Compare commits
2 Commits
ddfbcc5e58
...
a2a42f66a2
Author | SHA1 | Date | |
---|---|---|---|
a2a42f66a2 | |||
51c7b03ff8 |
@ -177,12 +177,21 @@
|
|||||||
"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.",
|
||||||
|
"channelProfileEdit": "Edit Channel Profile",
|
||||||
"channelActionDelete": "Delete Channel",
|
"channelActionDelete": "Delete Channel",
|
||||||
"channelActionDeleteDescription": "Delete the entire channel, and also delete messages in the channel.",
|
"channelActionDeleteDescription": "Delete the entire channel, and also delete messages in the channel.",
|
||||||
"channelLeave": "Leave Channel {}",
|
"channelLeave": "Leave Channel {}",
|
||||||
"channelLeaveDescription": "Leave this channel, but the messages in the channel will not be removed.",
|
"channelLeaveDescription": "Leave this channel, but the messages in the channel will not be removed.",
|
||||||
"channelActionLeave": "Leave Channel",
|
"channelActionLeave": "Leave Channel",
|
||||||
"channelActionLeaveDescription": "Delete your profile in this channel.",
|
"channelActionLeaveDescription": "Delete your profile in this channel.",
|
||||||
|
"channelNotifyLevel": "Notify Level",
|
||||||
|
"channelNotifyLevelDescription": "Decide to receive how much notifications from this channel.",
|
||||||
|
"channelNotifyLevelAll": "All",
|
||||||
|
"channelNotifyLevelMentioned": "Only Mentioned",
|
||||||
|
"channelNotifyLevelNone": "Muted",
|
||||||
|
"channelNotifyLevelApplied": "Channel notify level has been applied.",
|
||||||
|
"fieldChannelProfileNick": "In-Channel Display Name",
|
||||||
|
"fieldChannelProfileNickHint": "The nickname to display in the channel, leave blank to use the account display name.",
|
||||||
"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,12 +177,21 @@
|
|||||||
"channelEditProfile": "更改频道身份",
|
"channelEditProfile": "更改频道身份",
|
||||||
"channelEdit": "编辑频道",
|
"channelEdit": "编辑频道",
|
||||||
"channelEditDescription": "更改频道基本信息,元数据等。",
|
"channelEditDescription": "更改频道基本信息,元数据等。",
|
||||||
|
"channelProfileEdit": "编辑频道身份",
|
||||||
"channelActionDelete": "删除频道",
|
"channelActionDelete": "删除频道",
|
||||||
"channelActionDeleteDescription": "删除整个频道,并且删除频道里的所有信息。",
|
"channelActionDeleteDescription": "删除整个频道,并且删除频道里的所有信息。",
|
||||||
"channelLeave": "退出频道 {}",
|
"channelLeave": "退出频道 {}",
|
||||||
"channelLeaveDescription": "退出该频道,但是你频道内的信息不会被移除。",
|
"channelLeaveDescription": "退出该频道,但是你频道内的信息不会被移除。",
|
||||||
"channelActionLeave": "退出频道",
|
"channelActionLeave": "退出频道",
|
||||||
"channelActionLeaveDescription": "删除你在这个频道的身份。",
|
"channelActionLeaveDescription": "删除你在这个频道的身份。",
|
||||||
|
"channelNotifyLevel": "通知级别",
|
||||||
|
"channelNotifyLevelDescription": "有您决定要接受多少来自这个频道的消息。",
|
||||||
|
"channelNotifyLevelAll": "全部通知",
|
||||||
|
"channelNotifyLevelMentioned": "仅提及",
|
||||||
|
"channelNotifyLevelNone": "全部静音",
|
||||||
|
"channelNotifyLevelApplied": "已经保存并应用频道通知级别配置。",
|
||||||
|
"fieldChannelProfileNick": "频道内显示名",
|
||||||
|
"fieldChannelProfileNickHint": "在频道内显示的昵称,留空则使用账号显示名。",
|
||||||
"fieldRealmAlias": "领域别名",
|
"fieldRealmAlias": "领域别名",
|
||||||
"fieldRealmAliasHint": "全站范围内唯一的领域别名,用于在 URL 中表示该领域,留空则自动生成。应遵循 URL-Safe 的原则。",
|
"fieldRealmAliasHint": "全站范围内唯一的领域别名,用于在 URL 中表示该领域,留空则自动生成。应遵循 URL-Safe 的原则。",
|
||||||
"fieldRealmName": "名称",
|
"fieldRealmName": "名称",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
@ -55,6 +56,7 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
final resp = await sn.client
|
final resp = await sn.client
|
||||||
.get('/cgi/im/channels/${_channel!.keyPath}/members/me');
|
.get('/cgi/im/channels/${_channel!.keyPath}/members/me');
|
||||||
_profile = SnChannelMember.fromJson(resp.data);
|
_profile = SnChannelMember.fromJson(resp.data);
|
||||||
|
_notifyLevel = _profile!.notify;
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
final ud = context.read<UserDirectoryProvider>();
|
final ud = context.read<UserDirectoryProvider>();
|
||||||
await ud.getAccount(_profile!.accountId);
|
await ud.getAccount(_profile!.accountId);
|
||||||
@ -108,6 +110,51 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _notifyLevel = 0;
|
||||||
|
bool _isUpdatingNotifyLevel = false;
|
||||||
|
|
||||||
|
final kNotifyLevels = {
|
||||||
|
0: 'channelNotifyLevelAll'.tr(),
|
||||||
|
1: 'channelNotifyLevelMentioned'.tr(),
|
||||||
|
2: 'channelNotifyLevelNone'.tr(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Future<void> _updateNotifyLevel(int value) async {
|
||||||
|
if (_isUpdatingNotifyLevel) return;
|
||||||
|
|
||||||
|
setState(() => _isUpdatingNotifyLevel = true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
await sn.client.put(
|
||||||
|
'/cgi/im/channels/${_channel!.keyPath}/members/me/notify',
|
||||||
|
data: {'notify_level': value},
|
||||||
|
);
|
||||||
|
_notifyLevel = value;
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showSnackbar('channelNotifyLevelApplied'.tr());
|
||||||
|
} catch (err) {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
} finally {
|
||||||
|
setState(() => _isUpdatingNotifyLevel = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showChannelProfileDetail() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => _ChannelProfileDetailDialog(
|
||||||
|
channel: _channel!,
|
||||||
|
current: _profile!,
|
||||||
|
),
|
||||||
|
).then((value) {
|
||||||
|
if (value != null && mounted) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -159,8 +206,42 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
.fontSize(17)
|
.fontSize(17)
|
||||||
.tr()
|
.tr()
|
||||||
.padding(horizontal: 20, bottom: 4),
|
.padding(horizontal: 20, bottom: 4),
|
||||||
// TODO add notify level modifier
|
ListTile(
|
||||||
// TODO impl this
|
leading: const Icon(Symbols.notifications),
|
||||||
|
trailing: DropdownButtonHideUnderline(
|
||||||
|
child: DropdownButton2<int>(
|
||||||
|
isExpanded: true,
|
||||||
|
items: kNotifyLevels.entries
|
||||||
|
.map((item) => DropdownMenuItem<int>(
|
||||||
|
enabled: !_isUpdatingNotifyLevel,
|
||||||
|
value: item.key,
|
||||||
|
child: Text(
|
||||||
|
item.value,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
value: _notifyLevel,
|
||||||
|
onChanged: (int? value) {
|
||||||
|
if (value == null) return;
|
||||||
|
_updateNotifyLevel(value);
|
||||||
|
},
|
||||||
|
buttonStyleData: const ButtonStyleData(
|
||||||
|
padding: EdgeInsets.only(left: 16, right: 1),
|
||||||
|
height: 40,
|
||||||
|
width: 140,
|
||||||
|
),
|
||||||
|
menuItemStyleData: const MenuItemStyleData(
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text('channelNotifyLevel').tr(),
|
||||||
|
subtitle: Text('channelNotifyLevelDescription').tr(),
|
||||||
|
contentPadding: const EdgeInsets.only(left: 24, right: 20),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: AccountImage(
|
leading: AccountImage(
|
||||||
content:
|
content:
|
||||||
@ -175,7 +256,7 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
: _profile!.nick!,
|
: _profile!.nick!,
|
||||||
),
|
),
|
||||||
contentPadding: const EdgeInsets.only(left: 20, right: 20),
|
contentPadding: const EdgeInsets.only(left: 20, right: 20),
|
||||||
onTap: () {},
|
onTap: _showChannelProfileDetail,
|
||||||
),
|
),
|
||||||
if (!isOwned)
|
if (!isOwned)
|
||||||
ListTile(
|
ListTile(
|
||||||
@ -231,3 +312,80 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ChannelProfileDetailDialog extends StatefulWidget {
|
||||||
|
final SnChannel channel;
|
||||||
|
final SnChannelMember current;
|
||||||
|
const _ChannelProfileDetailDialog({
|
||||||
|
required this.channel,
|
||||||
|
required this.current,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_ChannelProfileDetailDialog> createState() =>
|
||||||
|
_ChannelProfileDetailDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChannelProfileDetailDialogState
|
||||||
|
extends State<_ChannelProfileDetailDialog> {
|
||||||
|
bool _isBusy = false;
|
||||||
|
|
||||||
|
final TextEditingController _nickController = TextEditingController();
|
||||||
|
|
||||||
|
Future<void> _updateProfile() async {
|
||||||
|
setState(() => _isBusy = true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
await sn.client.put(
|
||||||
|
'/cgi/im/channels/${widget.channel.keyPath}/members/me',
|
||||||
|
data: {'nick': _nickController.text},
|
||||||
|
);
|
||||||
|
if (!mounted) return;
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
} catch (err) {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
} finally {
|
||||||
|
setState(() => _isBusy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_nickController.text = widget.current.nick ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text('channelProfileEdit').tr(),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: _nickController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'fieldChannelProfileNick'.tr(),
|
||||||
|
helperText: 'fieldChannelProfileNickHint'.tr(),
|
||||||
|
helperMaxLines: 2,
|
||||||
|
),
|
||||||
|
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: _isBusy ? null : () => Navigator.pop(context),
|
||||||
|
child: Text('dialogCancel').tr(),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: _isBusy ? null : _updateProfile,
|
||||||
|
child: Text('apply').tr(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user