✨ Delete account
This commit is contained in:
parent
36013a3a57
commit
041be961c4
@ -177,6 +177,8 @@
|
|||||||
"channelEditProfile": "Edit Channel Profile",
|
"channelEditProfile": "Edit Channel Profile",
|
||||||
"channelEdit": "Edit Channel",
|
"channelEdit": "Edit Channel",
|
||||||
"channelEditDescription": "Change the basic information of the channel, metadata, etc.",
|
"channelEditDescription": "Change the basic information of the channel, metadata, etc.",
|
||||||
|
"channelActionDelete": "Delete Channel",
|
||||||
|
"channelActionDeleteDescription": "Delete the entire channel, and also delete messages in the channel.",
|
||||||
"fieldRealmAlias": "Realm Alias",
|
"fieldRealmAlias": "Realm Alias",
|
||||||
"fieldRealmAliasHint": "The unique realm alias within the site, used to represent the realm in URL, leave blank to auto generate. Should be URL-Safe.",
|
"fieldRealmAliasHint": "The unique realm alias within the site, used to represent the realm in URL, leave blank to auto generate. Should be URL-Safe.",
|
||||||
"fieldRealmName": "Name",
|
"fieldRealmName": "Name",
|
||||||
|
@ -177,6 +177,8 @@
|
|||||||
"channelEditProfile": "更改频道身份",
|
"channelEditProfile": "更改频道身份",
|
||||||
"channelEdit": "编辑频道",
|
"channelEdit": "编辑频道",
|
||||||
"channelEditDescription": "更改频道基本信息,元数据等。",
|
"channelEditDescription": "更改频道基本信息,元数据等。",
|
||||||
|
"channelActionDelete": "删除频道",
|
||||||
|
"channelActionDeleteDescription": "删除整个频道,并且删除频道里的所有信息。",
|
||||||
"fieldRealmAlias": "领域别名",
|
"fieldRealmAlias": "领域别名",
|
||||||
"fieldRealmAliasHint": "全站范围内唯一的领域别名,用于在 URL 中表示该领域,留空则自动生成。应遵循 URL-Safe 的原则。",
|
"fieldRealmAliasHint": "全站范围内唯一的领域别名,用于在 URL 中表示该领域,留空则自动生成。应遵循 URL-Safe 的原则。",
|
||||||
"fieldRealmName": "名称",
|
"fieldRealmName": "名称",
|
||||||
|
@ -21,9 +21,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
|
|
||||||
List<SnChannel>? _channels;
|
List<SnChannel>? _channels;
|
||||||
|
|
||||||
@override
|
void _refreshChannels() {
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
final chan = context.read<ChatChannelProvider>();
|
final chan = context.read<ChatChannelProvider>();
|
||||||
chan.fetchChannels().listen((channels) {
|
chan.fetchChannels().listen((channels) {
|
||||||
if (mounted) setState(() => _channels = channels);
|
if (mounted) setState(() => _channels = channels);
|
||||||
@ -39,6 +37,12 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_refreshChannels();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -48,40 +52,47 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
child: const Icon(Symbols.chat_add_on),
|
child: const Icon(Symbols.chat_add_on),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
GoRouter.of(context).pushNamed('chatManage');
|
GoRouter.of(context).pushNamed('chatManage').then((value) {
|
||||||
|
if (value != null && context.mounted) _refreshChannels();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
LoadingIndicator(isActive: _isBusy),
|
LoadingIndicator(isActive: _isBusy),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: RefreshIndicator(
|
||||||
itemCount: _channels?.length ?? 0,
|
onRefresh: () => Future.sync(() => _refreshChannels()),
|
||||||
itemBuilder: (context, idx) {
|
child: ListView.builder(
|
||||||
final channel = _channels![idx];
|
itemCount: _channels?.length ?? 0,
|
||||||
return ListTile(
|
itemBuilder: (context, idx) {
|
||||||
title: Text(channel.name),
|
final channel = _channels![idx];
|
||||||
subtitle: Text(
|
return ListTile(
|
||||||
channel.description,
|
title: Text(channel.name),
|
||||||
maxLines: 1,
|
subtitle: Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
channel.description,
|
||||||
),
|
maxLines: 1,
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
overflow: TextOverflow.ellipsis,
|
||||||
leading: AccountImage(
|
),
|
||||||
content: null,
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
fallbackWidget: const Icon(Symbols.chat, size: 20),
|
leading: AccountImage(
|
||||||
),
|
content: null,
|
||||||
onTap: () {
|
fallbackWidget: const Icon(Symbols.chat, size: 20),
|
||||||
GoRouter.of(context).pushNamed(
|
),
|
||||||
'chatRoom',
|
onTap: () {
|
||||||
pathParameters: {
|
GoRouter.of(context).pushNamed(
|
||||||
'scope': channel.realm?.alias ?? 'global',
|
'chatRoom',
|
||||||
'alias': channel.alias,
|
pathParameters: {
|
||||||
},
|
'scope': channel.realm?.alias ?? 'global',
|
||||||
);
|
'alias': channel.alias,
|
||||||
},
|
},
|
||||||
);
|
).then((value) {
|
||||||
},
|
if (value == true) _refreshChannels();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -65,6 +65,27 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _deleteChannel() async {
|
||||||
|
final confirm = await context.showConfirmDialog(
|
||||||
|
'channelDelete'.tr(args: [_channel!.name]),
|
||||||
|
'channelDeleteDescription'.tr(),
|
||||||
|
);
|
||||||
|
if (!confirm) return;
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
await sn.client.delete(
|
||||||
|
'/cgi/im/channels/${_channel!.realm?.alias ?? 'global'}/${_channel!.id}',
|
||||||
|
);
|
||||||
|
if (!mounted) return;
|
||||||
|
Navigator.pop(context, false);
|
||||||
|
} catch (err) {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -119,8 +140,9 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
trailing: const Icon(Symbols.chevron_right),
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
title: Text('channelEditProfile').tr(),
|
title: Text('channelEditProfile').tr(),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
_profile?.nick ??
|
(_profile?.nick?.isEmpty ?? true)
|
||||||
ud.getAccountFromCache(_profile!.accountId)!.nick,
|
? ud.getAccountFromCache(_profile!.accountId)!.nick
|
||||||
|
: _profile!.nick!,
|
||||||
),
|
),
|
||||||
contentPadding: const EdgeInsets.only(left: 20, right: 20),
|
contentPadding: const EdgeInsets.only(left: 20, right: 20),
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
@ -152,6 +174,14 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Symbols.delete),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
title: Text('channelActionDelete').tr(),
|
||||||
|
subtitle: Text('channelActionDeleteDescription').tr(),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
onTap: _deleteChannel,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -205,7 +205,9 @@ class _ChatRoomScreenState extends State<ChatRoomScreen> {
|
|||||||
'scope': widget.scope,
|
'scope': widget.scope,
|
||||||
'alias': widget.alias,
|
'alias': widget.alias,
|
||||||
}).then((value) {
|
}).then((value) {
|
||||||
if (value != null) {
|
if (value == false && context.mounted) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} else if (value != null && context.mounted) {
|
||||||
_fetchChannel();
|
_fetchChannel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user