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]
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
void openFriendsList() => pushPage(

View File

@ -66,7 +66,7 @@ class _TabletRouteState extends MainController {
Container(height: 10),
GlobalSearchField(),
Container(height: 10),
Expanded(child: MembershipsPanel())
Expanded(child: MembershipsPanel(currentPage: currentPage))
],
),
),

View File

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