release
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../constants/app_constants.dart';
|
||||
import '../../services/get/theme_controller.dart';
|
||||
import '../../models/colors/app_colors.dart';
|
||||
import '../../views/profile/theme/app-diy.dart';
|
||||
import '../../views/footprint/collect_notes.dart';
|
||||
import '../../views/profile/app-info.dart';
|
||||
import '../../views/home/care/care-page.dart';
|
||||
import '../../views/profile/guide/beginner_page.dart';
|
||||
import '../../views/active/active_search_page.dart';
|
||||
import '../../views/active/rate.dart';
|
||||
import '../../views/profile/components/entire_page.dart';
|
||||
|
||||
class SuggestionsCard extends StatefulWidget {
|
||||
const SuggestionsCard({super.key});
|
||||
@@ -16,159 +23,389 @@ class SuggestionsCard extends StatefulWidget {
|
||||
class _SuggestionsCardState extends State<SuggestionsCard> {
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
bool _showAlternativeContent = false;
|
||||
final PageController _pageController = PageController();
|
||||
int _currentPage = 0;
|
||||
late List<Map<String, dynamic>> _actionItems;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_shuffleActionItems();
|
||||
}
|
||||
|
||||
/// 随机排序选项
|
||||
void _shuffleActionItems() {
|
||||
_actionItems = [
|
||||
{
|
||||
'title': '主题风格',
|
||||
'subtitle': '自定义应用主题',
|
||||
'icon': Icons.palette,
|
||||
'page': const AppDiyPage(),
|
||||
},
|
||||
{
|
||||
'title': '创建笔记',
|
||||
'subtitle': '快速创建新笔记',
|
||||
'icon': Icons.note_add,
|
||||
'page': const CollectNotesPage(),
|
||||
},
|
||||
{
|
||||
'title': '关怀模式',
|
||||
'subtitle': '大字简洁模式',
|
||||
'icon': Icons.favorite,
|
||||
'page': const CarePage(),
|
||||
},
|
||||
{
|
||||
'title': '使用教程',
|
||||
'subtitle': '软件功能指南',
|
||||
'icon': Icons.menu_book,
|
||||
'page': const BeginnerPage(),
|
||||
},
|
||||
{
|
||||
'title': '诗词搜索',
|
||||
'subtitle': '全站诗词搜索',
|
||||
'icon': Icons.search,
|
||||
'page': const ActiveSearchPage(),
|
||||
},
|
||||
{
|
||||
'title': '调试页面',
|
||||
'subtitle': '活跃数据调试',
|
||||
'icon': Icons.bug_report,
|
||||
'page': const RatePage(),
|
||||
},
|
||||
{
|
||||
'title': ' 搜索设置',
|
||||
'subtitle': '搜索软件内的设置',
|
||||
'icon': Icons.search,
|
||||
'page': const _PlaceholderPage(title: '搜索设置'),
|
||||
},
|
||||
{
|
||||
'title': '统计',
|
||||
'subtitle': '全站数据统计',
|
||||
'icon': Icons.bar_chart,
|
||||
'page': const EntirePage(),
|
||||
},
|
||||
{
|
||||
'title': '了解软件',
|
||||
'subtitle': '查看应用信息',
|
||||
'icon': Icons.info,
|
||||
'page': const AppInfoPage(),
|
||||
},
|
||||
];
|
||||
_actionItems.shuffle();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 导航到页面并添加返回悬浮按钮
|
||||
void _navigateToPage(Widget page) {
|
||||
Get.to(() => _PageWithBackButton(child: page));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkModeRx.value;
|
||||
final themeColor = AppColors.primary;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showAlternativeContent = !_showAlternativeContent;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.settings_suggest,
|
||||
size: 40,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showAlternativeContent = !_showAlternativeContent;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.settings_suggest, size: 40, color: themeColor),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'设置建议',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_showAlternativeContent ? '是否在找,清理数据' : '是否在找,主题风格',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
final nextPage = (_currentPage + 1) % 3;
|
||||
_pageController.animateToPage(
|
||||
nextPage,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
child: Icon(Icons.refresh, color: themeColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(
|
||||
height: 160,
|
||||
child: PageView(
|
||||
controller: _pageController,
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
_currentPage = index;
|
||||
});
|
||||
},
|
||||
children: [
|
||||
// 第一页:随机排序后的前4个选项
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'设置建议',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[0]['title'],
|
||||
_actionItems[0]['subtitle'],
|
||||
_actionItems[0]['icon'],
|
||||
() => _navigateToPage(_actionItems[0]['page']),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[1]['title'],
|
||||
_actionItems[1]['subtitle'],
|
||||
_actionItems[1]['icon'],
|
||||
() => _navigateToPage(_actionItems[1]['page']),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_showAlternativeContent ? '是否在找,清理数据' : '是否在找,主题风格',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[2]['title'],
|
||||
_actionItems[2]['subtitle'],
|
||||
_actionItems[2]['icon'],
|
||||
() => _navigateToPage(_actionItems[2]['page']),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[3]['title'],
|
||||
_actionItems[3]['subtitle'],
|
||||
_actionItems[3]['icon'],
|
||||
() => _navigateToPage(_actionItems[3]['page']),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// 第二页:随机排序后的中间4个选项
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[4]['title'],
|
||||
_actionItems[4]['subtitle'],
|
||||
_actionItems[4]['icon'],
|
||||
() => _navigateToPage(_actionItems[4]['page']),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[5]['title'],
|
||||
_actionItems[5]['subtitle'],
|
||||
_actionItems[5]['icon'],
|
||||
() => _navigateToPage(_actionItems[5]['page']),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[6]['title'],
|
||||
_actionItems[6]['subtitle'],
|
||||
_actionItems[6]['icon'],
|
||||
() => _navigateToPage(_actionItems[6]['page']),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[7]['title'],
|
||||
_actionItems[7]['subtitle'],
|
||||
_actionItems[7]['icon'],
|
||||
() => _navigateToPage(_actionItems[7]['page']),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// 第三页:最后一个选项
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
_actionItems[8]['title'],
|
||||
_actionItems[8]['subtitle'],
|
||||
_actionItems[8]['icon'],
|
||||
() => _navigateToPage(_actionItems[8]['page']),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: Container()),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// 页面指示器
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: _currentPage == 0
|
||||
? themeColor
|
||||
: (isDark ? Colors.grey[600] : Colors.grey[300]),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: _currentPage == 1
|
||||
? themeColor
|
||||
: (isDark ? Colors.grey[600] : Colors.grey[300]),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: _currentPage == 2
|
||||
? themeColor
|
||||
: (isDark ? Colors.grey[600] : Colors.grey[300]),
|
||||
),
|
||||
),
|
||||
Icon(Icons.refresh, color: AppConstants.primaryColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_showAlternativeContent
|
||||
? Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
'清理数据',
|
||||
'管理应用数据',
|
||||
Icons.delete_sweep,
|
||||
Colors.red,
|
||||
() => Get.toNamed('/app-data-guide'),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
'了解软件',
|
||||
'查看应用信息',
|
||||
Icons.info,
|
||||
Colors.purple,
|
||||
() => Get.to(() => const AppInfoPage()),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
'主题风格',
|
||||
'自定义应用主题',
|
||||
Icons.palette,
|
||||
Colors.blue,
|
||||
() => Get.to(() => const AppDiyPage()),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
'创建笔记',
|
||||
'快速创建新笔记',
|
||||
Icons.note_add,
|
||||
Colors.green,
|
||||
() => Get.to(() => const CollectNotesPage()),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildActionButton(
|
||||
String title,
|
||||
String subtitle,
|
||||
IconData icon,
|
||||
Color color,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
final isDark = _themeController.isDarkModeRx.value;
|
||||
final themeColor = AppColors.primary;
|
||||
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: color.withValues(alpha: 0.2), width: 1),
|
||||
color: isDark ? const Color(0xFF333333) : const Color(0xFFF5F5F7),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: themeColor.withValues(alpha: 0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Icon(icon, color: color, size: 24),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: themeColor.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
child: Icon(icon, color: themeColor, size: 20),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -176,3 +413,171 @@ class _SuggestionsCardState extends State<SuggestionsCard> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 页面包装器 - 添加左侧返回悬浮按钮
|
||||
class _PageWithBackButton extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const _PageWithBackButton({required this.child});
|
||||
|
||||
@override
|
||||
State<_PageWithBackButton> createState() => _PageWithBackButtonState();
|
||||
}
|
||||
|
||||
class _PageWithBackButtonState extends State<_PageWithBackButton> {
|
||||
bool _showBackButton = true;
|
||||
Timer? _hideTimer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_startHideTimer();
|
||||
}
|
||||
|
||||
void _startHideTimer() {
|
||||
_hideTimer?.cancel();
|
||||
_hideTimer = Timer(const Duration(seconds: 5), () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_showBackButton = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_hideTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
|
||||
return Obx(() {
|
||||
final isDark = themeController.isDarkModeRx.value;
|
||||
final themeColor = AppColors.primary;
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
// 原始页面内容
|
||||
widget.child,
|
||||
|
||||
// 左侧返回悬浮按钮
|
||||
if (_showBackButton)
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: MediaQuery.of(context).size.height * 0.45,
|
||||
child: GestureDetector(
|
||||
onTap: () => Get.back(),
|
||||
child: AnimatedOpacity(
|
||||
opacity: _showBackButton ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(20),
|
||||
bottomRight: Radius.circular(20),
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(
|
||||
alpha: isDark ? 0.4 : 0.15,
|
||||
),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(2, 0),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: themeColor,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'返回',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// 占位页面 - 用于清理数据功能
|
||||
class _PlaceholderPage extends StatelessWidget {
|
||||
final String title;
|
||||
|
||||
const _PlaceholderPage({required this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
|
||||
return Obx(() {
|
||||
final isDark = themeController.isDarkModeRx.value;
|
||||
final themeColor = AppColors.primary;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
backgroundColor: isDark ? const Color(0xFF1A1A1A) : Colors.white,
|
||||
foregroundColor: isDark ? Colors.white : Colors.black,
|
||||
elevation: 0,
|
||||
),
|
||||
backgroundColor: isDark ? const Color(0xFF121212) : Colors.grey[50],
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.construction,
|
||||
size: 64,
|
||||
color: themeColor.withValues(alpha: 0.5),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'$title 功能开发中',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'敬请期待',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user