User profile

This commit is contained in:
LittleSheep 2024-12-03 23:38:43 +08:00
parent 273c66f5d5
commit 468b7f2c2e
12 changed files with 520 additions and 203 deletions

View File

@ -358,5 +358,9 @@
"accountBirthday": "Born on {}",
"accountBadge": "Badge",
"badgeCompanyStaff": "Solsynth LLC Staff",
"badgeSiteMigration": "Solar Network Native"
"badgeSiteMigration": "Solar Network Native",
"accountStatus": "Status",
"accountStatusOnline": "Online",
"accountStatusOffline": "Offline",
"accountStatusLastSeen": "Last seen at {}"
}

View File

@ -358,5 +358,9 @@
"accountBirthday": "出生于 {}",
"accountBadge": "徽章",
"badgeCompanyStaff": "索尔辛茨士大夫 · Staff",
"badgeSiteMigration": "Solar Network 原住民"
"badgeSiteMigration": "Solar Network 原住民",
"accountStatus": "状态",
"accountStatusOnline": "在线",
"accountStatusOffline": "离线",
"accountStatusLastSeen": "最后一次在 {} 上线"
}

View File

@ -109,7 +109,7 @@ PODS:
- SAMKeychain
- flutter_webrtc (0.12.2):
- Flutter
- WebRTC-SDK (= 125.6422.05)
- WebRTC-SDK (= 125.6422.06)
- GoogleAppMeasurement (11.4.0):
- GoogleAppMeasurement/AdIdSupport (= 11.4.0)
- GoogleUtilities/AppDelegateSwizzler (~> 8.0)
@ -164,7 +164,7 @@ PODS:
- Flutter
- livekit_client (2.3.1):
- Flutter
- WebRTC-SDK (= 125.6422.05)
- WebRTC-SDK (= 125.6422.06)
- media_kit_libs_ios_video (1.0.4):
- Flutter
- media_kit_native_event_loop (1.0.0):
@ -210,7 +210,7 @@ PODS:
- Flutter
- wakelock_plus (0.0.1):
- Flutter
- WebRTC-SDK (125.6422.05)
- WebRTC-SDK (125.6422.06)
DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`)
@ -341,12 +341,12 @@ SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: e8a1e01082d97a8099d973f919f57904c925008a
flutter_udid: a2482c67a61b9c806ef59dd82ed8d007f1b7ac04
flutter_webrtc: 043d1b47e9795158dd97dc84f1c152cd0e98b93b
flutter_webrtc: 1a53bd24f97bcfeff512f13699e721897f261563
GoogleAppMeasurement: 987769c4ca6b968f2479fbcc9fe3ce34af454b8e
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
livekit_client: e5e1be9c3fedd51c63f3ec4b4d3c616e9744c92b
livekit_client: dbb906ef427fe96dde5854471c3dda0a50cc15f9
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
@ -367,7 +367,7 @@ SPEC CHECKSUMS:
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9
wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1
WebRTC-SDK: 1990a1a595bd0b59c17485ce13ff17f575732c12
WebRTC-SDK: 79942c006ea64f6fb48d7da8a4786dfc820bc1db
PODFILE CHECKSUM: d2bdaa1cc7915e14cf47235c34a21fcb07b00390

View File

@ -21,7 +21,7 @@ import 'package:surface/screens/home.dart';
import 'package:surface/screens/notification.dart';
import 'package:surface/screens/post/post_detail.dart';
import 'package:surface/screens/post/post_editor.dart';
import 'package:surface/screens/post/post_publisher.dart';
import 'package:surface/screens/post/publisher_page.dart';
import 'package:surface/screens/post/post_search.dart';
import 'package:surface/screens/realm.dart';
import 'package:surface/screens/realm/manage.dart';

View File

@ -13,14 +13,16 @@ import 'package:surface/widgets/account/account_image.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/universal_image.dart';
const Map<String, (String, IconData)> kBadgesMeta = {
const Map<String, (String, IconData, Color)> kBadgesMeta = {
'company.staff': (
'badgeCompanyStaff',
Symbols.tools_wrench,
Colors.teal,
),
'site.migration': (
'badgeSiteMigration',
Symbols.flag,
Colors.orange,
),
};
@ -54,6 +56,22 @@ class _UserScreenState extends State<UserScreen>
}
}
SnAccountStatusInfo? _status;
Future<void> _fetchStatus() async {
try {
final sn = context.read<SnNetworkProvider>();
final resp = await sn.client.get('/cgi/id/users/${widget.name}/status');
if (!mounted) return;
_status = SnAccountStatusInfo.fromJson(resp.data);
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
} finally {
setState(() {});
}
}
double _appBarBlur = 0.0;
late final _appBarWidth = MediaQuery.of(context).size.width;
@ -71,7 +89,9 @@ class _UserScreenState extends State<UserScreen>
@override
void initState() {
super.initState();
_fetchAccount().then((_) {});
_fetchAccount().then((_) {
_fetchStatus();
});
_scrollController.addListener(_updateAppBarBlur);
}
@ -99,10 +119,9 @@ class _UserScreenState extends State<UserScreen>
final sn = context.read<SnNetworkProvider>();
return Scaffold(
body: NestedScrollView(
body: CustomScrollView(
controller: _scrollController,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
slivers: [
SliverAppBar(
expandedHeight: _appBarHeight,
title: _account == null
@ -112,8 +131,7 @@ class _UserScreenState extends State<UserScreen>
text: TextSpan(children: [
TextSpan(
text: _account!.nick,
style:
Theme.of(context).textTheme.titleLarge!.copyWith(
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: Colors.white,
shadows: labelShadows,
),
@ -121,8 +139,7 @@ class _UserScreenState extends State<UserScreen>
const TextSpan(text: '\n'),
TextSpan(
text: '@${_account!.name}',
style:
Theme.of(context).textTheme.bodySmall!.copyWith(
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Colors.white,
shadows: labelShadows,
),
@ -165,12 +182,9 @@ class _UserScreenState extends State<UserScreen>
)
: null,
),
];
},
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
if (_account != null)
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
@ -196,7 +210,30 @@ class _UserScreenState extends State<UserScreen>
).padding(right: 8),
const Gap(12),
Text(_account!.description).padding(horizontal: 8),
const Gap(12),
const Gap(4),
Card(
child: Row(
children: [
Icon(
Symbols.circle,
fill: 1,
size: 16,
color: (_status?.isOnline ?? false)
? Colors.green
: Colors.grey,
).padding(all: 4),
const Gap(8),
Text(
_status != null
? _status!.isOnline
? 'accountStatusOnline'.tr()
: 'accountStatusOffline'.tr()
: 'loading'.tr(),
),
],
).padding(vertical: 8, horizontal: 12),
),
const Gap(8),
Column(
children: [
Row(
@ -215,8 +252,9 @@ class _UserScreenState extends State<UserScreen>
Text('accountBirthday').tr(args: [
_account!.profile?.birthday == null
? 'unknown'.tr()
: DateFormat('M/d')
.format(_account!.profile!.birthday!)
: DateFormat('M/d').format(
_account!.profile!.birthday!.toLocal(),
)
]),
],
),
@ -234,15 +272,20 @@ class _UserScreenState extends State<UserScreen>
).padding(horizontal: 8),
],
).padding(all: 16),
const Divider(),
const Gap(12),
),
SliverToBoxAdapter(child: const Divider()),
const SliverGap(12),
SliverToBoxAdapter(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('accountBadge')
.bold()
.fontSize(17)
.tr()
.padding(horizontal: 20, bottom: 4),
SizedBox(
height: 64,
height: 80,
width: double.infinity,
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 8),
@ -256,19 +299,29 @@ class _UserScreenState extends State<UserScreen>
leading: Icon(
kBadgesMeta[badge.type]?.$2 ??
Symbols.question_mark,
color: kBadgesMeta[badge.type]?.$3,
fill: 1,
),
title: Text(
kBadgesMeta[badge.type]?.$1 ?? 'unknown',
).tr(),
subtitle: badge.metadata['title'] != null
? Text(badge.metadata['title'])
: Text(
DateFormat('y/M/d')
.format(badge.createdAt),
),
),
),
),
],
),
),
],
),
)
],
),
),
);
}
}

View File

@ -404,13 +404,16 @@ class _PostPublisherScreenState extends State<PostPublisherScreen>
],
),
SliverToBoxAdapter(child: const Divider(height: 1)),
Gap(math.max(MediaQuery.of(context).padding.top, 50)),
],
),
),
];
},
body: TabBarView(
body: Column(
children: [
Gap(math.max(MediaQuery.of(context).padding.top, 64)),
Expanded(
child: TabBarView(
controller: _tabController,
children: List.filled(
3,
@ -430,6 +433,9 @@ class _PostPublisherScreenState extends State<PostPublisherScreen>
),
),
),
],
),
),
);
}
}

View File

@ -106,3 +106,16 @@ class SnAccountBadge with _$SnAccountBadge {
factory SnAccountBadge.fromJson(Map<String, Object?> json) =>
_$SnAccountBadgeFromJson(json);
}
@freezed
class SnAccountStatusInfo with _$SnAccountStatusInfo {
const factory SnAccountStatusInfo({
required bool isDisturbable,
required bool isOnline,
required DateTime? lastSeenAt,
required dynamic status,
}) = _SnAccountStatusInfo;
factory SnAccountStatusInfo.fromJson(Map<String, Object?> json) =>
_$SnAccountStatusInfoFromJson(json);
}

View File

@ -1987,3 +1987,221 @@ abstract class _SnAccountBadge implements SnAccountBadge {
_$$SnAccountBadgeImplCopyWith<_$SnAccountBadgeImpl> get copyWith =>
throw _privateConstructorUsedError;
}
SnAccountStatusInfo _$SnAccountStatusInfoFromJson(Map<String, dynamic> json) {
return _SnAccountStatusInfo.fromJson(json);
}
/// @nodoc
mixin _$SnAccountStatusInfo {
bool get isDisturbable => throw _privateConstructorUsedError;
bool get isOnline => throw _privateConstructorUsedError;
DateTime? get lastSeenAt => throw _privateConstructorUsedError;
dynamic get status => throw _privateConstructorUsedError;
/// Serializes this SnAccountStatusInfo to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of SnAccountStatusInfo
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SnAccountStatusInfoCopyWith<SnAccountStatusInfo> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SnAccountStatusInfoCopyWith<$Res> {
factory $SnAccountStatusInfoCopyWith(
SnAccountStatusInfo value, $Res Function(SnAccountStatusInfo) then) =
_$SnAccountStatusInfoCopyWithImpl<$Res, SnAccountStatusInfo>;
@useResult
$Res call(
{bool isDisturbable,
bool isOnline,
DateTime? lastSeenAt,
dynamic status});
}
/// @nodoc
class _$SnAccountStatusInfoCopyWithImpl<$Res, $Val extends SnAccountStatusInfo>
implements $SnAccountStatusInfoCopyWith<$Res> {
_$SnAccountStatusInfoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SnAccountStatusInfo
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isDisturbable = null,
Object? isOnline = null,
Object? lastSeenAt = freezed,
Object? status = freezed,
}) {
return _then(_value.copyWith(
isDisturbable: null == isDisturbable
? _value.isDisturbable
: isDisturbable // ignore: cast_nullable_to_non_nullable
as bool,
isOnline: null == isOnline
? _value.isOnline
: isOnline // ignore: cast_nullable_to_non_nullable
as bool,
lastSeenAt: freezed == lastSeenAt
? _value.lastSeenAt
: lastSeenAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as dynamic,
) as $Val);
}
}
/// @nodoc
abstract class _$$SnAccountStatusInfoImplCopyWith<$Res>
implements $SnAccountStatusInfoCopyWith<$Res> {
factory _$$SnAccountStatusInfoImplCopyWith(_$SnAccountStatusInfoImpl value,
$Res Function(_$SnAccountStatusInfoImpl) then) =
__$$SnAccountStatusInfoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{bool isDisturbable,
bool isOnline,
DateTime? lastSeenAt,
dynamic status});
}
/// @nodoc
class __$$SnAccountStatusInfoImplCopyWithImpl<$Res>
extends _$SnAccountStatusInfoCopyWithImpl<$Res, _$SnAccountStatusInfoImpl>
implements _$$SnAccountStatusInfoImplCopyWith<$Res> {
__$$SnAccountStatusInfoImplCopyWithImpl(_$SnAccountStatusInfoImpl _value,
$Res Function(_$SnAccountStatusInfoImpl) _then)
: super(_value, _then);
/// Create a copy of SnAccountStatusInfo
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isDisturbable = null,
Object? isOnline = null,
Object? lastSeenAt = freezed,
Object? status = freezed,
}) {
return _then(_$SnAccountStatusInfoImpl(
isDisturbable: null == isDisturbable
? _value.isDisturbable
: isDisturbable // ignore: cast_nullable_to_non_nullable
as bool,
isOnline: null == isOnline
? _value.isOnline
: isOnline // ignore: cast_nullable_to_non_nullable
as bool,
lastSeenAt: freezed == lastSeenAt
? _value.lastSeenAt
: lastSeenAt // ignore: cast_nullable_to_non_nullable
as DateTime?,
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as dynamic,
));
}
}
/// @nodoc
@JsonSerializable()
class _$SnAccountStatusInfoImpl implements _SnAccountStatusInfo {
const _$SnAccountStatusInfoImpl(
{required this.isDisturbable,
required this.isOnline,
required this.lastSeenAt,
required this.status});
factory _$SnAccountStatusInfoImpl.fromJson(Map<String, dynamic> json) =>
_$$SnAccountStatusInfoImplFromJson(json);
@override
final bool isDisturbable;
@override
final bool isOnline;
@override
final DateTime? lastSeenAt;
@override
final dynamic status;
@override
String toString() {
return 'SnAccountStatusInfo(isDisturbable: $isDisturbable, isOnline: $isOnline, lastSeenAt: $lastSeenAt, status: $status)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SnAccountStatusInfoImpl &&
(identical(other.isDisturbable, isDisturbable) ||
other.isDisturbable == isDisturbable) &&
(identical(other.isOnline, isOnline) ||
other.isOnline == isOnline) &&
(identical(other.lastSeenAt, lastSeenAt) ||
other.lastSeenAt == lastSeenAt) &&
const DeepCollectionEquality().equals(other.status, status));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, isDisturbable, isOnline,
lastSeenAt, const DeepCollectionEquality().hash(status));
/// Create a copy of SnAccountStatusInfo
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SnAccountStatusInfoImplCopyWith<_$SnAccountStatusInfoImpl> get copyWith =>
__$$SnAccountStatusInfoImplCopyWithImpl<_$SnAccountStatusInfoImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$SnAccountStatusInfoImplToJson(
this,
);
}
}
abstract class _SnAccountStatusInfo implements SnAccountStatusInfo {
const factory _SnAccountStatusInfo(
{required final bool isDisturbable,
required final bool isOnline,
required final DateTime? lastSeenAt,
required final dynamic status}) = _$SnAccountStatusInfoImpl;
factory _SnAccountStatusInfo.fromJson(Map<String, dynamic> json) =
_$SnAccountStatusInfoImpl.fromJson;
@override
bool get isDisturbable;
@override
bool get isOnline;
@override
DateTime? get lastSeenAt;
@override
dynamic get status;
/// Create a copy of SnAccountStatusInfo
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SnAccountStatusInfoImplCopyWith<_$SnAccountStatusInfoImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -192,3 +192,23 @@ Map<String, dynamic> _$$SnAccountBadgeImplToJson(
'account_id': instance.accountId,
'metadata': instance.metadata,
};
_$SnAccountStatusInfoImpl _$$SnAccountStatusInfoImplFromJson(
Map<String, dynamic> json) =>
_$SnAccountStatusInfoImpl(
isDisturbable: json['is_disturbable'] as bool,
isOnline: json['is_online'] as bool,
lastSeenAt: json['last_seen_at'] == null
? null
: DateTime.parse(json['last_seen_at'] as String),
status: json['status'],
);
Map<String, dynamic> _$$SnAccountStatusInfoImplToJson(
_$SnAccountStatusInfoImpl instance) =>
<String, dynamic>{
'is_disturbable': instance.isDisturbable,
'is_online': instance.isOnline,
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
'status': instance.status,
};

View File

@ -75,7 +75,7 @@ PODS:
- SAMKeychain
- flutter_webrtc (0.12.2):
- FlutterMacOS
- WebRTC-SDK (= 125.6422.05)
- WebRTC-SDK (= 125.6422.06)
- FlutterMacOS (1.0.0)
- GoogleAppMeasurement (11.4.0):
- GoogleAppMeasurement/AdIdSupport (= 11.4.0)
@ -129,7 +129,7 @@ PODS:
- GoogleUtilities/Privacy
- livekit_client (2.3.1):
- FlutterMacOS
- WebRTC-SDK (= 125.6422.05)
- WebRTC-SDK (= 125.6422.06)
- media_kit_libs_macos_video (1.0.4):
- FlutterMacOS
- media_kit_native_event_loop (1.0.0):
@ -167,7 +167,7 @@ PODS:
- FlutterMacOS
- wakelock_plus (0.0.1):
- FlutterMacOS
- WebRTC-SDK (125.6422.05)
- WebRTC-SDK (125.6422.06)
DEPENDENCIES:
- connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/darwin`)
@ -278,12 +278,12 @@ SPEC CHECKSUMS:
FirebaseInstallations: 6ef4a1c7eb2a61ee1f74727d7f6ce2e72acf1414
FirebaseMessaging: f8a160d99c2c2e5babbbcc90c4a3e15db036aee2
flutter_udid: 6b2b89780c3dfeecf0047bdf93f622d6416b1c07
flutter_webrtc: 646bc8ab7ba7e45aae7279a371177e414cd5a326
flutter_webrtc: 53c9e1285ab32dfb58afb1e1471416a877e23d7a
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
GoogleAppMeasurement: 987769c4ca6b968f2479fbcc9fe3ce34af454b8e
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
livekit_client: 6ff0eb9b53ca4fbe0deb7e4b875f4ae9167702d2
livekit_client: 8838dc52cb95b452968efb84e87cad895c261d9d
media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82
media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5
media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5
@ -300,7 +300,7 @@ SPEC CHECKSUMS:
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
WebRTC-SDK: 1990a1a595bd0b59c17485ce13ff17f575732c12
WebRTC-SDK: 79942c006ea64f6fb48d7da8a4786dfc820bc1db
PODFILE CHECKSUM: c2e95c8c0fe03c5c57e438583cae4cc732296009

View File

@ -667,13 +667,13 @@ packages:
source: sdk
version: "0.0.0"
flutter_webrtc:
dependency: "direct main"
dependency: transitive
description:
name: flutter_webrtc
sha256: fcaee6f28cc1221e804fcba16fbee6f20b0848af20fe11174a0f97c3b9833381
sha256: "4838217405c42cce422698eacc9c2e17089b9c05322be899c0a725107dcddbdc"
url: "https://pub.dev"
source: hosted
version: "0.12.2"
version: "0.12.3"
freezed:
dependency: "direct dev"
description:
@ -974,10 +974,10 @@ packages:
dependency: "direct main"
description:
name: livekit_client
sha256: "442c228f42a3b757e1a5e526b0816f2b0a93b34625ff29b2c9fb9503ce4e4f3e"
sha256: e1e2524c8b0c9280ab852b5239b9ad00f10f50c82c5f6cc674df3583b6d3408b
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.1+hotfix.1"
logging:
dependency: transitive
description:
@ -1486,10 +1486,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_android
sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab"
sha256: "7f172d1b06de5da47b6264c2692ee2ead20bbbc246690427cdb4fc301cd0c549"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
version: "2.3.4"
shared_preferences_foundation:
dependency: transitive
description:

View File

@ -88,8 +88,7 @@ dependencies:
pasteboard: ^0.3.0
sentry_flutter: ^8.10.1
synchronized: ^3.3.0+3
livekit_client: ^2.3.0
flutter_webrtc: 0.12.2 # TODO: Remove this once livekit solved its dependency issue, https://github.com/livekit/client-sdk-flutter/issues/648
livekit_client: ^2.3.1+hotfix.1
wakelock_plus: ^1.2.8
permission_handler: ^11.3.1
flutter_staggered_grid_view: ^0.7.0