172 lines
5.0 KiB
Dart
172 lines
5.0 KiB
Dart
/// 时间: 2026-04-02
|
|
/// 功能: 关怀模式相关组件
|
|
/// 介绍: 包含关怀按钮和开关的UI组件
|
|
/// 最新变化: 2026-04-02 初始创建
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import '../../../services/get/theme_controller.dart';
|
|
import '../../../services/get/care_controller.dart';
|
|
import 'care-page.dart';
|
|
|
|
/// 关怀按钮组件
|
|
class CareButton extends StatelessWidget {
|
|
const CareButton({super.key, required this.onTap, required this.isDark});
|
|
|
|
final VoidCallback onTap;
|
|
final bool isDark;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final themeController = Get.find<ThemeController>();
|
|
final primaryColor = themeController.currentThemeColor;
|
|
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
width: 44,
|
|
height: 44,
|
|
decoration: BoxDecoration(
|
|
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withAlpha(isDark ? 40 : 20),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Center(child: Icon(Icons.people, color: primaryColor, size: 24)),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 关怀模式开关组件
|
|
class CareModeToggle extends StatelessWidget {
|
|
const CareModeToggle({
|
|
super.key,
|
|
required this.isEnabled,
|
|
required this.onToggle,
|
|
required this.isDark,
|
|
});
|
|
|
|
final bool isEnabled;
|
|
final VoidCallback onToggle;
|
|
final bool isDark;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final themeController = Get.find<ThemeController>();
|
|
final primaryColor = themeController.currentThemeColor;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
margin: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withAlpha(isDark ? 40 : 20),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(Icons.people, color: primaryColor, size: 20),
|
|
const SizedBox(width: 12),
|
|
GestureDetector(
|
|
onTap: () => Get.to(() => const CarePage()),
|
|
child: Text(
|
|
'关怀',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: isDark ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Switch(
|
|
value: isEnabled,
|
|
onChanged: (_) => onToggle(),
|
|
activeColor: primaryColor,
|
|
inactiveTrackColor: isDark ? Colors.grey[700] : Colors.grey[300],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 关怀模式页面顶部开关组件
|
|
class CarePageHeaderToggle extends StatelessWidget {
|
|
const CarePageHeaderToggle({super.key, required this.isDark});
|
|
|
|
final bool isDark;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final themeController = Get.find<ThemeController>();
|
|
final careController = Get.find<CareController>();
|
|
final primaryColor = themeController.currentThemeColor;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
margin: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withAlpha(isDark ? 40 : 20),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(Icons.people, color: primaryColor, size: 20),
|
|
const SizedBox(width: 12),
|
|
GestureDetector(
|
|
onTap: () => Get.to(() => const CarePage()),
|
|
child: Text(
|
|
'关怀模式',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: isDark ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Obx(
|
|
() => Switch(
|
|
value: careController.isCareModeEnabled,
|
|
onChanged: (value) {
|
|
// 关闭关怀模式并返回正常页面
|
|
careController.toggleCareMode();
|
|
},
|
|
activeColor: primaryColor,
|
|
inactiveTrackColor: isDark ? Colors.grey[700] : Colors.grey[300],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|