关怀模式
This commit is contained in:
@@ -28,9 +28,13 @@ class FavoritesController extends GetxController {
|
||||
}
|
||||
|
||||
void showFilterOptions(BuildContext context) {
|
||||
// 先获取当前值,避免在弹窗中使用 Obx
|
||||
final currentSortByTime = sortByTime.value;
|
||||
final currentLikesFirst = likesFirst.value;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => Container(
|
||||
builder: (BuildContext context) => Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -43,54 +47,51 @@ class FavoritesController extends GetxController {
|
||||
ListTile(
|
||||
leading: const Icon(Icons.date_range),
|
||||
title: const Text('按时间排序'),
|
||||
trailing: Obx(
|
||||
() => Icon(
|
||||
sortByTime.value
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
trailing: Icon(
|
||||
currentSortByTime
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
sortByTime.value = true;
|
||||
Get.snackbar('提示', '已按时间排序');
|
||||
// 触发排序更新
|
||||
update();
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
Get.snackbar('提示', '已按时间排序');
|
||||
});
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.title),
|
||||
title: const Text('按分类排序'),
|
||||
trailing: Obx(
|
||||
() => Icon(
|
||||
!sortByTime.value
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
trailing: Icon(
|
||||
!currentSortByTime
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
sortByTime.value = false;
|
||||
Get.snackbar('提示', '已按分类排序');
|
||||
// 触发排序更新
|
||||
update();
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
Get.snackbar('提示', '已按分类排序');
|
||||
});
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.swap_vert),
|
||||
title: Text(likesFirst.value ? '点赞在前' : '笔记在前'),
|
||||
trailing: Obx(
|
||||
() => Icon(Icons.swap_vert, color: AppConstants.primaryColor),
|
||||
),
|
||||
title: Text(currentLikesFirst ? '点赞在前' : '笔记在前'),
|
||||
trailing: Icon(Icons.swap_vert, color: AppConstants.primaryColor),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
likesFirst.value = !likesFirst.value;
|
||||
Get.snackbar('提示', likesFirst.value ? '点赞在前' : '笔记在前');
|
||||
// 触发顺序更新
|
||||
update();
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
Get.snackbar('提示', likesFirst.value ? '点赞在前' : '笔记在前');
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user