mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-26 12:58:51 +00:00
Simplify user page
This commit is contained in:
parent
824be11013
commit
69f8710f31
@ -3,7 +3,7 @@ import 'package:comunic/helpers/posts_helper.dart';
|
||||
import 'package:comunic/helpers/users_helper.dart';
|
||||
import 'package:comunic/models/advanced_user_info.dart';
|
||||
import 'package:comunic/ui/routes/home_route.dart';
|
||||
import 'package:comunic/ui/widgets/network_image_widget.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_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/scroll_watcher.dart';
|
||||
@ -37,7 +37,6 @@ class _UserPageScreenState extends State<UserPageScreen> {
|
||||
final PostsHelper _postsHelper = PostsHelper();
|
||||
|
||||
// Objects members
|
||||
final double _appBarHeight = 256.0;
|
||||
_PageStatus _status = _PageStatus.LOADING;
|
||||
AdvancedUserInfo _userInfo;
|
||||
GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
||||
@ -93,8 +92,8 @@ class _UserPageScreenState extends State<UserPageScreen> {
|
||||
return Scaffold(
|
||||
body: RefreshIndicator(
|
||||
key: _refreshIndicatorKey,
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[_buildHeader(), _buildBody()],
|
||||
child: ListView(
|
||||
children: <Widget>[_buildHeader(), _buildBody()],
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
controller: _scrollWatcher,
|
||||
),
|
||||
@ -124,92 +123,60 @@ class _UserPageScreenState extends State<UserPageScreen> {
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
return SliverAppBar(
|
||||
expandedHeight: _appBarHeight,
|
||||
floating: false,
|
||||
pinned: true,
|
||||
snap: false,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: Text(_userInfo.displayName),
|
||||
background: Stack(
|
||||
fit: StackFit.expand,
|
||||
return Container(
|
||||
color: Colors.black26,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
NetworkImageWidget(
|
||||
url: _userInfo.accountImageURL,
|
||||
height: _appBarHeight,
|
||||
roundedEdges: false,
|
||||
),
|
||||
// This gradient ensures that the toolbar icons are distinct
|
||||
// against the background image.
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment(0.0, -1.0),
|
||||
end: Alignment(0.0, -0.4),
|
||||
colors: <Color>[Color(0x60000000), Color(0x00000000)],
|
||||
AccountImageWidget(user: _userInfo),
|
||||
Text(" ${_userInfo.displayName}"),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.chat,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment(0.0, 0.4),
|
||||
end: Alignment(0.0, 0.9),
|
||||
colors: <Color>[Color(0x00000000), Color(0x60000000)],
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
openPrivateConversation(context, widget.userID);
|
||||
}),
|
||||
PopupMenuButton<_MenuOptions>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Friends")),
|
||||
enabled: _userInfo != null,
|
||||
value: _MenuOptions.FRIENDS_LIST,
|
||||
)
|
||||
],
|
||||
onSelected: _selectedMenuOption,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.chat,
|
||||
),
|
||||
onPressed: () {
|
||||
openPrivateConversation(context, widget.userID);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<_MenuOptions>(
|
||||
itemBuilder: (c) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Friends")),
|
||||
enabled: _userInfo != null,
|
||||
value: _MenuOptions.FRIENDS_LIST,
|
||||
)
|
||||
],
|
||||
onSelected: _selectedMenuOption,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
return SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
<Widget>[
|
||||
// Posts create form
|
||||
_userInfo.canPostTexts
|
||||
? PostCreateFormWidget(
|
||||
postTarget: PostTarget.USER_PAGE,
|
||||
targetID: _userInfo.id,
|
||||
onCreated: _postCreated,
|
||||
)
|
||||
: Container(),
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
// Posts create form
|
||||
_userInfo.canPostTexts
|
||||
? PostCreateFormWidget(
|
||||
postTarget: PostTarget.USER_PAGE,
|
||||
targetID: _userInfo.id,
|
||||
onCreated: _postCreated,
|
||||
)
|
||||
: Container(),
|
||||
|
||||
// Posts list
|
||||
PostsListWidget(
|
||||
key: _postListKey,
|
||||
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
||||
getOlder: (from) =>
|
||||
_postsHelper.getUserPosts(widget.userID, from: from),
|
||||
showPostsTarget: false,
|
||||
buildListView: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
// Posts list
|
||||
PostsListWidget(
|
||||
key: _postListKey,
|
||||
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
||||
getOlder: (from) =>
|
||||
_postsHelper.getUserPosts(widget.userID, from: from),
|
||||
showPostsTarget: false,
|
||||
buildListView: false,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user