1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 22:39:22 +00:00

Highlight active user / group in memberships panel

This commit is contained in:
Pierre HUBERT 2020-05-11 13:50:13 +02:00
parent 1bd2bdd1aa
commit 773cf17da0
3 changed files with 41 additions and 18 deletions

View File

@ -99,7 +99,9 @@ abstract class MainController extends State<MainRoute> {
/// Open a specific group page specified by its [groupID] /// Open a specific group page specified by its [groupID]
void openGroup(int groupID) => pushPage(PageInfo( void openGroup(int groupID) => pushPage(PageInfo(
type: PageType.GROUP_PAGE, child: GroupPageScreen(groupID: groupID))); type: PageType.GROUP_PAGE,
child: GroupPageScreen(groupID: groupID),
id: groupID));
/// Display the list of friends of current user /// Display the list of friends of current user
void openFriendsList() => pushPage( void openFriendsList() => pushPage(

View File

@ -66,17 +66,17 @@ class _TabletRouteState extends MainController {
Container(height: 10), Container(height: 10),
GlobalSearchField(), GlobalSearchField(),
Container(height: 10), Container(height: 10),
Expanded(child: MembershipsPanel()) Expanded(child: MembershipsPanel(currentPage: currentPage))
], ],
), ),
), ),
); );
Widget _buildRightPane() => Container( Widget _buildRightPane() => Container(
key: currentPage.key, key: currentPage.key,
width: MediaQuery.of(context).size.width - _SideBarSize, width: MediaQuery.of(context).size.width - _SideBarSize,
child: currentPage.child, child: currentPage.child,
); );
@override @override
void pushPage(PageInfo page) { void pushPage(PageInfo page) {

View File

@ -9,6 +9,7 @@ import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/friend.dart'; import 'package:comunic/models/friend.dart';
import 'package:comunic/models/membership.dart'; import 'package:comunic/models/membership.dart';
import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart';
import 'package:comunic/ui/routes/main_route/page_info.dart';
import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart';
import 'package:comunic/ui/widgets/group_icon_widget.dart'; import 'package:comunic/ui/widgets/group_icon_widget.dart';
import 'package:comunic/ui/widgets/group_membership_widget.dart'; import 'package:comunic/ui/widgets/group_membership_widget.dart';
@ -23,6 +24,14 @@ import 'package:flutter/material.dart';
/// @author Pierre Hubert /// @author Pierre Hubert
class MembershipsPanel extends StatefulWidget { class MembershipsPanel extends StatefulWidget {
final PageInfo currentPage;
const MembershipsPanel({
Key key,
@required this.currentPage,
}) : assert(currentPage != null),
super(key: key);
@override @override
_MembershipsPanelState createState() => _MembershipsPanelState(); _MembershipsPanelState createState() => _MembershipsPanelState();
} }
@ -127,11 +136,17 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
style: TextStyle(color: connected ? Colors.green : null), style: TextStyle(color: connected ? Colors.green : null),
); );
return ListTile( return Container(
leading: AccountImageWidget(user: user, width: _MembershipIconsWidth), color: widget.currentPage.type == PageType.USER_PAGE &&
title: Text(user.displayName), widget.currentPage.id == user.id
subtitle: subtitle, ? Colors.grey.shade800
onTap: () => MainController.of(context).openUserPage(user.id), : null,
child: ListTile(
leading: AccountImageWidget(user: user, width: _MembershipIconsWidth),
title: Text(user.displayName),
subtitle: subtitle,
onTap: () => MainController.of(context).openUserPage(user.id),
),
); );
} }
@ -150,14 +165,20 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
subtitle = Text(diffTimeFromNowToStr(membership.lastActive)); subtitle = Text(diffTimeFromNowToStr(membership.lastActive));
} }
return ListTile( return Container(
leading: GroupIcon( color: widget.currentPage.type == PageType.GROUP_PAGE &&
group: group, widget.currentPage.id == group.id
width: _MembershipIconsWidth, ? Colors.grey.shade800
: null,
child: ListTile(
leading: GroupIcon(
group: group,
width: _MembershipIconsWidth,
),
title: Text(group.displayName),
subtitle: subtitle,
onTap: () => MainController.of(context).openGroup(group.id),
), ),
title: Text(group.displayName),
subtitle: subtitle,
onTap: () => MainController.of(context).openGroup(group.id),
); );
} }