diff --git a/lib/services/get/favorites_controller.dart b/lib/services/get/favorites_controller.dart index 98dd8c1..f8b5b08 100644 --- a/lib/services/get/favorites_controller.dart +++ b/lib/services/get/favorites_controller.dart @@ -6,6 +6,8 @@ import 'theme_controller.dart'; class FavoritesController extends GetxController { static const String _isGridViewKey = 'favorites_is_grid_view'; + final ThemeController _themeController = Get.find(); + var categories = ['全部', '点赞', '笔记', '推送', '每日一句'].obs; var isGridView = true.obs; var currentTabIndex = 0.obs; @@ -52,17 +54,12 @@ class FavoritesController extends GetxController { Future refreshContent() async { await Future.delayed(const Duration(milliseconds: 500)); - Get.snackbar( - '提示', - '内容已刷新', - colorText: Get.find().currentThemeColor, - ); + Get.snackbar('提示', '内容已刷新', colorText: _themeController.currentThemeColor); } void showFilterOptions(BuildContext context) { - final themeController = Get.find(); - final isDark = themeController.isDarkMode; - final themeColor = themeController.currentThemeColor; + final isDark = _themeController.isDarkMode; + final themeColor = _themeController.currentThemeColor; showModalBottomSheet( context: context, @@ -93,66 +90,78 @@ class FavoritesController extends GetxController { ), ), const SizedBox(height: 16), - Obx(() => ListTile( - leading: Icon(Icons.date_range, color: themeColor), - title: Text( - '按时间排序', - style: TextStyle(color: isDark ? Colors.white : Colors.black87), + Obx( + () => ListTile( + leading: Icon(Icons.date_range, color: themeColor), + title: Text( + '按时间排序', + style: TextStyle( + color: isDark ? Colors.white : Colors.black87, + ), + ), + trailing: Icon( + sortByTime.value + ? Icons.radio_button_checked + : Icons.radio_button_unchecked, + color: themeColor, + ), + onTap: () { + Navigator.pop(context); + sortByTime.value = true; + Future.delayed(const Duration(milliseconds: 100), () { + Get.snackbar('提示', '已按时间排序', colorText: themeColor); + }); + }, ), - trailing: Icon( - sortByTime.value - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: themeColor, + ), + Obx( + () => ListTile( + leading: Icon(Icons.title, color: themeColor), + title: Text( + '按分类排序', + style: TextStyle( + color: isDark ? Colors.white : Colors.black87, + ), + ), + trailing: Icon( + !sortByTime.value + ? Icons.radio_button_checked + : Icons.radio_button_unchecked, + color: themeColor, + ), + onTap: () { + Navigator.pop(context); + sortByTime.value = false; + Future.delayed(const Duration(milliseconds: 100), () { + Get.snackbar('提示', '已按分类排序', colorText: themeColor); + }); + }, ), - onTap: () { - Navigator.pop(context); - sortByTime.value = true; - Future.delayed(const Duration(milliseconds: 100), () { - Get.snackbar('提示', '已按时间排序', colorText: themeColor); - }); - }, - )), - Obx(() => ListTile( - leading: Icon(Icons.title, color: themeColor), - title: Text( - '按分类排序', - style: TextStyle(color: isDark ? Colors.white : Colors.black87), - ), - trailing: Icon( - !sortByTime.value - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: themeColor, - ), - onTap: () { - Navigator.pop(context); - sortByTime.value = false; - Future.delayed(const Duration(milliseconds: 100), () { - Get.snackbar('提示', '已按分类排序', colorText: themeColor); - }); - }, - )), + ), const Divider(color: Colors.grey), - Obx(() => ListTile( - leading: Icon(Icons.swap_vert, color: themeColor), - title: Text( - likesFirst.value ? '点赞在前' : '笔记在前', - style: TextStyle(color: isDark ? Colors.white : Colors.black87), + Obx( + () => ListTile( + leading: Icon(Icons.swap_vert, color: themeColor), + title: Text( + likesFirst.value ? '点赞在前' : '笔记在前', + style: TextStyle( + color: isDark ? Colors.white : Colors.black87, + ), + ), + trailing: Icon(Icons.swap_vert, color: themeColor), + onTap: () { + Navigator.pop(context); + likesFirst.value = !likesFirst.value; + Future.delayed(const Duration(milliseconds: 100), () { + Get.snackbar( + '提示', + likesFirst.value ? '点赞在前' : '笔记在前', + colorText: themeColor, + ); + }); + }, ), - trailing: Icon(Icons.swap_vert, color: themeColor), - onTap: () { - Navigator.pop(context); - likesFirst.value = !likesFirst.value; - Future.delayed(const Duration(milliseconds: 100), () { - Get.snackbar( - '提示', - likesFirst.value ? '点赞在前' : '笔记在前', - colorText: themeColor, - ); - }); - }, - )), + ), ], ), ),