User last seen

This commit is contained in:
LittleSheep 2024-06-27 11:04:06 +08:00
parent 42acffff3e
commit 4f5762c5a9
2 changed files with 15 additions and 3 deletions

View File

@ -225,6 +225,7 @@ class SolianMessages extends Translations {
'accountStatusInvisible': 'Invisible', 'accountStatusInvisible': 'Invisible',
'accountStatusInvisibleDesc': 'Will show as offline, but all features still remain normal', 'accountStatusInvisibleDesc': 'Will show as offline, but all features still remain normal',
'accountStatusOffline': 'Offline', 'accountStatusOffline': 'Offline',
'accountLastSeenAt': 'Last seen at @date ago',
}, },
'zh_CN': { 'zh_CN': {
'hide': '隐藏', 'hide': '隐藏',
@ -433,6 +434,7 @@ class SolianMessages extends Translations {
'accountStatusInvisible': '隐身', 'accountStatusInvisible': '隐身',
'accountStatusInvisibleDesc': '将会在他人界面显示离线,但不影响功能使用', 'accountStatusInvisibleDesc': '将会在他人界面显示离线,但不影响功能使用',
'accountStatusOffline': '离线', 'accountStatusOffline': '离线',
'accountLastSeenAt': '最后上线于 @date 前',
} }
}; };
} }

View File

@ -7,6 +7,7 @@ import 'package:solian/providers/account_status.dart';
import 'package:solian/widgets/account/account_avatar.dart'; import 'package:solian/widgets/account/account_avatar.dart';
import 'package:solian/widgets/account/account_badge.dart'; import 'package:solian/widgets/account/account_badge.dart';
import 'package:solian/widgets/account/account_status_action.dart'; import 'package:solian/widgets/account/account_status_action.dart';
import 'package:timeago/timeago.dart';
class AccountHeadingWidget extends StatelessWidget { class AccountHeadingWidget extends StatelessWidget {
final dynamic avatar; final dynamic avatar;
@ -39,7 +40,7 @@ class AccountHeadingWidget extends StatelessWidget {
context: context, context: context,
builder: (context) => AccountStatusAction(hasStatus: hasStatus), builder: (context) => AccountStatusAction(hasStatus: hasStatus),
).then((val) { ).then((val) {
if(val == true) onEditStatus!(); if (val == true) onEditStatus!();
}); });
} }
@ -106,15 +107,24 @@ class AccountHeadingWidget extends StatelessWidget {
return Text('loading'.tr); return Text('loading'.tr);
} }
final info = StatusProvider.determineStatus( final status = AccountStatus.fromJson(
AccountStatus.fromJson(snapshot.data!.body), snapshot.data!.body,
); );
final info = StatusProvider.determineStatus(status);
return GestureDetector( return GestureDetector(
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text(info.$2), Text(info.$2),
if (!status.isOnline && status.lastSeenAt != null)
Opacity(
opacity: 0.75,
child: Text('accountLastSeenAt'.trParams({
'date': format(status.lastSeenAt!.toLocal(),
locale: 'en_short')
})).paddingOnly(left: 4),
),
info.$1.paddingSymmetric(horizontal: 6), info.$1.paddingSymmetric(horizontal: 6),
], ],
), ),