mod: fav folder edit

This commit is contained in:
guozhigq
2024-11-27 00:05:10 +08:00
parent bae1550593
commit 518f49973c
3 changed files with 27 additions and 24 deletions

View File

@ -134,8 +134,9 @@ class FavDetailController extends GetxController {
'privacy': [22, 0].contains(item!.attr) ? 0 : 1, 'privacy': [22, 0].contains(item!.attr) ? 0 : 1,
}, },
); );
title.value = res['title']; if (res != null) {
print(title); title.value = res['title'];
}
} }
Future toViewPlayAll() async { Future toViewPlayAll() async {

View File

@ -53,6 +53,7 @@ class FavEditController extends GetxController {
intro: intro, intro: intro,
mediaId: mediaId!, mediaId: mediaId!,
cover: cover, cover: cover,
privacy: privacy.value,
); );
if (res['status']) { if (res['status']) {
SmartDialog.showToast('编辑成功'); SmartDialog.showToast('编辑成功');
@ -74,4 +75,14 @@ class FavEditController extends GetxController {
SmartDialog.showToast(res['msg']); SmartDialog.showToast(res['msg']);
} }
} }
void togglePrivacy() {
if (privacy.value == 0) {
privacy.value = 1;
SmartDialog.showToast('设置为私密后,只有自己可见');
} else {
privacy.value = 0;
SmartDialog.showToast('设置为公开后,所有人可见');
}
}
} }

View File

@ -21,31 +21,22 @@ class _FavEditPageState extends State<FavEditPage> {
appBar: AppBar( appBar: AppBar(
title: Obx( title: Obx(
() => _favEditController.type.value == 'add' () => _favEditController.type.value == 'add'
? Text( ? const Text('新建收藏夹')
'新建收藏夹', : const Text('编辑收藏夹'),
style: Theme.of(context).textTheme.titleMedium,
)
: Text(
'编辑收藏夹',
style: Theme.of(context).textTheme.titleMedium,
),
), ),
actions: [ actions: [
Obx( Obx(
() => _favEditController.privacy.value == 0 () => IconButton(
? IconButton( onPressed: _favEditController.togglePrivacy,
onPressed: () { icon: Icon(
_favEditController.privacy.value = 1; _favEditController.privacy.value == 0
}, ? Icons.lock_open_outlined
icon: const Icon(Icons.lock_open_outlined)) : Icons.lock_outlined,
: IconButton( color: _favEditController.privacy.value == 0
onPressed: () { ? null
_favEditController.privacy.value = 0; : Theme.of(context).colorScheme.error,
}, ),
icon: Icon( ),
Icons.lock_outlined,
color: Theme.of(context).colorScheme.error,
)),
), ),
TextButton( TextButton(
onPressed: _favEditController.onSubmit, child: const Text('保存')), onPressed: _favEditController.onSubmit, child: const Text('保存')),