mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Simplify user page
This commit is contained in:
		@@ -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,92 +123,60 @@ 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,
 | 
					            IconButton(
 | 
				
			||||||
            ),
 | 
					                icon: Icon(
 | 
				
			||||||
            // This gradient ensures that the toolbar icons are distinct
 | 
					                  Icons.chat,
 | 
				
			||||||
            // 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)],
 | 
					 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
              ),
 | 
					                onPressed: () {
 | 
				
			||||||
            ),
 | 
					                  openPrivateConversation(context, widget.userID);
 | 
				
			||||||
 | 
					                }),
 | 
				
			||||||
            const DecoratedBox(
 | 
					            PopupMenuButton<_MenuOptions>(
 | 
				
			||||||
              decoration: BoxDecoration(
 | 
					              itemBuilder: (c) => [
 | 
				
			||||||
                gradient: LinearGradient(
 | 
					                PopupMenuItem(
 | 
				
			||||||
                  begin: Alignment(0.0, 0.4),
 | 
					                  child: Text(tr("Friends")),
 | 
				
			||||||
                  end: Alignment(0.0, 0.9),
 | 
					                  enabled: _userInfo != null,
 | 
				
			||||||
                  colors: <Color>[Color(0x00000000), Color(0x60000000)],
 | 
					                  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() {
 | 
					  Widget _buildBody() {
 | 
				
			||||||
    return SliverList(
 | 
					    return Column(
 | 
				
			||||||
      delegate: SliverChildListDelegate(
 | 
					      children: <Widget>[
 | 
				
			||||||
        <Widget>[
 | 
					        // Posts create form
 | 
				
			||||||
          // Posts create form
 | 
					        _userInfo.canPostTexts
 | 
				
			||||||
          _userInfo.canPostTexts
 | 
					            ? PostCreateFormWidget(
 | 
				
			||||||
              ? PostCreateFormWidget(
 | 
					                postTarget: PostTarget.USER_PAGE,
 | 
				
			||||||
                  postTarget: PostTarget.USER_PAGE,
 | 
					                targetID: _userInfo.id,
 | 
				
			||||||
                  targetID: _userInfo.id,
 | 
					                onCreated: _postCreated,
 | 
				
			||||||
                  onCreated: _postCreated,
 | 
					              )
 | 
				
			||||||
                )
 | 
					            : Container(),
 | 
				
			||||||
              : Container(),
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          // Posts list
 | 
					        // Posts list
 | 
				
			||||||
          PostsListWidget(
 | 
					        PostsListWidget(
 | 
				
			||||||
            key: _postListKey,
 | 
					          key: _postListKey,
 | 
				
			||||||
            getPostsList: () => _postsHelper.getUserPosts(widget.userID),
 | 
					          getPostsList: () => _postsHelper.getUserPosts(widget.userID),
 | 
				
			||||||
            getOlder: (from) =>
 | 
					          getOlder: (from) =>
 | 
				
			||||||
                _postsHelper.getUserPosts(widget.userID, from: from),
 | 
					              _postsHelper.getUserPosts(widget.userID, from: from),
 | 
				
			||||||
            showPostsTarget: false,
 | 
					          showPostsTarget: false,
 | 
				
			||||||
            buildListView: false,
 | 
					          buildListView: false,
 | 
				
			||||||
          ),
 | 
					        ),
 | 
				
			||||||
        ],
 | 
					      ],
 | 
				
			||||||
      ),
 | 
					 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user