🐛 Bug fixes on profile page
This commit is contained in:
		| @@ -15,6 +15,7 @@ class Account { | ||||
|   dynamic avatar; | ||||
|   dynamic banner; | ||||
|   String description; | ||||
|   AccountProfile? profile; | ||||
|   List<AccountBadge>? badges; | ||||
|   String? emailAddress; | ||||
|   int? externalId; | ||||
| @@ -31,6 +32,7 @@ class Account { | ||||
|     required this.avatar, | ||||
|     required this.banner, | ||||
|     required this.description, | ||||
|     required this.profile, | ||||
|     required this.badges, | ||||
|     required this.emailAddress, | ||||
|     this.externalId, | ||||
| @@ -67,3 +69,35 @@ class AccountBadge { | ||||
|  | ||||
|   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); | ||||
| } | ||||
|   | ||||
| @@ -24,6 +24,9 @@ Account _$AccountFromJson(Map<String, dynamic> json) => Account( | ||||
|       avatar: json['avatar'], | ||||
|       banner: json['banner'], | ||||
|       description: json['description'] as String, | ||||
|       profile: json['profile'] == null | ||||
|           ? null | ||||
|           : AccountProfile.fromJson(json['profile'] as Map<String, dynamic>), | ||||
|       badges: (json['badges'] as List<dynamic>?) | ||||
|           ?.map((e) => AccountBadge.fromJson(e as Map<String, dynamic>)) | ||||
|           .toList(), | ||||
| @@ -43,6 +46,7 @@ Map<String, dynamic> _$AccountToJson(Account instance) => <String, dynamic>{ | ||||
|       'avatar': instance.avatar, | ||||
|       'banner': instance.banner, | ||||
|       'description': instance.description, | ||||
|       'profile': instance.profile?.toJson(), | ||||
|       'badges': instance.badges?.map((e) => e.toJson()).toList(), | ||||
|       'email_address': instance.emailAddress, | ||||
|       'external_id': instance.externalId, | ||||
| @@ -70,3 +74,37 @@ Map<String, dynamic> _$AccountBadgeToJson(AccountBadge instance) => | ||||
|       'type': instance.type, | ||||
|       '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, | ||||
|     }; | ||||
|   | ||||
| @@ -84,10 +84,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> { | ||||
|   } | ||||
|  | ||||
|   int get _userSocialCreditPoints { | ||||
|     int birthPart = | ||||
|         DateTime.now().difference(_userinfo!.createdAt.toLocal()).inSeconds; | ||||
|     birthPart = birthPart >> 16; | ||||
|     return _totalUpvote * 2 - _totalDownvote + birthPart; | ||||
|     return _totalUpvote * 2 - _totalDownvote + _postController.postTotal.value; | ||||
|   } | ||||
|  | ||||
|   @override | ||||
| @@ -97,8 +94,9 @@ class _AccountProfilePageState extends State<AccountProfilePage> { | ||||
|     _postController = PostListController(author: widget.name); | ||||
|     _albumPagingController.addPageRequestListener((pageKey) async { | ||||
|       final client = ServiceFinder.configureClient('files'); | ||||
|       final resp = await client | ||||
|           .get('/attachments?take=10&offset=$pageKey&author=${widget.name}'); | ||||
|       final resp = await client.get( | ||||
|         '/attachments?take=10&offset=$pageKey&author=${widget.name}&original=true', | ||||
|       ); | ||||
|       if (resp.statusCode == 200) { | ||||
|         final result = PaginationResult.fromJson(resp.body); | ||||
|         final out = result.data | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import 'package:solian/providers/message/adaptor.dart'; | ||||
| import 'package:solian/providers/websocket.dart'; | ||||
| import 'package:solian/router.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/daily_sign/history_chart.dart'; | ||||
| import 'package:solian/widgets/posts/post_list.dart'; | ||||
| @@ -491,7 +492,9 @@ class _DashboardScreenState extends State<DashboardScreen> { | ||||
|  | ||||
|           /// Footer | ||||
|           Column( | ||||
|             mainAxisAlignment: MainAxisAlignment.center, | ||||
|             mainAxisAlignment: SolianTheme.isLargeScreen(context) | ||||
|                 ? MainAxisAlignment.start | ||||
|                 : MainAxisAlignment.center, | ||||
|             children: [ | ||||
|               Text( | ||||
|                 'Powered by Solar Network', | ||||
|   | ||||
| @@ -199,7 +199,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> { | ||||
|                               radius: 19, | ||||
|                             ), | ||||
|                           ), | ||||
|                           const IgnorePointer(child: Gap(8)), | ||||
|                           const Gap(8), | ||||
|                           Expanded( | ||||
|                             child: IgnorePointer( | ||||
|                               child: Column( | ||||
| @@ -241,7 +241,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> { | ||||
|                           ), | ||||
|                         ], | ||||
|                       ), | ||||
|                     const IgnorePointer(child: Gap(4)), | ||||
|                     const Gap(4), | ||||
|                     IgnorePointer( | ||||
|                       child: Text( | ||||
|                         widget.item.alt, | ||||
| @@ -253,7 +253,7 @@ class _AttachmentFullScreenState extends State<AttachmentFullScreen> { | ||||
|                         ), | ||||
|                       ), | ||||
|                     ), | ||||
|                     const IgnorePointer(child: Gap(2)), | ||||
|                     const Gap(2), | ||||
|                     IgnorePointer( | ||||
|                       child: Wrap( | ||||
|                         spacing: 6, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user