Skip to content

Commit

Permalink
chore: Follow up sync status
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Feb 2, 2025
1 parent ad138bc commit 7785f7a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 41 deletions.
29 changes: 14 additions & 15 deletions lib/pages/chat/chat_app_bar_title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
47 changes: 21 additions & 26 deletions lib/pages/chat_list/chat_list_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions lib/utils/sync_status_localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7785f7a

Please sign in to comment.