mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Start to create group page tabs
This commit is contained in:
@ -10,6 +10,7 @@ import 'package:comunic/ui/widgets/group_membership_widget.dart';
|
||||
import 'package:comunic/ui/widgets/like_widget.dart';
|
||||
import 'package:comunic/ui/widgets/post_create_form_widget.dart';
|
||||
import 'package:comunic/ui/widgets/posts_list_widget.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -21,6 +22,10 @@ import 'package:flutter/material.dart';
|
||||
|
||||
enum _MenuItems { OPEN_MEMBERS, OPEN_SETTINGS }
|
||||
|
||||
Color get _headerTextColor => Colors.white;
|
||||
|
||||
Color get _headerColor => Colors.blueAccent.shade700;
|
||||
|
||||
class AuthorizedGroupPageScreen extends StatefulWidget {
|
||||
final AdvancedGroupInfo advancedGroupInfo;
|
||||
final Function() needRefresh;
|
||||
@ -38,73 +43,120 @@ class AuthorizedGroupPageScreen extends StatefulWidget {
|
||||
_AuthorizedGroupPageScreenState();
|
||||
}
|
||||
|
||||
class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
||||
class _AuthorizedGroupPageScreenState
|
||||
extends SafeState<AuthorizedGroupPageScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AdvancedGroupInfo get _group => widget.advancedGroupInfo;
|
||||
|
||||
TabController _tabController;
|
||||
|
||||
final _postsKey = GlobalKey<PostsListWidgetState>();
|
||||
|
||||
List<_GroupPageTab> get _tabs => [
|
||||
_GroupPageTab(widget: _buildGroupPagePostsList(), label: tr("Posts")),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_tabController = TabController(
|
||||
length: _tabs.length,
|
||||
initialIndex: 0,
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => widget.needRefresh(),
|
||||
child: _buildGroupPagePostsList(),
|
||||
return Column(
|
||||
children: [
|
||||
_buildGroupPageHeader(),
|
||||
Container(
|
||||
color: _headerColor,
|
||||
child: TabBar(
|
||||
tabs: _tabs.map((e) => e.tab).toList(),
|
||||
controller: _tabController,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _tabs.map((e) => e.widget).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Build group page header
|
||||
Widget _buildGroupPageHeader() {
|
||||
return Container(
|
||||
color: Colors.black26,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
GroupIcon(
|
||||
group: _group,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
" ${_group.displayName}",
|
||||
style: TextStyle(fontSize: 20),
|
||||
return DefaultTextStyle(
|
||||
style: TextStyle(color: _headerTextColor),
|
||||
child: Container(
|
||||
color: _headerColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
GroupIcon(
|
||||
group: _group,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
GroupMembershipWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
Expanded(
|
||||
child: Text(
|
||||
" ${_group.displayName}",
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Container(
|
||||
height: 4,
|
||||
),
|
||||
GroupFollowingWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
),
|
||||
Container(
|
||||
height: 2,
|
||||
),
|
||||
LikeWidget(
|
||||
likeElement: _group,
|
||||
),
|
||||
],
|
||||
),
|
||||
PopupMenuButton<_MenuItems>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Group members")),
|
||||
value: _MenuItems.OPEN_MEMBERS,
|
||||
enabled: _group.isAtLeastModerator,
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Group settings")),
|
||||
value: _MenuItems.OPEN_SETTINGS,
|
||||
enabled: _group.isAdmin,
|
||||
),
|
||||
],
|
||||
onSelected: _handleMenuSelection,
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
GroupMembershipWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
),
|
||||
Container(
|
||||
height: 4,
|
||||
),
|
||||
GroupFollowingWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
inactiveColor: Colors.blueAccent,
|
||||
activeColor: Colors.white,
|
||||
),
|
||||
Container(
|
||||
height: 2,
|
||||
),
|
||||
LikeWidget(
|
||||
inativeColor: Colors.blueAccent,
|
||||
activeColor: Colors.white,
|
||||
likeElement: _group,
|
||||
),
|
||||
],
|
||||
),
|
||||
PopupMenuButton<_MenuItems>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Group members")),
|
||||
value: _MenuItems.OPEN_MEMBERS,
|
||||
enabled: _group.isAtLeastModerator,
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Group settings")),
|
||||
value: _MenuItems.OPEN_SETTINGS,
|
||||
enabled: _group.isAdmin,
|
||||
),
|
||||
],
|
||||
onSelected: _handleMenuSelection,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -125,7 +177,6 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
||||
return PostsListWidget(
|
||||
key: _postsKey,
|
||||
topWidgets: <Widget>[
|
||||
_buildGroupPageHeader(),
|
||||
_buildPostCreationArea(),
|
||||
],
|
||||
getPostsList: () => PostsHelper().getGroupPosts(_group.id),
|
||||
@ -149,3 +200,16 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _GroupPageTab {
|
||||
final Widget widget;
|
||||
final String label;
|
||||
|
||||
const _GroupPageTab({
|
||||
@required this.widget,
|
||||
@required this.label,
|
||||
}) : assert(widget != null),
|
||||
assert(label != null);
|
||||
|
||||
Tab get tab => Tab(text: label);
|
||||
}
|
||||
|
Reference in New Issue
Block a user