diff --git a/assets/translations/en.json b/assets/translations/en.json index 03d9859..12a46f1 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -396,5 +396,9 @@ "abuseReportResource": "Resource Location / ID", "abuseReportReason": "Reason", "abuseReportSubmitted": "Report submitted, thank you for your contribution.", - "submit": "Submit" + "submit": "Submit", + "accountDeletion": "Delete Account", + "accountDeletionDescription": "Are you sure you want to delete this account? This operation is irreversible, all resources (posts, chat channels, publishers, etc) belonging to this account will be permanently deleted. Be careful and think twice!", + "accountDeletionActionDescription": "Delete your Solarpass account.", + "accountDeletionSubmitted": "Account deletion request has been sent, you can check your inbox and follow the instructions in the email to complete the deletion operation." } diff --git a/assets/translations/zh.json b/assets/translations/zh.json index daaa85b..692f7f5 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -396,5 +396,9 @@ "abuseReportResource": "资源位置 / ID", "abuseReportReason": "检举原因", "abuseReportSubmitted": "检举已提交,感谢你的贡献。", - "submit": "提交" + "submit": "提交", + "accountDeletion": "删除帐户", + "accountDeletionDescription": "你确定要删除这个帐户吗?该操作不可撤销,其隶属于该帐户的所有资源(帖子、聊天频道、发布者、制品等)都将被永久删除。三思而后行!", + "accountDeletionActionDescription": "删除你的 Solarpass 帐户。", + "accountDeletionSubmitted": "帐户删除申请已发出,你可以检查你的收件箱并根据邮件内的指示完成删除操作。" } diff --git a/lib/screens/account.dart b/lib/screens/account.dart index e7560b9..71bdfdc 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -33,9 +33,7 @@ class AccountScreen extends StatelessWidget { ], ), body: SingleChildScrollView( - child: ua.isAuthorized - ? _AuthorizedAccountScreen() - : _UnauthorizedAccountScreen(), + child: ua.isAuthorized ? _AuthorizedAccountScreen() : _UnauthorizedAccountScreen(), ), ); } @@ -71,15 +69,12 @@ class _AuthorizedAccountScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ - Text(ua.user!.nick) - .textStyle(Theme.of(context).textTheme.titleLarge!), + Text(ua.user!.nick).textStyle(Theme.of(context).textTheme.titleLarge!), const Gap(4), - Text('@${ua.user!.name}') - .textStyle(Theme.of(context).textTheme.bodySmall!), + Text('@${ua.user!.name}').textStyle(Theme.of(context).textTheme.bodySmall!), ], ), - Text(ua.user!.description) - .textStyle(Theme.of(context).textTheme.bodyMedium!), + Text(ua.user!.description).textStyle(Theme.of(context).textTheme.bodyMedium!), ], ), ); @@ -139,6 +134,33 @@ class _AuthorizedAccountScreen extends StatelessWidget { }); }, ), + ListTile( + title: Text('accountDeletion'.tr()), + subtitle: Text('accountDeletionActionDescription'.tr()), + contentPadding: const EdgeInsets.symmetric(horizontal: 24), + leading: const Icon(Symbols.person_cancel), + trailing: const Icon(Symbols.chevron_right), + onTap: () { + context + .showConfirmDialog( + 'accountDeletion'.tr(), + 'accountDeletionDescription'.tr(), + ) + .then((value) { + if (!value || !context.mounted) return; + final sn = context.read(); + sn.client.post('/cgi/id/users/me/deletion').then((value) { + if (context.mounted) { + context.showSnackbar('accountDeletionSubmitted'.tr()); + } + }).catchError((err) { + if (context.mounted) { + context.showErrorDialog(err); + } + }); + }); + }, + ), ], ); } @@ -162,9 +184,7 @@ class _UnauthorizedAccountScreen extends StatelessWidget { child: Icon(Symbols.waving_hand, size: 28), ), const Gap(8), - Text('accountIntroTitle') - .tr() - .textStyle(Theme.of(context).textTheme.titleLarge!), + Text('accountIntroTitle').tr().textStyle(Theme.of(context).textTheme.titleLarge!), Text('accountIntroSubtitle').tr(), ], ).padding(all: 20), @@ -226,7 +246,7 @@ class _AbuseReportDialogState extends State<_AbuseReportDialog> { setState(() => _isBusy = true); try { final sn = context.read(); - await sn.client.request( + await sn.client.post( '/cgi/id/reports/abuse', data: { 'resource': _resourceController.text, diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 4de41ea..a41fedb 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -761,7 +761,7 @@ class _PostAbuseReportDialogState extends State<_PostAbuseReportDialog> { setState(() => _isBusy = true); try { final sn = context.read(); - await sn.client.request( + await sn.client.post( '/cgi/id/reports/abuse', data: { 'resource': 'post:${widget.data.id}',