关怀模式

This commit is contained in:
Developer
2026-04-02 22:30:49 +08:00
parent 09fee0694c
commit 7872f2e78a
70 changed files with 4884 additions and 2752 deletions

View File

@@ -14,6 +14,9 @@ import 'home_part.dart';
import 'set/home_components.dart';
import 'set/home-load.dart';
import 'set/home-set.dart';
import '../../services/get/care_controller.dart';
import 'care/care_widgets.dart';
import 'care/care_poetry_page.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@@ -22,23 +25,31 @@ class HomePage extends StatefulWidget {
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
class _HomePageState extends State<HomePage>
with SingleTickerProviderStateMixin {
final GlobalKey repaintKey = GlobalKey();
final SecondaryButtonsManager _secondaryButtonsManager =
SecondaryButtonsManager();
final FloatingButtonsVisibilityManager _floatingButtonsVisibilityManager =
FloatingButtonsVisibilityManager();
final CareController _careController = Get.put(CareController());
late AnimationController _animationController;
@override
void initState() {
super.initState();
_secondaryButtonsManager.init();
_floatingButtonsVisibilityManager.init();
_animationController = AnimationController(
duration: const Duration(milliseconds: 300),
vsync: this,
);
}
@override
void dispose() {
_floatingButtonsVisibilityManager.dispose();
_animationController.dispose();
super.dispose();
}
@@ -47,12 +58,40 @@ class _HomePageState extends State<HomePage> {
Get.lazyPut(() => HomeController());
final controller = Get.find<HomeController>();
final themeController = Get.find<ThemeController>();
final careController = Get.find<CareController>();
return Obx(() {
final isDark = themeController.isDarkModeRx.value;
return Scaffold(
backgroundColor: isDark ? const Color(0xFF121212) : Colors.grey[50],
body: SafeArea(child: _buildBody(controller, isDark)),
// 触发动画
if (_animationController.status != AnimationStatus.forward) {
_animationController.forward(from: 0);
}
// 关怀模式开启时显示关怀页面,添加过渡动画
if (careController.isCareModeEnabled) {
return FadeTransition(
opacity: Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOut,
),
),
child: const CarePoetryPage(),
);
}
return FadeTransition(
opacity: Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOut,
),
),
child: Scaffold(
backgroundColor: isDark ? const Color(0xFF121212) : Colors.grey[50],
body: SafeArea(child: _buildBody(controller, isDark)),
),
);
});
}
@@ -113,6 +152,30 @@ class _HomePageState extends State<HomePage> {
),
),
),
// 关怀按钮 - 左上角
Positioned(
top: 8,
left: 16,
child: CareButton(
onTap: _careController.toggleCareButtonVisibility,
isDark: isDark,
),
),
// 关怀模式开关
Obx(
() => _careController.isCareButtonVisible.value
? Positioned(
top: 60,
left: 16,
right: 16,
child: CareModeToggle(
isEnabled: _careController.isCareModeEnabled,
onToggle: _careController.toggleCareMode,
isDark: isDark,
),
)
: const SizedBox.shrink(),
),
// 收起/恢复按钮 - 右上角(与下方分享按钮对齐)
Positioned(
top: 8,