✨ Channel isPublic and isCommunity
This commit is contained in:
parent
01db63e297
commit
c9fbe47337
@ -253,7 +253,8 @@
|
|||||||
"channelName": "Name",
|
"channelName": "Name",
|
||||||
"channelDescription": "Description",
|
"channelDescription": "Description",
|
||||||
"channelDirectDescription": "Direct message with @username",
|
"channelDirectDescription": "Direct message with @username",
|
||||||
"channelEncrypted": "Encrypted Channel",
|
"channelPublic": "Public channel",
|
||||||
|
"channelCommunity": "Community channel",
|
||||||
"channelMember": "Channel member",
|
"channelMember": "Channel member",
|
||||||
"channelMembers": "Channel members",
|
"channelMembers": "Channel members",
|
||||||
"channelMembersAdd": "Add channel members",
|
"channelMembersAdd": "Add channel members",
|
||||||
|
@ -254,7 +254,8 @@
|
|||||||
"channelName": "显示名称",
|
"channelName": "显示名称",
|
||||||
"channelDescription": "频道简介",
|
"channelDescription": "频道简介",
|
||||||
"channelDirectDescription": "与 @username 的私聊",
|
"channelDirectDescription": "与 @username 的私聊",
|
||||||
"channelEncrypted": "加密频道",
|
"channelPublic": "公开频道",
|
||||||
|
"channelCommunity": "社区频道",
|
||||||
"channelMember": "频道成员",
|
"channelMember": "频道成员",
|
||||||
"channelMembers": "频道成员",
|
"channelMembers": "频道成员",
|
||||||
"channelMembersAdd": "添加频道成员",
|
"channelMembersAdd": "添加频道成员",
|
||||||
|
@ -19,7 +19,8 @@ class Channel {
|
|||||||
int accountId;
|
int accountId;
|
||||||
Realm? realm;
|
Realm? realm;
|
||||||
int? realmId;
|
int? realmId;
|
||||||
bool isEncrypted;
|
bool isPublic;
|
||||||
|
bool isCommunity;
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: true)
|
@JsonKey(includeFromJson: false, includeToJson: true)
|
||||||
bool isAvailable = false;
|
bool isAvailable = false;
|
||||||
@ -36,7 +37,8 @@ class Channel {
|
|||||||
required this.members,
|
required this.members,
|
||||||
required this.account,
|
required this.account,
|
||||||
required this.accountId,
|
required this.accountId,
|
||||||
required this.isEncrypted,
|
required this.isPublic,
|
||||||
|
required this.isCommunity,
|
||||||
required this.realm,
|
required this.realm,
|
||||||
required this.realmId,
|
required this.realmId,
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,8 @@ Channel _$ChannelFromJson(Map<String, dynamic> json) => Channel(
|
|||||||
.toList(),
|
.toList(),
|
||||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||||
accountId: (json['account_id'] as num).toInt(),
|
accountId: (json['account_id'] as num).toInt(),
|
||||||
isEncrypted: json['is_encrypted'] as bool,
|
isPublic: json['is_public'] as bool,
|
||||||
|
isCommunity: json['is_community'] as bool,
|
||||||
realm: json['realm'] == null
|
realm: json['realm'] == null
|
||||||
? null
|
? null
|
||||||
: Realm.fromJson(json['realm'] as Map<String, dynamic>),
|
: Realm.fromJson(json['realm'] as Map<String, dynamic>),
|
||||||
@ -43,7 +44,8 @@ Map<String, dynamic> _$ChannelToJson(Channel instance) => <String, dynamic>{
|
|||||||
'account_id': instance.accountId,
|
'account_id': instance.accountId,
|
||||||
'realm': instance.realm?.toJson(),
|
'realm': instance.realm?.toJson(),
|
||||||
'realm_id': instance.realmId,
|
'realm_id': instance.realmId,
|
||||||
'is_encrypted': instance.isEncrypted,
|
'is_public': instance.isPublic,
|
||||||
|
'is_community': instance.isCommunity,
|
||||||
'is_available': instance.isAvailable,
|
'is_available': instance.isAvailable,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,13 +35,14 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
final _nameController = TextEditingController();
|
final _nameController = TextEditingController();
|
||||||
final _descriptionController = TextEditingController();
|
final _descriptionController = TextEditingController();
|
||||||
|
|
||||||
bool _isEncrypted = false;
|
bool _isPublic = false;
|
||||||
|
bool _isCommunity = false;
|
||||||
|
|
||||||
void applyChannel() async {
|
void _applyChannel() async {
|
||||||
final AuthProvider auth = Get.find();
|
final AuthProvider auth = Get.find();
|
||||||
if (auth.isAuthorized.isFalse) return;
|
if (auth.isAuthorized.isFalse) return;
|
||||||
|
|
||||||
if (_aliasController.value.text.isEmpty) randomizeAlias();
|
if (_aliasController.value.text.isEmpty) _randomizeAlias();
|
||||||
|
|
||||||
setState(() => _isBusy = true);
|
setState(() => _isBusy = true);
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
'alias': _aliasController.value.text.toLowerCase(),
|
'alias': _aliasController.value.text.toLowerCase(),
|
||||||
'name': _nameController.value.text,
|
'name': _nameController.value.text,
|
||||||
'description': _descriptionController.value.text,
|
'description': _descriptionController.value.text,
|
||||||
'is_encrypted': _isEncrypted,
|
'is_encrypted': _isPublic,
|
||||||
};
|
};
|
||||||
|
|
||||||
Response? resp;
|
Response? resp;
|
||||||
@ -71,27 +72,28 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
setState(() => _isBusy = false);
|
setState(() => _isBusy = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void randomizeAlias() {
|
void _randomizeAlias() {
|
||||||
_aliasController.text =
|
_aliasController.text =
|
||||||
const Uuid().v4().replaceAll('-', '').substring(0, 12);
|
const Uuid().v4().replaceAll('-', '').substring(0, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncWidget() {
|
void _syncWidget() {
|
||||||
if (widget.edit != null) {
|
if (widget.edit != null) {
|
||||||
_aliasController.text = widget.edit!.alias;
|
_aliasController.text = widget.edit!.alias;
|
||||||
_nameController.text = widget.edit!.name;
|
_nameController.text = widget.edit!.name;
|
||||||
_descriptionController.text = widget.edit!.description;
|
_descriptionController.text = widget.edit!.description;
|
||||||
_isEncrypted = widget.edit!.isEncrypted;
|
_isPublic = widget.edit!.isPublic;
|
||||||
|
_isCommunity = widget.edit!.isCommunity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelAction() {
|
void _cancelAction() {
|
||||||
AppRouter.instance.pop();
|
AppRouter.instance.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
syncWidget();
|
_syncWidget();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final notifyBannerActions = [
|
final notifyBannerActions = [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: cancelAction,
|
onPressed: _cancelAction,
|
||||||
child: Text('cancel'.tr),
|
child: Text('cancel'.tr),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@ -113,7 +115,7 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
toolbarHeight: AppTheme.toolbarHeight(context),
|
toolbarHeight: AppTheme.toolbarHeight(context),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: _isBusy ? null : () => applyChannel(),
|
onPressed: _isBusy ? null : () => _applyChannel(),
|
||||||
child: Text('apply'.tr.toUpperCase()),
|
child: Text('apply'.tr.toUpperCase()),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -164,7 +166,7 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
visualDensity:
|
visualDensity:
|
||||||
const VisualDensity(horizontal: -2, vertical: -2),
|
const VisualDensity(horizontal: -2, vertical: -2),
|
||||||
),
|
),
|
||||||
onPressed: () => randomizeAlias(),
|
onPressed: () => _randomizeAlias(),
|
||||||
child: const Icon(Icons.refresh),
|
child: const Icon(Icons.refresh),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -196,12 +198,17 @@ class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
|
|||||||
),
|
),
|
||||||
const Divider(thickness: 0.3),
|
const Divider(thickness: 0.3),
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
title: Text('channelEncrypted'.tr),
|
title: Text('channelPublic'.tr),
|
||||||
value: _isEncrypted,
|
value: _isPublic,
|
||||||
onChanged: (widget.edit?.isEncrypted ?? false)
|
onChanged: (value) =>
|
||||||
? null
|
setState(() => _isPublic = value ?? false),
|
||||||
: (newValue) =>
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
setState(() => _isEncrypted = newValue ?? false),
|
),
|
||||||
|
CheckboxListTile(
|
||||||
|
title: Text('channelCommunity'.tr),
|
||||||
|
value: _isCommunity,
|
||||||
|
onChanged: (value) =>
|
||||||
|
setState(() => _isCommunity = value ?? false),
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user