From 1f0abe9c2b7f891bad8c00d2d19a203008ffe76e Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 22 Apr 2021 15:15:40 +0200 Subject: [PATCH] Ready to build presence section --- lib/helpers/groups_helper.dart | 1 + lib/models/advanced_group_info.dart | 5 ++++- lib/models/group.dart | 5 ++++- .../screens/authorized_group_page_screen.dart | 10 +++++++++- .../group_sections/forez_presence_section.dart | 17 +++++++++++++++++ lib/ui/screens/groups_list_screen.dart | 3 ++- 6 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 lib/ui/screens/group_sections/forez_presence_section.dart diff --git a/lib/helpers/groups_helper.dart b/lib/helpers/groups_helper.dart index 90b545a..4259a21 100644 --- a/lib/helpers/groups_helper.dart +++ b/lib/helpers/groups_helper.dart @@ -409,6 +409,7 @@ class GroupsHelper { .map((s) => ConversationsHelper.apiToConversation(s)) .cast() .toList(), + isForezGroup: map["is_forez_group"], ); /// Create [GroupMembership] object from API entry diff --git a/lib/models/advanced_group_info.dart b/lib/models/advanced_group_info.dart index f2eb9c2..021f6f9 100644 --- a/lib/models/advanced_group_info.dart +++ b/lib/models/advanced_group_info.dart @@ -17,6 +17,7 @@ class AdvancedGroupInfo extends Group implements LikeElement { int likes; bool userLike; List conversations; + bool isForezGroup; AdvancedGroupInfo({ @required int id, @@ -36,7 +37,9 @@ class AdvancedGroupInfo extends Group implements LikeElement { @required this.likes, @required this.userLike, @required this.conversations, - }) : super( + @required this.isForezGroup, + }) : assert(isForezGroup != null), + super( id: id, name: name, iconURL: iconURL, diff --git a/lib/models/group.dart b/lib/models/group.dart index b28e3eb..de448d7 100644 --- a/lib/models/group.dart +++ b/lib/models/group.dart @@ -19,7 +19,7 @@ enum GroupRegistrationLevel { OPEN, MODERATED, CLOSED } enum GroupPostCreationLevel { MODERATORS, MEMBERS } -class Group { +class Group implements Comparable { final int id; String name; final String iconURL; @@ -70,4 +70,7 @@ class Group { membershipLevel == GroupMembershipLevel.MODERATOR || (membershipLevel == GroupMembershipLevel.MEMBER && postCreationLevel == GroupPostCreationLevel.MEMBERS); + + @override + int compareTo(Group other) => id.compareTo(other.id); } diff --git a/lib/ui/screens/authorized_group_page_screen.dart b/lib/ui/screens/authorized_group_page_screen.dart index f1de4ec..858dd78 100644 --- a/lib/ui/screens/authorized_group_page_screen.dart +++ b/lib/ui/screens/authorized_group_page_screen.dart @@ -1,6 +1,7 @@ import 'package:comunic/models/advanced_group_info.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/screens/group_sections/about_group_section.dart'; +import 'package:comunic/ui/screens/group_sections/forez_presence_section.dart'; import 'package:comunic/ui/screens/group_sections/group_conversation_section.dart'; import 'package:comunic/ui/screens/group_sections/group_members_screen.dart'; import 'package:comunic/ui/screens/group_sections/group_posts_section.dart'; @@ -57,6 +58,13 @@ class _AuthorizedGroupPageScreenState label: tr("Posts"), ), + // Forez presence tab + _GroupPageTab( + widget: (c) => ForezPresenceSection(), + label: tr("Presence"), + visible: _group.isForezGroup, + ), + // About the group _GroupPageTab( widget: (c) => AboutGroupSection(group: _group), @@ -72,7 +80,7 @@ class _AuthorizedGroupPageScreenState // Add group conversations ..insertAll( - 1, + 2, _group.conversations .map((e) => _GroupPageTab( widget: (c) => GroupConversationSection(conv: e), diff --git a/lib/ui/screens/group_sections/forez_presence_section.dart b/lib/ui/screens/group_sections/forez_presence_section.dart new file mode 100644 index 0000000..bc2876f --- /dev/null +++ b/lib/ui/screens/group_sections/forez_presence_section.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +/// Forez presence section +/// +/// @author Pierre Hubert + +class ForezPresenceSection extends StatefulWidget { + @override + _ForezPresenceSectionState createState() => _ForezPresenceSectionState(); +} + +class _ForezPresenceSectionState extends State { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/ui/screens/groups_list_screen.dart b/lib/ui/screens/groups_list_screen.dart index cf79d2a..dfe4777 100644 --- a/lib/ui/screens/groups_list_screen.dart +++ b/lib/ui/screens/groups_list_screen.dart @@ -61,7 +61,8 @@ class _GroupsListScreenState extends SafeState { } Widget _buildGroupsList() => ListView( - children: _groups.values + children: (_groups.values.toList() + ..sort((one, two) => two.id.compareTo(one.id))) .map((g) => ListTile( leading: GroupIcon(group: g), title: Text(g.displayName),