mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Start to create group page tabs
This commit is contained in:
parent
0920a36cef
commit
cc553e803d
@ -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/like_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/post_create_form_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/posts_list_widget.dart';
|
||||||
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -21,6 +22,10 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
enum _MenuItems { OPEN_MEMBERS, OPEN_SETTINGS }
|
enum _MenuItems { OPEN_MEMBERS, OPEN_SETTINGS }
|
||||||
|
|
||||||
|
Color get _headerTextColor => Colors.white;
|
||||||
|
|
||||||
|
Color get _headerColor => Colors.blueAccent.shade700;
|
||||||
|
|
||||||
class AuthorizedGroupPageScreen extends StatefulWidget {
|
class AuthorizedGroupPageScreen extends StatefulWidget {
|
||||||
final AdvancedGroupInfo advancedGroupInfo;
|
final AdvancedGroupInfo advancedGroupInfo;
|
||||||
final Function() needRefresh;
|
final Function() needRefresh;
|
||||||
@ -38,23 +43,64 @@ class AuthorizedGroupPageScreen extends StatefulWidget {
|
|||||||
_AuthorizedGroupPageScreenState();
|
_AuthorizedGroupPageScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
class _AuthorizedGroupPageScreenState
|
||||||
|
extends SafeState<AuthorizedGroupPageScreen>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
AdvancedGroupInfo get _group => widget.advancedGroupInfo;
|
AdvancedGroupInfo get _group => widget.advancedGroupInfo;
|
||||||
|
|
||||||
|
TabController _tabController;
|
||||||
|
|
||||||
final _postsKey = GlobalKey<PostsListWidgetState>();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RefreshIndicator(
|
return Column(
|
||||||
onRefresh: () => widget.needRefresh(),
|
children: [
|
||||||
child: _buildGroupPagePostsList(),
|
_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
|
/// Build group page header
|
||||||
Widget _buildGroupPageHeader() {
|
Widget _buildGroupPageHeader() {
|
||||||
return Container(
|
return DefaultTextStyle(
|
||||||
color: Colors.black26,
|
style: TextStyle(color: _headerTextColor),
|
||||||
|
child: Container(
|
||||||
|
color: _headerColor,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -69,6 +115,7 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
GroupMembershipWidget(
|
GroupMembershipWidget(
|
||||||
group: _group,
|
group: _group,
|
||||||
@ -80,11 +127,15 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
|||||||
GroupFollowingWidget(
|
GroupFollowingWidget(
|
||||||
group: _group,
|
group: _group,
|
||||||
onUpdated: () => widget.needRefresh(),
|
onUpdated: () => widget.needRefresh(),
|
||||||
|
inactiveColor: Colors.blueAccent,
|
||||||
|
activeColor: Colors.white,
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
height: 2,
|
height: 2,
|
||||||
),
|
),
|
||||||
LikeWidget(
|
LikeWidget(
|
||||||
|
inativeColor: Colors.blueAccent,
|
||||||
|
activeColor: Colors.white,
|
||||||
likeElement: _group,
|
likeElement: _group,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -107,6 +158,7 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +177,6 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
|||||||
return PostsListWidget(
|
return PostsListWidget(
|
||||||
key: _postsKey,
|
key: _postsKey,
|
||||||
topWidgets: <Widget>[
|
topWidgets: <Widget>[
|
||||||
_buildGroupPageHeader(),
|
|
||||||
_buildPostCreationArea(),
|
_buildPostCreationArea(),
|
||||||
],
|
],
|
||||||
getPostsList: () => PostsHelper().getGroupPosts(_group.id),
|
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);
|
||||||
|
}
|
||||||
|
@ -12,10 +12,16 @@ import 'package:flutter/material.dart';
|
|||||||
class GroupFollowingWidget extends StatefulWidget {
|
class GroupFollowingWidget extends StatefulWidget {
|
||||||
final Group group;
|
final Group group;
|
||||||
final Function() onUpdated;
|
final Function() onUpdated;
|
||||||
|
final Color inactiveColor;
|
||||||
|
final Color activeColor;
|
||||||
|
|
||||||
const GroupFollowingWidget(
|
const GroupFollowingWidget({
|
||||||
{Key key, @required this.group, @required this.onUpdated})
|
Key key,
|
||||||
: assert(group != null),
|
@required this.group,
|
||||||
|
@required this.onUpdated,
|
||||||
|
this.activeColor,
|
||||||
|
this.inactiveColor,
|
||||||
|
}) : assert(group != null),
|
||||||
assert(onUpdated != null),
|
assert(onUpdated != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@ -31,9 +37,17 @@ class _GroupFollowingWidgetState extends SafeState<GroupFollowingWidget> {
|
|||||||
if (!_group.isAtLeastMember) return Container();
|
if (!_group.isAtLeastMember) return Container();
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
child: Text(
|
child: RichText(
|
||||||
_group.following ? tr("Following") : tr("Follow"),
|
text: TextSpan(children: [
|
||||||
style: TextStyle(color: Colors.blue),
|
WidgetSpan(
|
||||||
|
child: Icon(
|
||||||
|
Icons.notifications,
|
||||||
|
size: 16.0,
|
||||||
|
color: _group.following ? widget.activeColor : widget.inactiveColor,
|
||||||
|
)),
|
||||||
|
TextSpan(
|
||||||
|
text: " " + (_group.following ? tr("Following") : tr("Follow"))),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
onTap: () => _toggleFollowing(),
|
onTap: () => _toggleFollowing(),
|
||||||
);
|
);
|
||||||
|
@ -16,12 +16,16 @@ typedef UpdatedLikingCallBack = Function(int, bool);
|
|||||||
class LikeWidget extends StatefulWidget {
|
class LikeWidget extends StatefulWidget {
|
||||||
final LikeElement likeElement;
|
final LikeElement likeElement;
|
||||||
final double buttonIconSize;
|
final double buttonIconSize;
|
||||||
|
final Color activeColor;
|
||||||
|
final Color inativeColor;
|
||||||
|
|
||||||
const LikeWidget({
|
const LikeWidget(
|
||||||
Key key,
|
{Key key,
|
||||||
@required this.likeElement,
|
@required this.likeElement,
|
||||||
this.buttonIconSize = 15.0,
|
this.buttonIconSize = 15.0,
|
||||||
}) : assert(likeElement != null),
|
this.activeColor,
|
||||||
|
this.inativeColor})
|
||||||
|
: assert(likeElement != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -54,7 +58,9 @@ class _LikeWidgetState extends SafeState<LikeWidget> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(
|
Icon(
|
||||||
Icons.thumb_up,
|
Icons.thumb_up,
|
||||||
color: elem.userLike ? Colors.blue : null,
|
color: elem.userLike
|
||||||
|
? (widget.activeColor ?? Colors.blue)
|
||||||
|
: widget.inativeColor,
|
||||||
size: widget.buttonIconSize,
|
size: widget.buttonIconSize,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
Loading…
Reference in New Issue
Block a user