From 486072374854fadf32e92bb963bd4d0f66442b18 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 25 Feb 2021 13:24:07 +0100 Subject: [PATCH] change: Settings button to appBar --- .../default_bottom_navigation_bar.dart | 12 +---------- lib/main.dart | 1 - lib/views/chat_list.dart | 20 ++++++++++++++++--- lib/views/contacts.dart | 20 ++++++++++++++----- lib/views/settings.dart | 7 ++++--- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/lib/components/default_bottom_navigation_bar.dart b/lib/components/default_bottom_navigation_bar.dart index 296f2f3d..3ef5621e 100644 --- a/lib/components/default_bottom_navigation_bar.dart +++ b/lib/components/default_bottom_navigation_bar.dart @@ -25,18 +25,13 @@ class DefaultBottomNavigationBar extends StatelessWidget { AdaptivePageLayout.of(context) .pushNamedAndRemoveUntilIsFirst('/discover'); break; - case 3: - AdaptivePageLayout.of(context) - .pushNamedAndRemoveUntilIsFirst('/settings'); - break; } }, backgroundColor: Theme.of(context).scaffoldBackgroundColor, selectedItemColor: Theme.of(context).accentColor, currentIndex: currentIndex, - //unselectedItemColor: Theme.of(context).textTheme.bodyText1.color, type: BottomNavigationBarType.fixed, - showUnselectedLabels: false, + showUnselectedLabels: true, items: [ BottomNavigationBarItem( icon: Icon(currentIndex == 0 ? Icons.people : Icons.people_outlined), @@ -54,11 +49,6 @@ class DefaultBottomNavigationBar extends StatelessWidget { : CupertinoIcons.compass), label: L10n.of(context).discover, ), - BottomNavigationBarItem( - icon: Icon( - currentIndex == 3 ? Icons.settings : Icons.settings_outlined), - label: L10n.of(context).settings, - ), ], ); } diff --git a/lib/main.dart b/lib/main.dart index 2f94be52..22d29895 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -83,7 +83,6 @@ class App extends StatelessWidget { '/', '/discover', '/contacts', - '/settings', }.contains(settings.name) ? CupertinoPageRoute(builder: builder) : FadeRoute(page: builder(context)), diff --git a/lib/views/chat_list.dart b/lib/views/chat_list.dart index 8ee91edd..29b7aec4 100644 --- a/lib/views/chat_list.dart +++ b/lib/views/chat_list.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_page_layout/adaptive_page_layout.dart'; import 'package:famedlysdk/famedlysdk.dart'; +import 'package:fluffychat/components/avatar.dart'; import 'package:fluffychat/components/connection_status_header.dart'; import 'package:fluffychat/components/default_app_bar_search_field.dart'; import 'package:fluffychat/components/default_bottom_navigation_bar.dart'; @@ -188,7 +189,22 @@ class _ChatListState extends State { AppBar( elevation: 1, leading: selectMode == SelectMode.normal - ? null + ? Center( + child: InkWell( + borderRadius: BorderRadius.circular(32), + child: FutureBuilder( + future: Matrix.of(context).client.ownProfile, + builder: (_, snapshot) => Avatar( + snapshot.data?.avatarUrl ?? Uri.parse(''), + snapshot.data?.displayname ?? + Matrix.of(context).client.userID.localpart, + size: 32, + ), + ), + onTap: () => AdaptivePageLayout.of(context) + .pushNamedAndRemoveUntilIsFirst('/settings'), + ), + ) : IconButton( tooltip: L10n.of(context).cancel, icon: Icon(Icons.close_outlined), @@ -360,8 +376,6 @@ class _ChatListState extends State { .pushNamedAndRemoveUntilIsFirst('/newprivatechat'), ) : null, - floatingActionButtonLocation: - FloatingActionButtonLocation.centerDocked, bottomNavigationBar: selectMode == SelectMode.normal ? DefaultBottomNavigationBar(currentIndex: 1) : null, diff --git a/lib/views/contacts.dart b/lib/views/contacts.dart index f94014ab..826f31a8 100644 --- a/lib/views/contacts.dart +++ b/lib/views/contacts.dart @@ -62,7 +62,8 @@ class _ContactsState extends State { @override Widget build(BuildContext context) { - _onSync ??= Matrix.of(context).client.onSync.stream.listen((_) { + final client = Matrix.of(context).client; + _onSync ??= client.onSync.stream.listen((_) { if (DateTime.now().millisecondsSinceEpoch - _lastSetState.millisecondsSinceEpoch < 1000) { @@ -78,6 +79,10 @@ class _ContactsState extends State { .where((p) => p.senderId.toLowerCase().contains(_controller.text.toLowerCase())) .toList(); + if (client.presences[client.userID]?.presence?.statusMsg?.isNotEmpty ?? + false) { + contactList.add(client.presences[client.userID]); + } return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, @@ -147,9 +152,8 @@ class _ContactsState extends State { color: Theme.of(context).accentColor), ), onPressed: () => FluffyShare.share( - L10n.of(context).inviteText( - Matrix.of(context).client.userID, - 'https://matrix.to/#/${Matrix.of(context).client.userID}'), + L10n.of(context).inviteText(client.userID, + 'https://matrix.to/#/${client.userID}'), context), ), ), @@ -196,7 +200,13 @@ class _ContactListTile extends StatelessWidget { ), ), title: Text(displayname), - subtitle: Text(contact.getLocalizedStatusMessage(context)), + subtitle: Text(contact.getLocalizedStatusMessage(context), + style: contact.presence.statusMsg?.isNotEmpty ?? false + ? TextStyle( + color: Theme.of(context).accentColor, + fontWeight: FontWeight.bold, + ) + : null), onTap: () => AdaptivePageLayout.of(context).pushNamed( '/rooms/${Matrix.of(context).client.getDirectChatFromUserId(contact.senderId)}'), ); diff --git a/lib/views/settings.dart b/lib/views/settings.dart index fcfbd3ab..2bc04912 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -365,8 +365,10 @@ class _SettingsState extends State { headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) => [ SliverAppBar( - elevation: 1, - automaticallyImplyLeading: false, + leading: IconButton( + icon: Icon(Icons.close_outlined), + onPressed: () => AdaptivePageLayout.of(context).popUntilIsFirst(), + ), expandedHeight: 300.0, floating: true, pinned: true, @@ -590,7 +592,6 @@ class _SettingsState extends State { ], ), ), - bottomNavigationBar: DefaultBottomNavigationBar(currentIndex: 3), ); } }