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) {
|
builder: (context, snapshot) {
|
||||||
final status = room.client.onSyncStatus.value ??
|
final status = room.client.onSyncStatus.value ??
|
||||||
const SyncStatusUpdate(SyncStatus.waitingForResponse);
|
const SyncStatusUpdate(SyncStatus.waitingForResponse);
|
||||||
final hide = room.client.onSync.value != null &&
|
final hide = FluffyThemes.isColumnMode(context) ||
|
||||||
status.status != SyncStatus.error &&
|
(room.client.onSync.value != null &&
|
||||||
room.client.prevBatch != null;
|
status.status != SyncStatus.error &&
|
||||||
|
room.client.prevBatch != null);
|
||||||
return AnimatedSize(
|
return AnimatedSize(
|
||||||
duration: FluffyThemes.animationDuration,
|
duration: FluffyThemes.animationDuration,
|
||||||
child: hide
|
child: hide
|
||||||
|
|
@ -94,18 +95,16 @@ class ChatAppBarTitle extends StatelessWidget {
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
children: [
|
children: [
|
||||||
if (status.error != null) ...[
|
Icon(
|
||||||
Icon(
|
status.icon,
|
||||||
Icons.cloud_off_outlined,
|
size: 12,
|
||||||
size: 12,
|
color: status.error != null
|
||||||
color: status.error != null
|
? Theme.of(context)
|
||||||
? Theme.of(context)
|
.colorScheme
|
||||||
.colorScheme
|
.onErrorContainer
|
||||||
.onErrorContainer
|
: null,
|
||||||
: null,
|
),
|
||||||
),
|
const SizedBox(width: 4),
|
||||||
const SizedBox(width: 4),
|
|
||||||
],
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
status.calcLocalizedString(context),
|
status.calcLocalizedString(context),
|
||||||
|
|
|
||||||
|
|
@ -55,36 +55,31 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||||
borderRadius: BorderRadius.circular(99),
|
borderRadius: BorderRadius.circular(99),
|
||||||
),
|
),
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
label: hide
|
hintText: hide
|
||||||
? null
|
? L10n.of(context).searchChatsRooms
|
||||||
: Center(
|
: status.calcLocalizedString(context),
|
||||||
child: Text(
|
|
||||||
status.calcLocalizedString(context),
|
|
||||||
style: TextStyle(
|
|
||||||
color: status.error != null
|
|
||||||
? theme.colorScheme.onErrorContainer
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
hintText: L10n.of(context).searchChatsRooms,
|
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
color: theme.colorScheme.onPrimaryContainer,
|
color: theme.colorScheme.onPrimaryContainer,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
prefixIcon: controller.isSearchMode
|
prefixIcon: hide
|
||||||
? IconButton(
|
? controller.isSearchMode
|
||||||
tooltip: L10n.of(context).cancel,
|
? IconButton(
|
||||||
icon: const Icon(Icons.close_outlined),
|
tooltip: L10n.of(context).cancel,
|
||||||
onPressed: controller.cancelSearch,
|
icon: const Icon(Icons.close_outlined),
|
||||||
color: theme.colorScheme.onPrimaryContainer,
|
onPressed: controller.cancelSearch,
|
||||||
)
|
color: theme.colorScheme.onPrimaryContainer,
|
||||||
: IconButton(
|
)
|
||||||
onPressed: controller.startSearch,
|
: IconButton(
|
||||||
icon: Icon(
|
onPressed: controller.startSearch,
|
||||||
Icons.search_outlined,
|
icon: Icon(
|
||||||
color: theme.colorScheme.onPrimaryContainer,
|
Icons.search_outlined,
|
||||||
),
|
color: theme.colorScheme.onPrimaryContainer,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Icon(
|
||||||
|
status.icon,
|
||||||
|
size: 18,
|
||||||
),
|
),
|
||||||
suffixIcon: controller.isSearchMode && globalSearch
|
suffixIcon: controller.isSearchMode && globalSearch
|
||||||
? controller.isSearching
|
? controller.isSearching
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,21 @@ import 'package:matrix/matrix.dart';
|
||||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||||
|
|
||||||
extension SyncStatusLocalization on SyncStatusUpdate {
|
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) {
|
String calcLocalizedString(BuildContext context) {
|
||||||
final progress = this.progress;
|
final progress = this.progress;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue