release
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -15,6 +16,8 @@ class CareController extends GetxController {
|
||||
final RxBool isCareButtonVisible = false.obs;
|
||||
final RxInt _careNavigationIndex = 0.obs;
|
||||
|
||||
Timer? _autoHideTimer;
|
||||
|
||||
bool get isCareModeEnabled => _isCareModeEnabled.value;
|
||||
String get userType => _userType.value;
|
||||
bool get pinyinEnabled => _pinyinEnabled.value;
|
||||
@@ -77,6 +80,40 @@ class CareController extends GetxController {
|
||||
|
||||
void toggleCareButtonVisibility() {
|
||||
isCareButtonVisible.value = !isCareButtonVisible.value;
|
||||
|
||||
// 如果显示关怀开关,启动3秒自动隐藏定时器
|
||||
if (isCareButtonVisible.value) {
|
||||
_startAutoHideTimer();
|
||||
} else {
|
||||
_cancelAutoHideTimer();
|
||||
}
|
||||
}
|
||||
|
||||
/// 启动自动隐藏定时器
|
||||
void _startAutoHideTimer() {
|
||||
_cancelAutoHideTimer();
|
||||
_autoHideTimer = Timer(const Duration(seconds: 3), () {
|
||||
isCareButtonVisible.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
/// 取消自动隐藏定时器
|
||||
void _cancelAutoHideTimer() {
|
||||
_autoHideTimer?.cancel();
|
||||
_autoHideTimer = null;
|
||||
}
|
||||
|
||||
/// 重置自动隐藏定时器(用户交互时调用)
|
||||
void resetAutoHideTimer() {
|
||||
if (isCareButtonVisible.value) {
|
||||
_startAutoHideTimer();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_cancelAutoHideTimer();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> switchCareNavigation(int index) async {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../controllers/shared_preferences_storage_controller.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import 'theme_controller.dart';
|
||||
|
||||
class DiscoverController extends GetxController {
|
||||
var categories = <String>[].obs;
|
||||
@@ -64,7 +65,8 @@ class DiscoverController extends GetxController {
|
||||
|
||||
Future<void> refreshContent() async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
Get.snackbar('提示', '内容已刷新');
|
||||
final themeController = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', '内容已刷新', colorText: themeController.currentThemeColor);
|
||||
}
|
||||
|
||||
void toggleTips() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import 'theme_controller.dart';
|
||||
|
||||
class FavoritesController extends GetxController {
|
||||
var categories = ['全部', '点赞', '笔记', '推送', '每日一句'].obs;
|
||||
@@ -24,10 +25,12 @@ class FavoritesController extends GetxController {
|
||||
|
||||
Future<void> refreshContent() async {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
Get.snackbar('提示', '内容已刷新');
|
||||
final themeController = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', '内容已刷新', colorText: themeController.currentThemeColor);
|
||||
}
|
||||
|
||||
void showFilterOptions(BuildContext context) {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
// 先获取当前值,避免在弹窗中使用 Obx
|
||||
final currentSortByTime = sortByTime.value;
|
||||
final currentLikesFirst = likesFirst.value;
|
||||
@@ -58,7 +61,8 @@ class FavoritesController extends GetxController {
|
||||
sortByTime.value = true;
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
Get.snackbar('提示', '已按时间排序');
|
||||
final tc = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', '已按时间排序', colorText: tc.currentThemeColor);
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -76,7 +80,8 @@ class FavoritesController extends GetxController {
|
||||
sortByTime.value = false;
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
Get.snackbar('提示', '已按分类排序');
|
||||
final tc = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', '已按分类排序', colorText: tc.currentThemeColor);
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -90,7 +95,12 @@ class FavoritesController extends GetxController {
|
||||
likesFirst.value = !likesFirst.value;
|
||||
// 使用 Future.delayed 确保弹窗完全关闭后再显示 snackbar
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
Get.snackbar('提示', likesFirst.value ? '点赞在前' : '笔记在前');
|
||||
final tc = Get.find<ThemeController>();
|
||||
Get.snackbar(
|
||||
'提示',
|
||||
likesFirst.value ? '点赞在前' : '笔记在前',
|
||||
colorText: tc.currentThemeColor,
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
@@ -415,6 +415,7 @@ class HomeController extends GetxController with NetworkListenerMixin {
|
||||
'keywords': true,
|
||||
'introduction': true,
|
||||
};
|
||||
update(); // 立即通知UI更新,显示骨架屏
|
||||
|
||||
try {
|
||||
final offlineDataManager = OfflineDataManager();
|
||||
@@ -490,7 +491,7 @@ class HomeController extends GetxController with NetworkListenerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
// 模拟分步加载过程
|
||||
// 模拟分步加载过程 - 简化版,避免闪烁
|
||||
Future<void> simulateSectionLoading(PoetryData newPoetryData) async {
|
||||
// 记录浏览统计
|
||||
try {
|
||||
@@ -501,60 +502,27 @@ class HomeController extends GetxController with NetworkListenerMixin {
|
||||
// 忽略错误
|
||||
}
|
||||
|
||||
// 1. 加载标题区域
|
||||
var states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['title'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
// 1. 立即更新所有数据
|
||||
poetryData.value = newPoetryData;
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 2. 加载诗句区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['name'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 3. 加载原文区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['content'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 4. 加载关键词区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['keywords'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
keywordList.value = PoetryDataUtils.extractKeywords(newPoetryData);
|
||||
update(); // 通知UI更新
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// 5. 加载译文区域
|
||||
states = <String, bool>{};
|
||||
sectionLoadingStates.forEach((key, value) {
|
||||
states[key] = value;
|
||||
});
|
||||
states['introduction'] = false;
|
||||
sectionLoadingStates.assignAll(states);
|
||||
starDisplay.value = PoetryDataUtils.getStarDisplay(newPoetryData);
|
||||
isLiked.value = false;
|
||||
errorMessage.value = '';
|
||||
update(); // 通知UI更新
|
||||
|
||||
// 2. 短暂延迟后,一次性关闭所有加载状态
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
// 一次性关闭所有加载状态
|
||||
sectionLoadingStates.value = {
|
||||
'title': false,
|
||||
'content': false,
|
||||
'name': false,
|
||||
'keywords': false,
|
||||
'introduction': false,
|
||||
};
|
||||
update();
|
||||
|
||||
checkIfLiked();
|
||||
updateCurrentHistoryIndex();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import '../../controllers/history_controller.dart';
|
||||
import '../../controllers/shared_preferences_storage_controller.dart';
|
||||
import '../isweb/wakelock_service.dart';
|
||||
import '../../views/profile/guide/tongji.dart';
|
||||
import 'theme_controller.dart';
|
||||
|
||||
class ProfileController extends GetxController with WidgetsBindingObserver {
|
||||
// 页面状态
|
||||
@@ -214,9 +215,14 @@ class ProfileController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
// === 屏幕常亮相关方法 ===
|
||||
Future<void> toggleScreenWake(bool enable) async {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
// Web 平台不支持 wakelock_plus
|
||||
if (kIsWeb) {
|
||||
Get.snackbar('提示', 'Web 平台不支持屏幕常亮功能');
|
||||
Get.snackbar(
|
||||
'提示',
|
||||
'Web 平台不支持屏幕常亮功能',
|
||||
colorText: themeController.currentThemeColor,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -228,10 +234,18 @@ class ProfileController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
if (enable) {
|
||||
await WakelockService.instance.enable();
|
||||
Get.snackbar('提示', '屏幕常亮已开启');
|
||||
Get.snackbar(
|
||||
'提示',
|
||||
'屏幕常亮已开启',
|
||||
colorText: themeController.currentThemeColor,
|
||||
);
|
||||
} else {
|
||||
await WakelockService.instance.disable();
|
||||
Get.snackbar('提示', '屏幕常亮已关闭');
|
||||
Get.snackbar(
|
||||
'提示',
|
||||
'屏幕常亮已关闭',
|
||||
colorText: themeController.currentThemeColor,
|
||||
);
|
||||
}
|
||||
|
||||
// 不再更新开关状态,由 UI 层直接控制
|
||||
@@ -324,6 +338,7 @@ class ProfileController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
// === 显示提示 ===
|
||||
void showSnackBar(String message) {
|
||||
Get.snackbar('提示', message);
|
||||
final themeController = Get.find<ThemeController>();
|
||||
Get.snackbar('提示', message, colorText: themeController.currentThemeColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ enum TransparencyLevel {
|
||||
class TapLiquidGlassController extends GetxController {
|
||||
SharedPreferences? _prefs;
|
||||
final _isEnabled = true.obs;
|
||||
final _transparencyLevel = TransparencyLevel.weak.obs;
|
||||
final _transparencyLevel = TransparencyLevel.medium.obs;
|
||||
|
||||
bool get isEnabled => _isEnabled.value;
|
||||
RxBool get isEnabledRx => _isEnabled;
|
||||
@@ -68,7 +68,7 @@ class TapLiquidGlassController extends GetxController {
|
||||
Future<void> _loadSettings() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
_isEnabled.value = _prefs?.getBool(AppConfig.keyTapLiquidGlass) ?? true;
|
||||
final levelIndex = _prefs?.getInt('tap_liquid_glass_transparency') ?? 0;
|
||||
final levelIndex = _prefs?.getInt('tap_liquid_glass_transparency') ?? 1;
|
||||
_transparencyLevel.value = TransparencyLevel
|
||||
.values[levelIndex.clamp(0, TransparencyLevel.values.length - 1)];
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ class ThemeController extends GetxController {
|
||||
duration: const Duration(seconds: 2),
|
||||
margin: const EdgeInsets.all(16),
|
||||
borderRadius: 12,
|
||||
colorText: currentThemeColor,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,6 +174,7 @@ class ThemeController extends GetxController {
|
||||
duration: const Duration(seconds: 2),
|
||||
margin: const EdgeInsets.all(16),
|
||||
borderRadius: 12,
|
||||
colorText: currentThemeColor,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -266,6 +268,7 @@ class ThemeController extends GetxController {
|
||||
duration: const Duration(seconds: 2),
|
||||
margin: const EdgeInsets.all(16),
|
||||
borderRadius: 12,
|
||||
colorText: currentThemeColor,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user