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,
},
);
title.value = res['title'];
print(title);
if (res != null) {
title.value = res['title'];
}
}
Future toViewPlayAll() async {

View File

@ -53,6 +53,7 @@ class FavEditController extends GetxController {
intro: intro,
mediaId: mediaId!,
cover: cover,
privacy: privacy.value,
);
if (res['status']) {
SmartDialog.showToast('编辑成功');
@ -74,4 +75,14 @@ class FavEditController extends GetxController {
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(
title: Obx(
() => _favEditController.type.value == 'add'
? Text(
'新建收藏夹',
style: Theme.of(context).textTheme.titleMedium,
)
: Text(
'编辑收藏夹',
style: Theme.of(context).textTheme.titleMedium,
),
? const Text('新建收藏夹')
: const Text('编辑收藏夹'),
),
actions: [
Obx(
() => _favEditController.privacy.value == 0
? IconButton(
onPressed: () {
_favEditController.privacy.value = 1;
},
icon: const Icon(Icons.lock_open_outlined))
: IconButton(
onPressed: () {
_favEditController.privacy.value = 0;
},
icon: Icon(
Icons.lock_outlined,
color: Theme.of(context).colorScheme.error,
)),
() => IconButton(
onPressed: _favEditController.togglePrivacy,
icon: Icon(
_favEditController.privacy.value == 0
? Icons.lock_open_outlined
: Icons.lock_outlined,
color: _favEditController.privacy.value == 0
? null
: Theme.of(context).colorScheme.error,
),
),
),
TextButton(
onPressed: _favEditController.onSubmit, child: const Text('保存')),