鸿蒙 api23
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import 'theme_controller.dart';
|
||||
|
||||
class FavoritesController extends GetxController {
|
||||
@@ -61,79 +60,99 @@ class FavoritesController extends GetxController {
|
||||
}
|
||||
|
||||
void showFilterOptions(BuildContext context) {
|
||||
// 先获取当前值,避免在弹窗中使用 Obx
|
||||
final currentSortByTime = sortByTime.value;
|
||||
final currentLikesFirst = likesFirst.value;
|
||||
final themeController = Get.find<ThemeController>();
|
||||
final isDark = themeController.isDarkMode;
|
||||
final themeColor = themeController.currentThemeColor;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (BuildContext context) => Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: isDark ? Colors.grey[600] : Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'排序选项',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.date_range),
|
||||
title: const Text('按时间排序'),
|
||||
Obx(() => ListTile(
|
||||
leading: Icon(Icons.date_range, color: themeColor),
|
||||
title: Text(
|
||||
'按时间排序',
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black87),
|
||||
),
|
||||
trailing: Icon(
|
||||
currentSortByTime
|
||||
sortByTime.value
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
sortByTime.value = true;
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
final tc = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', '已按时间排序', colorText: tc.currentThemeColor);
|
||||
Get.snackbar('提示', '已按时间排序', colorText: themeColor);
|
||||
});
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.title),
|
||||
title: const Text('按分类排序'),
|
||||
)),
|
||||
Obx(() => ListTile(
|
||||
leading: Icon(Icons.title, color: themeColor),
|
||||
title: Text(
|
||||
'按分类排序',
|
||||
style: TextStyle(color: isDark ? Colors.white : Colors.black87),
|
||||
),
|
||||
trailing: Icon(
|
||||
!currentSortByTime
|
||||
!sortByTime.value
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: AppConstants.primaryColor,
|
||||
color: themeColor,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
sortByTime.value = false;
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
final tc = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', '已按分类排序', colorText: tc.currentThemeColor);
|
||||
Get.snackbar('提示', '已按分类排序', colorText: themeColor);
|
||||
});
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.swap_vert),
|
||||
title: Text(currentLikesFirst ? '点赞在前' : '笔记在前'),
|
||||
trailing: Icon(Icons.swap_vert, color: AppConstants.primaryColor),
|
||||
)),
|
||||
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),
|
||||
),
|
||||
trailing: Icon(Icons.swap_vert, color: themeColor),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
likesFirst.value = !likesFirst.value;
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
final tc = Get.find<ThemeController>();
|
||||
Get.snackbar(
|
||||
'提示',
|
||||
likesFirst.value ? '点赞在前' : '笔记在前',
|
||||
colorText: tc.currentThemeColor,
|
||||
colorText: themeColor,
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user