chore: Follow up presences

pull/672/head
krille-chan 2 years ago
parent a41dd4c60f
commit bee90019bb
No known key found for this signature in database

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat/chat.dart'; import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/utils/date_time_extension.dart'; import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
@ -41,9 +42,10 @@ class ChatAppBarTitle extends StatelessWidget {
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Expanded( Expanded(
child: ListTile( child: Column(
contentPadding: EdgeInsets.zero, crossAxisAlignment: CrossAxisAlignment.start,
title: Text( children: [
Text(
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)), room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@ -51,24 +53,33 @@ class ChatAppBarTitle extends StatelessWidget {
fontSize: 16, fontSize: 16,
), ),
), ),
subtitle: PresenceBuilder( AnimatedSize(
duration: FluffyThemes.animationDuration,
child: PresenceBuilder(
userId: room.directChatMatrixID, userId: room.directChatMatrixID,
builder: (context, presence) { builder: (context, presence) {
final lastActiveTimestamp = presence?.lastActiveTimestamp; final lastActiveTimestamp = presence?.lastActiveTimestamp;
final style = Theme.of(context).textTheme.bodySmall;
if (presence?.currentlyActive == true) { if (presence?.currentlyActive == true) {
return Text(L10n.of(context)!.currentlyActive); return Text(
L10n.of(context)!.currentlyActive,
style: style,
);
} }
if (lastActiveTimestamp != null) { if (lastActiveTimestamp != null) {
return Text( return Text(
L10n.of(context)!.lastActiveAgo( L10n.of(context)!.lastActiveAgo(
lastActiveTimestamp.localizedTimeShort(context), lastActiveTimestamp.localizedTimeShort(context),
), ),
style: style,
); );
} }
return const SizedBox.shrink(); return const SizedBox.shrink();
}, },
), ),
), ),
],
),
), ),
], ],
), ),

@ -43,7 +43,6 @@ class SeenByRow extends StatelessWidget {
name: user.calcDisplayname(), name: user.calcDisplayname(),
size: 16, size: 16,
fontSize: 9, fontSize: 9,
presenceUserId: user.stateKey,
), ),
), ),
if (seenByUsers.length > maxAvatars) if (seenByUsers.length > maxAvatars)

@ -32,10 +32,11 @@ class UserBottomSheetView extends StatelessWidget {
leading: CloseButton( leading: CloseButton(
onPressed: Navigator.of(context, rootNavigator: false).pop, onPressed: Navigator.of(context, rootNavigator: false).pop,
), ),
title: ListTile( title: Column(
contentPadding: EdgeInsets.zero, crossAxisAlignment: CrossAxisAlignment.start,
title: Text(displayname.trim().split(' ').first), children: [
subtitle: PresenceBuilder( Text(displayname),
PresenceBuilder(
userId: userId, userId: userId,
client: client, client: client,
builder: (context, presence) { builder: (context, presence) {
@ -44,8 +45,8 @@ class UserBottomSheetView extends StatelessWidget {
final dotColor = presence.presence.isOnline final dotColor = presence.presence.isOnline
? Colors.green ? Colors.green
: presence.presence.isUnavailable : presence.presence.isUnavailable
? Colors.orange ? Colors.red
: Colors.red; : Colors.grey;
final lastActiveTimestamp = presence.lastActiveTimestamp; final lastActiveTimestamp = presence.lastActiveTimestamp;
@ -61,17 +62,22 @@ class UserBottomSheetView extends StatelessWidget {
), ),
), ),
if (presence.currentlyActive == true) if (presence.currentlyActive == true)
Text(L10n.of(context)!.currentlyActive), Text(
L10n.of(context)!.currentlyActive,
style: Theme.of(context).textTheme.bodySmall,
),
if (lastActiveTimestamp != null) if (lastActiveTimestamp != null)
Text( Text(
L10n.of(context)!.lastActiveAgo( L10n.of(context)!.lastActiveAgo(
lastActiveTimestamp.localizedTimeShort(context), lastActiveTimestamp.localizedTimeShort(context),
), ),
style: Theme.of(context).textTheme.bodySmall,
), ),
], ],
); );
}, },
), ),
],
), ),
actions: [ actions: [
if (userId != client.userID && if (userId != client.userID &&

@ -84,8 +84,8 @@ class Avatar extends StatelessWidget {
final dotColor = presence.presence.isOnline final dotColor = presence.presence.isOnline
? Colors.green ? Colors.green
: presence.presence.isUnavailable : presence.presence.isUnavailable
? Colors.orange ? Colors.red
: Colors.red; : Colors.grey;
return Positioned( return Positioned(
bottom: -4, bottom: -4,
right: -4, right: -4,

Loading…
Cancel
Save