1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-02-16 21:52:38 +00:00

Show friends list as a dialog

This commit is contained in:
Pierre HUBERT 2020-05-16 17:36:52 +02:00
parent f8ba06d0ae
commit cfc3552011
2 changed files with 34 additions and 22 deletions

View File

@ -115,8 +115,11 @@ abstract class MainController extends State<MainRoute> {
id: groupID)); id: groupID));
/// Display the list of friends of current user /// Display the list of friends of current user
void openFriendsList() => pushPage( void openFriendsList() => pushPage(PageInfo(
PageInfo(type: PageType.FRIENDS_LIST_PAGE, child: FriendsListScreen())); type: PageType.FRIENDS_LIST_PAGE,
child: FriendsListScreen(),
canShowAsDialog: true,
));
/// Open search page /// Open search page
void openSearchPage() => pushPage(PageInfo(child: SearchScreen())); void openSearchPage() => pushPage(PageInfo(child: SearchScreen()));
@ -127,7 +130,10 @@ abstract class MainController extends State<MainRoute> {
/// Display the list of friends of a user /// Display the list of friends of a user
void openUserFriendsList(int id) { void openUserFriendsList(int id) {
if (id != userID()) if (id != userID())
pushPage(PageInfo(child: OtherUserFriendsListScreen(userID: id))); pushPage(PageInfo(
child: OtherUserFriendsListScreen(userID: id),
canShowAsDialog: true,
));
else else
openFriendsList(); openFriendsList();
} }

View File

@ -43,7 +43,6 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
error = _friendsList == null ? _ErrorsLevel.MAJOR : _ErrorsLevel.MINOR; error = _friendsList == null ? _ErrorsLevel.MAJOR : _ErrorsLevel.MINOR;
} }
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
@ -69,7 +68,7 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
final list = await _friendsHelper.getList(online: online); final list = await _friendsHelper.getList(online: online);
// Check if there is no cache yet // Check if there is no cache yet
if(!online && list.isEmpty) return; if (!online && list.isEmpty) return;
// Check for errors // Check for errors
if (list == null) return _gotError(); if (list == null) return _gotError();
@ -103,7 +102,14 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
); );
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(tr("Your friends list")),
),
body: _buildBody(),
);
Widget _buildBody() {
if (_error == _ErrorsLevel.MAJOR) return _buildError(); if (_error == _ErrorsLevel.MAJOR) return _buildError();
if (_friendsList == null) return buildCenteredProgressBar(); if (_friendsList == null) return buildCenteredProgressBar();
@ -161,23 +167,23 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
final choice = await showDialog<bool>( final choice = await showDialog<bool>(
context: context, context: context,
builder: (b) => AlertDialog( builder: (b) => AlertDialog(
title: Text(tr("Delete friend")), title: Text(tr("Delete friend")),
content: Text(tr( content: Text(tr(
"Are you sure do you want to remove this friend from your list of friends ? A friendship request will have to be sent to get this user back to your list!")), "Are you sure do you want to remove this friend from your list of friends ? A friendship request will have to be sent to get this user back to your list!")),
actions: <Widget>[ actions: <Widget>[
FlatButton( FlatButton(
onPressed: () => Navigator.pop(context, false), onPressed: () => Navigator.pop(context, false),
child: Text(tr("Cancel").toUpperCase()), child: Text(tr("Cancel").toUpperCase()),
),
FlatButton(
onPressed: () => Navigator.pop(context, true),
child: Text(
tr("Confirm").toUpperCase(),
style: TextStyle(color: Colors.red),
),
),
],
), ),
FlatButton(
onPressed: () => Navigator.pop(context, true),
child: Text(
tr("Confirm").toUpperCase(),
style: TextStyle(color: Colors.red),
),
),
],
),
); );
if (choice == null || !choice) return; if (choice == null || !choice) return;