Stickers

This commit is contained in:
LittleSheep 2025-02-23 14:23:06 +08:00
parent 537f404fe0
commit 81a79f9476
6 changed files with 164 additions and 4 deletions

View File

@ -716,5 +716,6 @@
"fieldStickerPackPrefix": "Prefix",
"fieldStickerAttachment": "Attachment",
"stickersNew": "New Sticker",
"stickersNewDescription": "Create a new sticker belongs to this pack."
"stickersNewDescription": "Create a new sticker belongs to this pack.",
"stickersPackNew": "New Sticker Pack"
}

View File

@ -714,5 +714,6 @@
"fieldStickerPackPrefix": "贴图包前缀",
"fieldStickerAttachment": "附件",
"stickersNew": "新建贴图",
"stickersNewDescription": "创建一个新的贴图。"
"stickersNewDescription": "创建一个新的贴图。",
"stickersPackNew": "新建贴图包"
}

View File

@ -699,5 +699,21 @@
"stickersRemoved": "貼圖包已被移除,你可以隨時再次添加回來。",
"stickersReload": "重載貼圖包",
"stickersReloadDescription": "從服務器重新加載添加過的貼圖,更新貼圖選擇器。",
"stickersReloaded": "貼圖包已重載。"
"stickersReloaded": "貼圖包已重載。",
"stickersPackDelete": "刪除貼圖包 {}",
"stickersPackDeleteDescription": "你確定要刪除這個貼圖包嗎?這個操作不可撤銷。",
"stickersPackDeleted": "貼圖包已被刪除。",
"stickersDelete": "刪除貼圖 {}",
"stickersDeleteDescription": "你確定要刪除這個貼圖嗎?這個操作不可撤銷。",
"stickersDeleted": "貼圖已被刪除。",
"fieldStickerName": "貼圖名稱",
"fieldStickerAlias": "貼圖別名",
"fieldStickerAliasHint": "和貼圖包前綴組合成為本貼圖的唯一佔位符。",
"fieldStickerPackName": "名稱",
"fieldStickerPackDescription": "描述",
"fieldStickerPackPrefix": "貼圖包前綴",
"fieldStickerAttachment": "附件",
"stickersNew": "新建貼圖",
"stickersNewDescription": "創建一個新的貼圖。",
"stickersPackNew": "新建貼圖包"
}

View File

@ -699,5 +699,21 @@
"stickersRemoved": "貼圖包已被移除,你可以隨時再次添加回來。",
"stickersReload": "重載貼圖包",
"stickersReloadDescription": "從服務器重新加載添加過的貼圖,更新貼圖選擇器。",
"stickersReloaded": "貼圖包已重載。"
"stickersReloaded": "貼圖包已重載。",
"stickersPackDelete": "刪除貼圖包 {}",
"stickersPackDeleteDescription": "你確定要刪除這個貼圖包嗎?這個操作不可撤銷。",
"stickersPackDeleted": "貼圖包已被刪除。",
"stickersDelete": "刪除貼圖 {}",
"stickersDeleteDescription": "你確定要刪除這個貼圖嗎?這個操作不可撤銷。",
"stickersDeleted": "貼圖已被刪除。",
"fieldStickerName": "貼圖名稱",
"fieldStickerAlias": "貼圖別名",
"fieldStickerAliasHint": "和貼圖包前綴組合成為本貼圖的唯一佔位符。",
"fieldStickerPackName": "名稱",
"fieldStickerPackDescription": "描述",
"fieldStickerPackPrefix": "貼圖包前綴",
"fieldStickerAttachment": "附件",
"stickersNew": "新建貼圖",
"stickersNewDescription": "創建一個新的貼圖。",
"stickersPackNew": "新建貼圖包"
}

View File

@ -136,6 +136,20 @@ class _StickerScreenState extends State<StickerScreen>
appBar: AppBar(
leading: AutoAppBarLeading(),
title: Text('screenStickers').tr(),
actions: [
IconButton(
icon: const Icon(Symbols.add_circle),
onPressed: () {
showDialog(
context: context,
builder: (context) => _StickerPackCreateDialog(),
).then((value) {
if (value == true) _refreshPacks();
});
},
),
const Gap(8),
],
bottom: TabBar(
controller: _tabController,
tabs: [
@ -344,3 +358,107 @@ class _StickerPackAddPopupState extends State<_StickerPackAddPopup> {
);
}
}
class _StickerPackCreateDialog extends StatefulWidget {
const _StickerPackCreateDialog();
@override
State<_StickerPackCreateDialog> createState() =>
_StickerPackCreateDialogState();
}
class _StickerPackCreateDialogState extends State<_StickerPackCreateDialog> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _prefixController = TextEditingController();
final TextEditingController _descriptionController = TextEditingController();
bool _isBusy = false;
Future<void> _createPack() async {
if (_nameController.text.isEmpty ||
_prefixController.text.isEmpty ||
_descriptionController.text.isEmpty) {
return;
}
setState(() => _isBusy = true);
try {
final sn = context.read<SnNetworkProvider>();
await sn.client.post(
'/cgi/uc/stickers/packs',
data: {
'name': _nameController.text,
'prefix': _prefixController.text,
'description': _descriptionController.text,
},
);
if (!mounted) return;
Navigator.pop(context, true);
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
}
}
@override
void dispose() {
_nameController.dispose();
_prefixController.dispose();
_descriptionController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('stickersPackNew').tr(),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: _nameController,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'fieldStickerPackName'.tr(),
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
const Gap(4),
TextField(
controller: _prefixController,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'fieldStickerPackPrefix'.tr(),
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
const Gap(4),
TextField(
controller: _descriptionController,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'fieldStickerPackDescription'.tr(),
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
],
),
actions: [
TextButton(
onPressed: _isBusy
? null
: () {
Navigator.pop(context);
},
child: Text('dialogDismiss').tr(),
),
TextButton(
onPressed: _isBusy ? null : () => _createPack(),
child: Text('dialogConfirm').tr(),
),
],
);
}
}

View File

@ -158,6 +158,14 @@ class _StickerCreateDialogState extends State<_StickerCreateDialog> {
bool _isBusy = false;
@override
void dispose() {
_nameController.dispose();
_aliasController.dispose();
_attachmentController.dispose();
super.dispose();
}
Future<void> _createSticker() async {
if (_nameController.text.isEmpty ||
_aliasController.text.isEmpty ||