chore: Follow up sync status
This commit is contained in:
parent
ad138bc7c0
commit
7785f7ab2a
3 changed files with 50 additions and 41 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue