1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00

Simplify user page

This commit is contained in:
Pierre HUBERT 2020-04-16 14:20:24 +02:00
parent 824be11013
commit 69f8710f31

View File

@ -3,7 +3,7 @@ import 'package:comunic/helpers/posts_helper.dart';
import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/models/advanced_user_info.dart'; import 'package:comunic/models/advanced_user_info.dart';
import 'package:comunic/ui/routes/home_route.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/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/scroll_watcher.dart'; import 'package:comunic/ui/widgets/scroll_watcher.dart';
@ -37,7 +37,6 @@ class _UserPageScreenState extends State<UserPageScreen> {
final PostsHelper _postsHelper = PostsHelper(); final PostsHelper _postsHelper = PostsHelper();
// Objects members // Objects members
final double _appBarHeight = 256.0;
_PageStatus _status = _PageStatus.LOADING; _PageStatus _status = _PageStatus.LOADING;
AdvancedUserInfo _userInfo; AdvancedUserInfo _userInfo;
GlobalKey<RefreshIndicatorState> _refreshIndicatorKey = GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
@ -93,8 +92,8 @@ class _UserPageScreenState extends State<UserPageScreen> {
return Scaffold( return Scaffold(
body: RefreshIndicator( body: RefreshIndicator(
key: _refreshIndicatorKey, key: _refreshIndicatorKey,
child: CustomScrollView( child: ListView(
slivers: <Widget>[_buildHeader(), _buildBody()], children: <Widget>[_buildHeader(), _buildBody()],
physics: AlwaysScrollableScrollPhysics(), physics: AlwaysScrollableScrollPhysics(),
controller: _scrollWatcher, controller: _scrollWatcher,
), ),
@ -124,54 +123,22 @@ class _UserPageScreenState extends State<UserPageScreen> {
} }
Widget _buildHeader() { Widget _buildHeader() {
return SliverAppBar( return Container(
expandedHeight: _appBarHeight, color: Colors.black26,
floating: false, child: Padding(
pinned: true, padding: const EdgeInsets.all(8.0),
snap: false, child: Row(
flexibleSpace: FlexibleSpaceBar(
title: Text(_userInfo.displayName),
background: Stack(
fit: StackFit.expand,
children: <Widget>[ children: <Widget>[
NetworkImageWidget( AccountImageWidget(user: _userInfo),
url: _userInfo.accountImageURL, Text(" ${_userInfo.displayName}"),
height: _appBarHeight, Spacer(),
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)],
),
),
),
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment(0.0, 0.4),
end: Alignment(0.0, 0.9),
colors: <Color>[Color(0x00000000), Color(0x60000000)],
),
),
),
],
),
),
actions: <Widget>[
IconButton( IconButton(
icon: Icon( icon: Icon(
Icons.chat, Icons.chat,
), ),
onPressed: () { onPressed: () {
openPrivateConversation(context, widget.userID); openPrivateConversation(context, widget.userID);
}, }),
),
PopupMenuButton<_MenuOptions>( PopupMenuButton<_MenuOptions>(
itemBuilder: (c) => [ itemBuilder: (c) => [
PopupMenuItem( PopupMenuItem(
@ -183,13 +150,14 @@ class _UserPageScreenState extends State<UserPageScreen> {
onSelected: _selectedMenuOption, onSelected: _selectedMenuOption,
), ),
], ],
),
),
); );
} }
Widget _buildBody() { Widget _buildBody() {
return SliverList( return Column(
delegate: SliverChildListDelegate( children: <Widget>[
<Widget>[
// Posts create form // Posts create form
_userInfo.canPostTexts _userInfo.canPostTexts
? PostCreateFormWidget( ? PostCreateFormWidget(
@ -209,7 +177,6 @@ class _UserPageScreenState extends State<UserPageScreen> {
buildListView: false, buildListView: false,
), ),
], ],
),
); );
} }