chore: Better connection status indicator
This commit is contained in:
parent
892e379a2a
commit
7599ce8627
7 changed files with 195 additions and 187 deletions
|
|
@ -2,11 +2,13 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/utils/date_time_extension.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/utils/sync_status_localization.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/presence_builder.dart';
|
||||
|
||||
|
|
@ -54,30 +56,73 @@ class ChatAppBarTitle extends StatelessWidget {
|
|||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
AnimatedSize(
|
||||
duration: FluffyThemes.animationDuration,
|
||||
child: PresenceBuilder(
|
||||
userId: room.directChatMatrixID,
|
||||
builder: (context, presence) {
|
||||
final lastActiveTimestamp = presence?.lastActiveTimestamp;
|
||||
final style = Theme.of(context).textTheme.bodySmall;
|
||||
if (presence?.currentlyActive == true) {
|
||||
return Text(
|
||||
L10n.of(context).currentlyActive,
|
||||
style: style,
|
||||
);
|
||||
}
|
||||
if (lastActiveTimestamp != null) {
|
||||
return Text(
|
||||
L10n.of(context).lastActiveAgo(
|
||||
lastActiveTimestamp.localizedTimeShort(context),
|
||||
),
|
||||
style: style,
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
StreamBuilder(
|
||||
stream: room.client.onSyncStatus.stream,
|
||||
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;
|
||||
return AnimatedSize(
|
||||
duration: FluffyThemes.animationDuration,
|
||||
child: hide
|
||||
? PresenceBuilder(
|
||||
userId: room.directChatMatrixID,
|
||||
builder: (context, presence) {
|
||||
final lastActiveTimestamp =
|
||||
presence?.lastActiveTimestamp;
|
||||
final style =
|
||||
Theme.of(context).textTheme.bodySmall;
|
||||
if (presence?.currentlyActive == true) {
|
||||
return Text(
|
||||
L10n.of(context).currentlyActive,
|
||||
style: style,
|
||||
);
|
||||
}
|
||||
if (lastActiveTimestamp != null) {
|
||||
return Text(
|
||||
L10n.of(context).lastActiveAgo(
|
||||
lastActiveTimestamp
|
||||
.localizedTimeShort(context),
|
||||
),
|
||||
style: style,
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
)
|
||||
: 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),
|
||||
],
|
||||
Expanded(
|
||||
child: Text(
|
||||
status.calcLocalizedString(context),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: status.error != null
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.onErrorContainer
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import 'package:fluffychat/pages/chat/reply_display.dart';
|
|||
import 'package:fluffychat/utils/account_config.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:fluffychat/widgets/chat_settings_popup_menu.dart';
|
||||
import 'package:fluffychat/widgets/connection_status_header.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
|
|
@ -354,7 +353,6 @@ class ChatView extends StatelessWidget {
|
|||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const ConnectionStatusHeader(),
|
||||
ReactionsPicker(controller),
|
||||
ReplyDisplay(controller),
|
||||
ChatInputRow(controller),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue