🐛 Bug fixes on profile page

This commit is contained in:
LittleSheep 2024-09-08 01:48:01 +08:00
parent 0a04c72468
commit 1fd042bcae
5 changed files with 83 additions and 10 deletions

View File

@ -15,6 +15,7 @@ class Account {
dynamic avatar; dynamic avatar;
dynamic banner; dynamic banner;
String description; String description;
AccountProfile? profile;
List<AccountBadge>? badges; List<AccountBadge>? badges;
String? emailAddress; String? emailAddress;
int? externalId; int? externalId;
@ -31,6 +32,7 @@ class Account {
required this.avatar, required this.avatar,
required this.banner, required this.banner,
required this.description, required this.description,
required this.profile,
required this.badges, required this.badges,
required this.emailAddress, required this.emailAddress,
this.externalId, this.externalId,
@ -67,3 +69,35 @@ class AccountBadge {
Map<String, dynamic> toJson() => _$AccountBadgeToJson(this); Map<String, dynamic> toJson() => _$AccountBadgeToJson(this);
} }
@JsonSerializable()
class AccountProfile {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String? firstName;
String? lastName;
int? experience;
DateTime? lastSeenAt;
DateTime? birthday;
int accountId;
AccountProfile({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.firstName,
required this.lastName,
required this.experience,
required this.lastSeenAt,
required this.birthday,
required this.accountId,
});
factory AccountProfile.fromJson(Map<String, dynamic> json) =>
_$AccountProfileFromJson(json);
Map<String, dynamic> toJson() => _$AccountProfileToJson(this);
}

View File

@ -24,6 +24,9 @@ Account _$AccountFromJson(Map<String, dynamic> json) => Account(
avatar: json['avatar'], avatar: json['avatar'],
banner: json['banner'], banner: json['banner'],
description: json['description'] as String, description: json['description'] as String,
profile: json['profile'] == null
? null
: AccountProfile.fromJson(json['profile'] as Map<String, dynamic>),
badges: (json['badges'] as List<dynamic>?) badges: (json['badges'] as List<dynamic>?)
?.map((e) => AccountBadge.fromJson(e as Map<String, dynamic>)) ?.map((e) => AccountBadge.fromJson(e as Map<String, dynamic>))
.toList(), .toList(),
@ -43,6 +46,7 @@ Map<String, dynamic> _$AccountToJson(Account instance) => <String, dynamic>{
'avatar': instance.avatar, 'avatar': instance.avatar,
'banner': instance.banner, 'banner': instance.banner,
'description': instance.description, 'description': instance.description,
'profile': instance.profile?.toJson(),
'badges': instance.badges?.map((e) => e.toJson()).toList(), 'badges': instance.badges?.map((e) => e.toJson()).toList(),
'email_address': instance.emailAddress, 'email_address': instance.emailAddress,
'external_id': instance.externalId, 'external_id': instance.externalId,
@ -70,3 +74,37 @@ Map<String, dynamic> _$AccountBadgeToJson(AccountBadge instance) =>
'type': instance.type, 'type': instance.type,
'account_id': instance.accountId, 'account_id': instance.accountId,
}; };
AccountProfile _$AccountProfileFromJson(Map<String, dynamic> json) =>
AccountProfile(
id: (json['id'] as num).toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
deletedAt: json['deleted_at'] == null
? null
: DateTime.parse(json['deleted_at'] as String),
firstName: json['first_name'] as String?,
lastName: json['last_name'] as String?,
experience: (json['experience'] as num?)?.toInt(),
lastSeenAt: json['last_seen_at'] == null
? null
: DateTime.parse(json['last_seen_at'] as String),
birthday: json['birthday'] == null
? null
: DateTime.parse(json['birthday'] as String),
accountId: (json['account_id'] as num).toInt(),
);
Map<String, dynamic> _$AccountProfileToJson(AccountProfile instance) =>
<String, dynamic>{
'id': instance.id,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'deleted_at': instance.deletedAt?.toIso8601String(),
'first_name': instance.firstName,
'last_name': instance.lastName,
'experience': instance.experience,
'last_seen_at': instance.lastSeenAt?.toIso8601String(),
'birthday': instance.birthday?.toIso8601String(),
'account_id': instance.accountId,
};

View File

@ -84,10 +84,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
} }
int get _userSocialCreditPoints { int get _userSocialCreditPoints {
int birthPart = return _totalUpvote * 2 - _totalDownvote + _postController.postTotal.value;
DateTime.now().difference(_userinfo!.createdAt.toLocal()).inSeconds;
birthPart = birthPart >> 16;
return _totalUpvote * 2 - _totalDownvote + birthPart;
} }
@override @override
@ -97,8 +94,9 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
_postController = PostListController(author: widget.name); _postController = PostListController(author: widget.name);
_albumPagingController.addPageRequestListener((pageKey) async { _albumPagingController.addPageRequestListener((pageKey) async {
final client = ServiceFinder.configureClient('files'); final client = ServiceFinder.configureClient('files');
final resp = await client final resp = await client.get(
.get('/attachments?take=10&offset=$pageKey&author=${widget.name}'); '/attachments?take=10&offset=$pageKey&author=${widget.name}&original=true',
);
if (resp.statusCode == 200) { if (resp.statusCode == 200) {
final result = PaginationResult.fromJson(resp.body); final result = PaginationResult.fromJson(resp.body);
final out = result.data final out = result.data

View File

@ -23,6 +23,7 @@ import 'package:solian/providers/message/adaptor.dart';
import 'package:solian/providers/websocket.dart'; import 'package:solian/providers/websocket.dart';
import 'package:solian/router.dart'; import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart'; import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/chat/chat_event.dart'; import 'package:solian/widgets/chat/chat_event.dart';
import 'package:solian/widgets/daily_sign/history_chart.dart'; import 'package:solian/widgets/daily_sign/history_chart.dart';
import 'package:solian/widgets/posts/post_list.dart'; import 'package:solian/widgets/posts/post_list.dart';
@ -491,7 +492,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
/// Footer /// Footer
Column( Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: SolianTheme.isLargeScreen(context)
? MainAxisAlignment.start
: MainAxisAlignment.center,
children: [ children: [
Text( Text(
'Powered by Solar Network', 'Powered by Solar Network',

View File

@ -199,7 +199,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
radius: 19, radius: 19,
), ),
), ),
const IgnorePointer(child: Gap(8)), const Gap(8),
Expanded( Expanded(
child: IgnorePointer( child: IgnorePointer(
child: Column( child: Column(
@ -241,7 +241,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
), ),
], ],
), ),
const IgnorePointer(child: Gap(4)), const Gap(4),
IgnorePointer( IgnorePointer(
child: Text( child: Text(
widget.item.alt, widget.item.alt,
@ -253,7 +253,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> {
), ),
), ),
), ),
const IgnorePointer(child: Gap(2)), const Gap(2),
IgnorePointer( IgnorePointer(
child: Wrap( child: Wrap(
spacing: 6, spacing: 6,