mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Add friend tab
This commit is contained in:
parent
20e486fe26
commit
160a3e1f27
@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:comunic/enums/user_page_visibility.dart';
|
||||
import 'package:comunic/helpers/serialization/base_serialization_helper.dart';
|
||||
import 'package:comunic/lists/custom_emojies_list.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@ -44,6 +45,8 @@ class User implements SerializableElement<User> {
|
||||
bool get hasVirtualDirectory =>
|
||||
virtualDirectory != null && virtualDirectory.length > 0;
|
||||
|
||||
bool get isCurrentUser => id == userID();
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"firstName": firstName,
|
||||
|
@ -20,6 +20,10 @@ import 'package:flutter/material.dart';
|
||||
enum _ErrorsLevel { NONE, MINOR, MAJOR }
|
||||
|
||||
class FriendsListScreen extends StatefulWidget {
|
||||
final bool showAppBar;
|
||||
|
||||
const FriendsListScreen({Key key, this.showAppBar = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _FriendsListScreenState();
|
||||
}
|
||||
@ -103,9 +107,11 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
appBar: widget.showAppBar
|
||||
? AppBar(
|
||||
title: Text(tr("Your friends list")),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
body: _buildBody(),
|
||||
);
|
||||
|
||||
|
@ -13,11 +13,14 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class OtherUserFriendsListScreen extends StatefulWidget {
|
||||
final int userID;
|
||||
final bool enableAppBar;
|
||||
|
||||
const OtherUserFriendsListScreen({
|
||||
Key key,
|
||||
@required this.userID,
|
||||
this.enableAppBar = true,
|
||||
}) : assert(userID != null),
|
||||
assert(enableAppBar != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@ -74,9 +77,11 @@ class _OtherUserFriendsListScreenState
|
||||
if (_usersInfo == null) return buildCenteredProgressBar();
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
appBar: widget.enableAppBar
|
||||
? AppBar(
|
||||
title: Text(_routeName),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
body: ListView.builder(
|
||||
itemCount: _friendsList.length,
|
||||
itemBuilder: (c, i) => SimpleUserTile(
|
||||
|
@ -1,4 +1,6 @@
|
||||
import 'package:comunic/models/advanced_user_info.dart';
|
||||
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/other_friends_lists_screen.dart';
|
||||
import 'package:comunic/ui/screens/user_page_sections/user_page_header.dart';
|
||||
import 'package:comunic/ui/screens/user_page_sections/user_posts_section.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
@ -36,7 +38,21 @@ class _UserMobilePageState extends State<UserMobilePage>
|
||||
user: widget.userInfo,
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
// User friends
|
||||
UserPageTab(
|
||||
label: tr("Friends"),
|
||||
onBuild: (c) => widget.userInfo.isCurrentUser
|
||||
? FriendsListScreen(
|
||||
showAppBar: false,
|
||||
)
|
||||
: OtherUserFriendsListScreen(
|
||||
userID: widget.userInfo.id,
|
||||
enableAppBar: false,
|
||||
),
|
||||
visible: widget.userInfo.isFriendsListPublic ||
|
||||
widget.userInfo.isCurrentUser),
|
||||
].where((element) => element.visible).toList();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -85,12 +101,15 @@ class _UserMobilePageState extends State<UserMobilePage>
|
||||
class UserPageTab {
|
||||
final String label;
|
||||
final WidgetBuilder onBuild;
|
||||
final bool visible;
|
||||
|
||||
UserPageTab({
|
||||
@required this.label,
|
||||
@required this.onBuild,
|
||||
this.visible = true,
|
||||
}) : assert(label != null),
|
||||
assert(onBuild != null);
|
||||
assert(onBuild != null),
|
||||
assert(visible != null);
|
||||
|
||||
Tab get tab => Tab(text: label);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user