💄 Use bottom modal sheet instead of popover
✨ Show strike on user profile page
			
			
This commit is contained in:
		| @@ -15,6 +15,7 @@ import 'package:surface/providers/experience.dart'; | ||||
| import 'package:surface/providers/relationship.dart'; | ||||
| import 'package:surface/providers/sn_network.dart'; | ||||
| import 'package:surface/screens/abuse_report.dart'; | ||||
| import 'package:surface/screens/account/punishments.dart'; | ||||
| import 'package:surface/types/account.dart'; | ||||
| import 'package:surface/types/check_in.dart'; | ||||
| import 'package:surface/types/post.dart'; | ||||
| @@ -457,7 +458,7 @@ class _UserScreenState extends State<UserScreen> | ||||
|                     ], | ||||
|                   ).padding(right: 8), | ||||
|                   if (_account!.profile!.description.isNotEmpty) | ||||
|                     const Gap(12) | ||||
|                     const Gap(4) | ||||
|                   else | ||||
|                     const Gap(8), | ||||
|                   if (_account!.profile!.description.isNotEmpty) | ||||
| @@ -503,14 +504,15 @@ class _UserScreenState extends State<UserScreen> | ||||
|                       ], | ||||
|                     ).padding(vertical: 8, horizontal: 12), | ||||
|                   ), | ||||
|                   const Gap(8), | ||||
|                   Wrap( | ||||
|                     spacing: 4, | ||||
|                     runSpacing: 4, | ||||
|                     children: _account!.badges | ||||
|                         .map((ele) => AccountBadge(badge: ele)) | ||||
|                         .toList(), | ||||
|                   ).padding(horizontal: 8), | ||||
|                   if (_account!.badges.isNotEmpty) const Gap(8), | ||||
|                   if (_account!.badges.isNotEmpty) | ||||
|                     Wrap( | ||||
|                       spacing: 4, | ||||
|                       runSpacing: 4, | ||||
|                       children: _account!.badges | ||||
|                           .map((ele) => AccountBadge(badge: ele)) | ||||
|                           .toList(), | ||||
|                     ).padding(horizontal: 8), | ||||
|                   const Gap(8), | ||||
|                   Column( | ||||
|                     children: [ | ||||
| @@ -619,6 +621,17 @@ class _UserScreenState extends State<UserScreen> | ||||
|                 ], | ||||
|               ).padding(all: 16), | ||||
|             ), | ||||
|           if (_account?.punishments.isNotEmpty ?? false) | ||||
|             SliverToBoxAdapter(child: const Divider()), | ||||
|           if (_account?.punishments.isNotEmpty ?? false) | ||||
|             SliverToBoxAdapter( | ||||
|               child: Column( | ||||
|                 children: [ | ||||
|                   for (final ele in _account!.punishments) | ||||
|                     PunishmentInfoCard(ele: ele), | ||||
|                 ], | ||||
|               ), | ||||
|             ), | ||||
|           if (_account?.profile?.links.isNotEmpty ?? false) | ||||
|             SliverToBoxAdapter(child: const Divider()), | ||||
|           if (_account?.profile?.links.isNotEmpty ?? false) | ||||
|   | ||||
| @@ -107,74 +107,7 @@ class _PunishmentsScreenState extends State<PunishmentsScreen> { | ||||
|                 itemCount: _punishments?.length ?? 0, | ||||
|                 itemBuilder: (context, index) { | ||||
|                   final ele = _punishments![index]; | ||||
|                   return Card( | ||||
|                     margin: EdgeInsets.symmetric(horizontal: 8), | ||||
|                     child: Column( | ||||
|                       crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                       children: [ | ||||
|                         Row( | ||||
|                           children: [ | ||||
|                             Icon(kPunishmentIcons[ele.type], size: 20), | ||||
|                             const Gap(6), | ||||
|                             Expanded( | ||||
|                               child: Text('punishmentType${ele.type}') | ||||
|                                   .tr() | ||||
|                                   .fontSize(16) | ||||
|                                   .bold(), | ||||
|                             ), | ||||
|                           ], | ||||
|                         ), | ||||
|                         Text(ele.reason), | ||||
|                         const Gap(4), | ||||
|                         Text( | ||||
|                           'punishmentCreatedAt'.tr(args: [ | ||||
|                             DateFormat().format( | ||||
|                               ele.createdAt.toLocal(), | ||||
|                             ) | ||||
|                           ]), | ||||
|                         ).opacity(0.8), | ||||
|                         Text( | ||||
|                           ele.expiredAt == null | ||||
|                               ? 'punishmentExpiredNever'.tr() | ||||
|                               : 'punishmentExpiredAt'.tr(args: [ | ||||
|                                   DateFormat().format( | ||||
|                                     ele.expiredAt!.toLocal(), | ||||
|                                   ) | ||||
|                                 ]), | ||||
|                         ).opacity(0.8), | ||||
|                         const Gap(8), | ||||
|                         if (ele.moderator != null) | ||||
|                           Column( | ||||
|                             crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                             children: [ | ||||
|                               Text('punishmentModerator').tr().opacity(0.75), | ||||
|                               InkWell( | ||||
|                                 child: Row( | ||||
|                                   children: [ | ||||
|                                     AccountImage( | ||||
|                                       content: ele.moderator!.avatar, | ||||
|                                       radius: 8, | ||||
|                                     ), | ||||
|                                     const Gap(4), | ||||
|                                     Text(ele.moderator?.nick ?? 'unknown'), | ||||
|                                   ], | ||||
|                                 ), | ||||
|                                 onTap: () { | ||||
|                                   GoRouter.of(context).pushNamed( | ||||
|                                     'accountProfilePage', | ||||
|                                     pathParameters: { | ||||
|                                       'name': ele.moderator!.name, | ||||
|                                     }, | ||||
|                                   ); | ||||
|                                 }, | ||||
|                               ), | ||||
|                             ], | ||||
|                           ) | ||||
|                         else | ||||
|                           Text('punishmentMadeBySystem').tr().opacity(0.75), | ||||
|                       ], | ||||
|                     ).padding(horizontal: 24, vertical: 16), | ||||
|                   ); | ||||
|                   return PunishmentInfoCard(ele: ele); | ||||
|                 }, | ||||
|                 separatorBuilder: (_, __) => const Gap(8), | ||||
|               ), | ||||
| @@ -185,3 +118,82 @@ class _PunishmentsScreenState extends State<PunishmentsScreen> { | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
| class PunishmentInfoCard extends StatelessWidget { | ||||
|   const PunishmentInfoCard({ | ||||
|     super.key, | ||||
|     required this.ele, | ||||
|   }); | ||||
|  | ||||
|   final SnPunishment ele; | ||||
|  | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     return Card( | ||||
|       margin: EdgeInsets.symmetric(horizontal: 8), | ||||
|       child: Column( | ||||
|         crossAxisAlignment: CrossAxisAlignment.start, | ||||
|         children: [ | ||||
|           Row( | ||||
|             children: [ | ||||
|               Icon(kPunishmentIcons[ele.type], size: 20), | ||||
|               const Gap(6), | ||||
|               Expanded( | ||||
|                 child: | ||||
|                     Text('punishmentType${ele.type}').tr().fontSize(16).bold(), | ||||
|               ), | ||||
|             ], | ||||
|           ), | ||||
|           Text(ele.reason), | ||||
|           const Gap(4), | ||||
|           Text( | ||||
|             'punishmentCreatedAt'.tr(args: [ | ||||
|               DateFormat().format( | ||||
|                 ele.createdAt.toLocal(), | ||||
|               ) | ||||
|             ]), | ||||
|           ).opacity(0.8), | ||||
|           Text( | ||||
|             ele.expiredAt == null | ||||
|                 ? 'punishmentExpiredNever'.tr() | ||||
|                 : 'punishmentExpiredAt'.tr(args: [ | ||||
|                     DateFormat().format( | ||||
|                       ele.expiredAt!.toLocal(), | ||||
|                     ) | ||||
|                   ]), | ||||
|           ).opacity(0.8), | ||||
|           const Gap(8), | ||||
|           if (ele.moderator != null) | ||||
|             Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|               children: [ | ||||
|                 Text('punishmentModerator').tr().opacity(0.75), | ||||
|                 InkWell( | ||||
|                   child: Row( | ||||
|                     children: [ | ||||
|                       AccountImage( | ||||
|                         content: ele.moderator!.avatar, | ||||
|                         radius: 8, | ||||
|                       ), | ||||
|                       const Gap(4), | ||||
|                       Text(ele.moderator?.nick ?? 'unknown'), | ||||
|                     ], | ||||
|                   ), | ||||
|                   onTap: () { | ||||
|                     GoRouter.of(context).pushNamed( | ||||
|                       'accountProfilePage', | ||||
|                       pathParameters: { | ||||
|                         'name': ele.moderator!.name, | ||||
|                       }, | ||||
|                     ); | ||||
|                   }, | ||||
|                 ), | ||||
|               ], | ||||
|             ) | ||||
|           else | ||||
|             Text('punishmentMadeBySystem').tr().opacity(0.75), | ||||
|         ], | ||||
|       ).padding(horizontal: 24, vertical: 16), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user