diff --git a/lib/pages/fav_detail/controller.dart b/lib/pages/fav_detail/controller.dart index 022e0103..32bad5c9 100644 --- a/lib/pages/fav_detail/controller.dart +++ b/lib/pages/fav_detail/controller.dart @@ -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 { diff --git a/lib/pages/fav_edit/controller.dart b/lib/pages/fav_edit/controller.dart index bf310389..18e88a03 100644 --- a/lib/pages/fav_edit/controller.dart +++ b/lib/pages/fav_edit/controller.dart @@ -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('设置为公开后,所有人可见'); + } + } } diff --git a/lib/pages/fav_edit/view.dart b/lib/pages/fav_edit/view.dart index 2fecf070..4b5db10c 100644 --- a/lib/pages/fav_edit/view.dart +++ b/lib/pages/fav_edit/view.dart @@ -21,31 +21,22 @@ class _FavEditPageState extends State { 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('保存')),