/// 时间: 2026-04-02 /// 功能: 关怀页面 /// 介绍: 简约大字风格的关怀功能页面 /// 最新变化: 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'; class CarePage extends StatefulWidget { const CarePage({super.key}); @override State createState() => _CarePageState(); } class _CarePageState extends State { final CareController _careController = Get.find(); bool _readAloudEnabled = false; final List _options = ['诗词', '出处', '译文', '更多', '原文', '问候语']; @override Widget build(BuildContext context) { final themeController = Get.find(); final isDark = themeController.isDarkModeRx.value; final primaryColor = themeController.currentThemeColor; return Scaffold( backgroundColor: isDark ? const Color(0xFF121212) : Colors.white, appBar: AppBar( title: Text( '关怀', style: TextStyle( color: isDark ? Colors.white : primaryColor, fontWeight: FontWeight.bold, ), ), backgroundColor: isDark ? const Color(0xFF1A1A1A) : Colors.white, elevation: 0, leading: IconButton( icon: Icon( Icons.arrow_back, color: isDark ? Colors.white : primaryColor, ), onPressed: () => Navigator.pop(context), ), actions: [ IconButton( icon: Icon( Icons.info_outline, color: isDark ? Colors.white : primaryColor, ), onPressed: () { showDialog( context: context, builder: (context) => AlertDialog( backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white, title: Text( '功能说明', style: TextStyle( color: isDark ? Colors.white : Colors.black87, fontWeight: FontWeight.bold, ), ), content: Text( '该功能处于开发状态,限时免费使用\n待后续开发完成后,使用需付费激活\n其他功能不受影响。', style: TextStyle( color: isDark ? Colors.grey[300] : Colors.grey[700], ), ), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: Text('确定', style: TextStyle(color: primaryColor)), ), ], ), ); }, ), ], ), body: SingleChildScrollView( padding: const EdgeInsets.all(32), child: Column( children: [ Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(Icons.people, size: 80, color: primaryColor), const SizedBox(width: 32), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '关怀', style: TextStyle( fontSize: 48, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), const SizedBox(height: 16), Text( '用心呵护每一位用户', style: TextStyle( fontSize: 18, color: isDark ? Colors.grey[400] : Colors.grey[600], ), ), ], ), ], ), ), const SizedBox(height: 48), _buildCareModeToggle(isDark, primaryColor), const SizedBox(height: 24), _buildUserTypeSelector(isDark, primaryColor), const SizedBox(height: 24), _buildPinyinToggle(isDark, primaryColor), const SizedBox(height: 24), _buildMultiSelectOptions(isDark, primaryColor), const SizedBox(height: 24), _buildDescriptionArea(isDark), ], ), ), ); } Widget _buildCareModeToggle(bool isDark, Color primaryColor) { return Container( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[100], borderRadius: BorderRadius.circular(16), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '关怀模式', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), Obx( () => Switch( value: _careController.isCareModeEnabled, onChanged: (value) => _careController.toggleCareMode(), activeColor: primaryColor, ), ), ], ), ); } Widget _buildUserTypeSelector(bool isDark, Color primaryColor) { return Container( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[100], borderRadius: BorderRadius.circular(16), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '用户类型', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), const SizedBox(height: 16), Row( children: [ Expanded( child: _buildUserTypeButton( '儿童', _careController.userType == '儿童', isDark, primaryColor, ), ), const SizedBox(width: 16), Expanded( child: _buildUserTypeButton( '学生', _careController.userType == '学生', isDark, primaryColor, ), ), ], ), const SizedBox(height: 16), Container( width: double.infinity, padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: isDark ? const Color(0xFF3A3A3A) : Colors.white, borderRadius: BorderRadius.circular(12), ), child: Obx( () => Text( _careController.userType == '儿童' ? '儿童模式:大字体、简单界面、拼音辅助,适合低龄儿童使用。界面更加卡通化,内容简单易懂,帮助儿童轻松学习诗词。' : '学生模式:适中字体、学习辅助、诗词解析,适合学生群体使用。提供详细的诗词注释、背景知识,助力学生深入理解古典文学。', style: TextStyle( fontSize: 14, height: 1.5, color: isDark ? Colors.grey[300] : Colors.grey[700], ), ), ), ), ], ), ); } Widget _buildUserTypeButton( String label, bool isSelected, bool isDark, Color primaryColor, ) { return GestureDetector( onTap: () => _careController.setUserType(label), child: Container( padding: const EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration( color: isSelected ? primaryColor : (isDark ? const Color(0xFF3A3A3A) : Colors.white), borderRadius: BorderRadius.circular(12), border: Border.all( color: isSelected ? primaryColor : Colors.transparent, width: 2, ), ), child: Center( child: Text( label, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: isSelected ? Colors.white : (isDark ? Colors.white : Colors.black87), ), ), ), ), ); } Widget _buildPinyinToggle(bool isDark, Color primaryColor) { return Container( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[100], borderRadius: BorderRadius.circular(16), ), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '拼音显示', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), Obx( () => Switch( value: _careController.pinyinEnabled, onChanged: (value) => _careController.setPinyinEnabled(value), activeColor: primaryColor, ), ), ], ), const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Text( '朗读', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), const SizedBox(width: 8), IconButton( icon: Icon( Icons.info_outline, color: isDark ? Colors.grey[400] : Colors.grey[600], size: 20, ), onPressed: () { showDialog( context: context, builder: (context) => AlertDialog( backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white, title: Text( '功能说明', style: TextStyle( color: isDark ? Colors.white : Colors.black87, fontWeight: FontWeight.bold, ), ), content: Text( '你使用的设备暂不支持朗读功能\n 等待上游厂商适配TTS.', style: TextStyle( color: isDark ? Colors.grey[300] : Colors.grey[700], ), ), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: Text( '确定', style: TextStyle(color: primaryColor), ), ), ], ), ); }, ), ], ), Switch( value: false, onChanged: null, activeColor: isDark ? Colors.grey[700] : Colors.grey[400], inactiveTrackColor: isDark ? Colors.grey[800] : Colors.grey[300], ), ], ), ], ), ); } Widget _buildMultiSelectOptions(bool isDark, Color primaryColor) { return Container( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), decoration: BoxDecoration( color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[100], borderRadius: BorderRadius.circular(16), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '显示选项', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), const SizedBox(height: 16), Obx( () => Wrap( spacing: 12, runSpacing: 12, children: _options.map((option) { final isSelected = _careController.selectedOptions.contains( option, ); final isPoetry = option == '诗词'; return GestureDetector( onTap: isPoetry ? null : () => _careController.toggleOption(option), child: Container( padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 12, ), decoration: BoxDecoration( color: isSelected ? primaryColor : (isDark ? const Color(0xFF3A3A3A) : Colors.white), borderRadius: BorderRadius.circular(12), border: Border.all( color: isSelected ? primaryColor : Colors.transparent, width: 2, ), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ if (isSelected) Icon(Icons.check, color: Colors.white, size: 20), if (isSelected) const SizedBox(width: 8), Text( option, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: isSelected ? Colors.white : (isDark ? Colors.white : Colors.black87), ), ), ], ), ), ); }).toList(), ), ), ], ), ); } Widget _buildDescriptionArea(bool isDark) { return Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: isDark ? const Color(0xFF2A2A2A) : Colors.grey[100], borderRadius: BorderRadius.circular(16), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '功能说明', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87, ), ), const SizedBox(height: 12), Text( '关怀模式为儿童和学生用户提供更加友好的界面体验。\n\n' '开启关怀模式后,应用将根据选择的用户类型自动调整界面显示。', style: TextStyle( fontSize: 16, height: 1.6, color: isDark ? Colors.grey[300] : Colors.grey[700], ), ), ], ), ); } }