From 566f205dc9019e27bb062caa5626c7ce768329ea Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 15 Apr 2020 18:23:38 +0200 Subject: [PATCH] Start to build group page --- .../screens/authorized_group_page_screen.dart | 61 +++++++++++++++++++ lib/ui/screens/group_screen.dart | 7 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 lib/ui/screens/authorized_group_page_screen.dart diff --git a/lib/ui/screens/authorized_group_page_screen.dart b/lib/ui/screens/authorized_group_page_screen.dart new file mode 100644 index 0000000..604c8dd --- /dev/null +++ b/lib/ui/screens/authorized_group_page_screen.dart @@ -0,0 +1,61 @@ +import 'package:comunic/models/advanced_group_info.dart'; +import 'package:comunic/ui/widgets/group_icon_widget.dart'; +import 'package:comunic/ui/widgets/group_membership_widget.dart'; +import 'package:flutter/material.dart'; + +/// Authorized group page screen +/// +/// This screen is shown when the user is allowed to access to a group's page +/// +/// @author Pierre Hubert + +class AuthorizedGroupPageScreen extends StatefulWidget { + final AdvancedGroupInfo advancedGroupInfo; + final Function() needRefresh; + + const AuthorizedGroupPageScreen({ + Key key, + @required this.advancedGroupInfo, + @required this.needRefresh, + }) : assert(advancedGroupInfo != null), + assert(needRefresh != null), + super(key: key); + + @override + _AuthorizedGroupPageScreenState createState() => + _AuthorizedGroupPageScreenState(); +} + +class _AuthorizedGroupPageScreenState extends State { + AdvancedGroupInfo get _group => widget.advancedGroupInfo; + + @override + Widget build(BuildContext context) { + return Column( + children: [_buildGroupPageHeader()], + ); + } + + /// Build group page header + _buildGroupPageHeader() { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + GroupIcon( + group: _group, + ), + Text( + " ${_group.displayName}", + style: TextStyle(fontSize: 20), + ), + Spacer(), + GroupMembershipWidget( + group: _group, + onUpdated: () => widget.needRefresh(), + ) + ], + ), + ); + } +} diff --git a/lib/ui/screens/group_screen.dart b/lib/ui/screens/group_screen.dart index 74dee54..e19ae19 100644 --- a/lib/ui/screens/group_screen.dart +++ b/lib/ui/screens/group_screen.dart @@ -1,4 +1,5 @@ import 'package:comunic/helpers/groups_helper.dart'; +import 'package:comunic/ui/screens/authorized_group_page_screen.dart'; import 'package:comunic/ui/screens/group_access_denied_screen.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -53,7 +54,11 @@ class _GroupPageScreenState extends SafeState { onMembershipAcquired: () => _refreshPage(), ); - // Create another screen for the group page + // Now we can show group page + return AuthorizedGroupPageScreen( + advancedGroupInfo: _getGroupResult.info, + needRefresh: () => _refreshPage(), + ); } /// Refresh the page