From 7785f7ab2a361a12cd1fb6b3aed70fb0a2203294 Mon Sep 17 00:00:00 2001 From: Krille Date: Sun, 2 Feb 2025 16:51:27 +0100 Subject: [PATCH] chore: Follow up sync status --- lib/pages/chat/chat_app_bar_title.dart | 29 +++++++------- lib/pages/chat_list/chat_list_header.dart | 47 ++++++++++------------- lib/utils/sync_status_localization.dart | 15 ++++++++ 3 files changed, 50 insertions(+), 41 deletions(-) diff --git a/lib/pages/chat/chat_app_bar_title.dart b/lib/pages/chat/chat_app_bar_title.dart index 2b9f2cc37..f23b5bc54 100644 --- a/lib/pages/chat/chat_app_bar_title.dart +++ b/lib/pages/chat/chat_app_bar_title.dart @@ -61,9 +61,10 @@ class ChatAppBarTitle extends StatelessWidget { builder: (context, snapshot) { final status = room.client.onSyncStatus.value ?? const SyncStatusUpdate(SyncStatus.waitingForResponse); - final hide = room.client.onSync.value != null && - status.status != SyncStatus.error && - room.client.prevBatch != null; + final hide = FluffyThemes.isColumnMode(context) || + (room.client.onSync.value != null && + status.status != SyncStatus.error && + room.client.prevBatch != null); return AnimatedSize( duration: FluffyThemes.animationDuration, child: hide @@ -94,18 +95,16 @@ class ChatAppBarTitle extends StatelessWidget { ) : Row( children: [ - if (status.error != null) ...[ - Icon( - Icons.cloud_off_outlined, - size: 12, - color: status.error != null - ? Theme.of(context) - .colorScheme - .onErrorContainer - : null, - ), - const SizedBox(width: 4), - ], + Icon( + status.icon, + size: 12, + color: status.error != null + ? Theme.of(context) + .colorScheme + .onErrorContainer + : null, + ), + const SizedBox(width: 4), Expanded( child: Text( status.calcLocalizedString(context), diff --git a/lib/pages/chat_list/chat_list_header.dart b/lib/pages/chat_list/chat_list_header.dart index 79166b6ef..55a2eea8c 100644 --- a/lib/pages/chat_list/chat_list_header.dart +++ b/lib/pages/chat_list/chat_list_header.dart @@ -55,36 +55,31 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { borderRadius: BorderRadius.circular(99), ), contentPadding: EdgeInsets.zero, - label: hide - ? null - : Center( - child: Text( - status.calcLocalizedString(context), - style: TextStyle( - color: status.error != null - ? theme.colorScheme.onErrorContainer - : null, - ), - ), - ), - hintText: L10n.of(context).searchChatsRooms, + hintText: hide + ? L10n.of(context).searchChatsRooms + : status.calcLocalizedString(context), hintStyle: TextStyle( color: theme.colorScheme.onPrimaryContainer, fontWeight: FontWeight.normal, ), - prefixIcon: controller.isSearchMode - ? IconButton( - tooltip: L10n.of(context).cancel, - icon: const Icon(Icons.close_outlined), - onPressed: controller.cancelSearch, - color: theme.colorScheme.onPrimaryContainer, - ) - : IconButton( - onPressed: controller.startSearch, - icon: Icon( - Icons.search_outlined, - color: theme.colorScheme.onPrimaryContainer, - ), + prefixIcon: hide + ? controller.isSearchMode + ? IconButton( + tooltip: L10n.of(context).cancel, + icon: const Icon(Icons.close_outlined), + onPressed: controller.cancelSearch, + color: theme.colorScheme.onPrimaryContainer, + ) + : IconButton( + onPressed: controller.startSearch, + icon: Icon( + Icons.search_outlined, + color: theme.colorScheme.onPrimaryContainer, + ), + ) + : Icon( + status.icon, + size: 18, ), suffixIcon: controller.isSearchMode && globalSearch ? controller.isSearching diff --git a/lib/utils/sync_status_localization.dart b/lib/utils/sync_status_localization.dart index 1ea8f14e1..0cccbc7b9 100644 --- a/lib/utils/sync_status_localization.dart +++ b/lib/utils/sync_status_localization.dart @@ -6,6 +6,21 @@ import 'package:matrix/matrix.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; extension SyncStatusLocalization on SyncStatusUpdate { + IconData get icon { + switch (status) { + case SyncStatus.waitingForResponse: + return Icons.hourglass_empty_outlined; + case SyncStatus.error: + return Icons.cloud_off_outlined; + case SyncStatus.processing: + return Icons.hourglass_top_outlined; + case SyncStatus.cleaningUp: + return Icons.hourglass_bottom_outlined; + case SyncStatus.finished: + return Icons.hourglass_full_outlined; + } + } + String calcLocalizedString(BuildContext context) { final progress = this.progress; switch (status) {