From 6311322c4aba4cd967271003db072b950fce9e84 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 13 Jul 2024 19:09:04 +0800 Subject: [PATCH] :sparkles: Suspended account tip --- lib/models/account.dart | 18 ++++++++++++++++-- lib/translations/en_us.dart | 2 ++ lib/translations/zh_cn.dart | 2 ++ lib/widgets/account/account_heading.dart | 16 ++++++++++++++++ lib/widgets/account/account_profile_popup.dart | 1 + 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/models/account.dart b/lib/models/account.dart index 36f607b..e28c9a6 100644 --- a/lib/models/account.dart +++ b/lib/models/account.dart @@ -3,6 +3,8 @@ class Account { DateTime createdAt; DateTime updatedAt; DateTime? deletedAt; + DateTime? confirmedAt; + DateTime? suspendedAt; String name; String nick; dynamic avatar; @@ -17,6 +19,8 @@ class Account { required this.createdAt, required this.updatedAt, required this.deletedAt, + required this.confirmedAt, + required this.suspendedAt, required this.name, required this.nick, required this.avatar, @@ -31,7 +35,15 @@ class Account { id: json['id'], createdAt: DateTime.parse(json['created_at']), updatedAt: DateTime.parse(json['updated_at']), - deletedAt: json['deleted_at'], + deletedAt: json['deleted_at'] != null + ? DateTime.parse(json['deleted_at']) + : null, + confirmedAt: json['confirmed_at'] != null + ? DateTime.parse(json['confirmed_at']) + : null, + suspendedAt: json['suspended_at'] != null + ? DateTime.parse(json['suspended_at']) + : null, name: json['name'], nick: json['nick'], avatar: json['avatar'], @@ -49,7 +61,9 @@ class Account { 'id': id, 'created_at': createdAt.toIso8601String(), 'updated_at': updatedAt.toIso8601String(), - 'deleted_at': deletedAt, + 'deleted_at': deletedAt?.toIso8601String(), + 'confirmed_at': confirmedAt?.toIso8601String(), + 'suspended_at': suspendedAt?.toIso8601String(), 'name': name, 'nick': nick, 'avatar': avatar, diff --git a/lib/translations/en_us.dart b/lib/translations/en_us.dart index 6df4afa..711bdf4 100644 --- a/lib/translations/en_us.dart +++ b/lib/translations/en_us.dart @@ -50,6 +50,8 @@ const messagesEnglish = { 'accountFriendPending': 'Friend requests', 'accountFriendBlocked': 'Friend blocklist', 'accountFriendListHint': 'Swipe left to decline, right to approve', + 'accountSuspended': 'Account was suspended', + 'accountSuspendedAt': 'Account was suspended since @date', 'aspectRatio': 'Aspect Ratio', 'aspectRatioSquare': 'Square', 'aspectRatioPortrait': 'Portrait', diff --git a/lib/translations/zh_cn.dart b/lib/translations/zh_cn.dart index 65b72d7..013f3e4 100644 --- a/lib/translations/zh_cn.dart +++ b/lib/translations/zh_cn.dart @@ -49,6 +49,8 @@ const simplifiedChineseMessages = { 'accountFriendPending': '好友请求', 'accountFriendBlocked': '好友黑名单', 'accountFriendListHint': '左滑来拒绝,右滑来接受', + 'accountSuspended': '帐号被停用', + 'accountSuspendedAt': '该帐号自 @date 起被停用', 'aspectRatio': '纵横比', 'aspectRatioSquare': '方型', 'aspectRatioPortrait': '竖型', diff --git a/lib/widgets/account/account_heading.dart b/lib/widgets/account/account_heading.dart index 4b70d1b..d2dac85 100644 --- a/lib/widgets/account/account_heading.dart +++ b/lib/widgets/account/account_heading.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:intl/intl.dart'; import 'package:solian/models/account.dart'; import 'package:solian/models/account_status.dart'; import 'package:solian/platform.dart'; @@ -15,6 +16,7 @@ class AccountHeadingWidget extends StatelessWidget { final String name; final String nick; final String? desc; + final Account? detail; final List? badges; final Future? status; @@ -28,6 +30,7 @@ class AccountHeadingWidget extends StatelessWidget { required this.nick, required this.desc, required this.badges, + this.detail, this.status, this.onEditStatus, }); @@ -146,6 +149,19 @@ class AccountHeadingWidget extends StatelessWidget { ], ).paddingOnly(left: 116, top: 6), const SizedBox(height: 4), + if (detail?.suspendedAt != null) + SizedBox( + width: double.infinity, + child: Card( + child: ListTile( + title: Text('accountSuspended'.tr), + subtitle: Text('accountSuspendedAt'.trParams({ + 'date': DateFormat('y/M/d').format(detail!.suspendedAt!), + })), + trailing: const Icon(Icons.block), + ), + ), + ).paddingOnly(left: 16, right: 16), if (badges?.isNotEmpty ?? false) SizedBox( width: double.infinity, diff --git a/lib/widgets/account/account_profile_popup.dart b/lib/widgets/account/account_profile_popup.dart index f3f5270..f899935 100644 --- a/lib/widgets/account/account_profile_popup.dart +++ b/lib/widgets/account/account_profile_popup.dart @@ -60,6 +60,7 @@ class _AccountProfilePopupState extends State { name: _userinfo!.name, nick: _userinfo!.nick, desc: _userinfo!.description, + detail: _userinfo!, badges: _userinfo!.badges, status: Get.find().getSomeoneStatus(_userinfo!.name), ).paddingOnly(top: 16),