深色模式、首页设置页面和功能优化
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
import 'sp-guide.dart';
|
||||
|
||||
class BeginnerPage extends StatefulWidget {
|
||||
@@ -12,6 +14,7 @@ class BeginnerPage extends StatefulWidget {
|
||||
class _BeginnerPageState extends State<BeginnerPage>
|
||||
with TickerProviderStateMixin {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
late AnimationController _fadeController;
|
||||
late Animation<double> _fadeAnimation;
|
||||
double _progress = 0.0;
|
||||
@@ -266,65 +269,78 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey[50],
|
||||
body: Stack(
|
||||
children: [
|
||||
FadeTransition(
|
||||
opacity: _fadeAnimation,
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
title: const Text(
|
||||
'软件功能',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 17,
|
||||
color: AppConstants.primaryColor,
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
return Scaffold(
|
||||
backgroundColor: isDark ? const Color(0xFF1A1A1A) : Colors.grey[50],
|
||||
body: Stack(
|
||||
children: [
|
||||
FadeTransition(
|
||||
opacity: _fadeAnimation,
|
||||
child: CustomScrollView(
|
||||
controller: _scrollController,
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
title: Text(
|
||||
'软件功能',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 17,
|
||||
color: AppConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
backgroundColor: isDark
|
||||
? const Color(0xFF2A2A2A)
|
||||
: Colors.white,
|
||||
foregroundColor: AppConstants.primaryColor,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
floating: true,
|
||||
snap: true,
|
||||
pinned: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.help_outline),
|
||||
color: AppConstants.primaryColor,
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const SpGuidePage(fromSettings: true),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: AppConstants.primaryColor,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
floating: true,
|
||||
snap: true,
|
||||
pinned: false,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.help_outline),
|
||||
color: AppConstants.primaryColor,
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const SpGuidePage(fromSettings: true),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 100),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return _buildSectionCard(
|
||||
_tutorialSections[index],
|
||||
index,
|
||||
isDark,
|
||||
);
|
||||
},
|
||||
}, childCount: _tutorialSections.length),
|
||||
),
|
||||
],
|
||||
),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 100),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return _buildSectionCard(_tutorialSections[index], index);
|
||||
}, childCount: _tutorialSections.length),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildProgressIndicator(),
|
||||
],
|
||||
),
|
||||
);
|
||||
_buildProgressIndicator(isDark),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildSectionCard(Map<String, dynamic> section, int index) {
|
||||
Widget _buildSectionCard(
|
||||
Map<String, dynamic> section,
|
||||
int index,
|
||||
bool isDark,
|
||||
) {
|
||||
return TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 0.0, end: 1.0),
|
||||
duration: Duration(milliseconds: 300 + (index * 50)),
|
||||
@@ -338,11 +354,13 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
color: isDark
|
||||
? Colors.black.withValues(alpha: 0.3)
|
||||
: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 12,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -376,10 +394,10 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
children: [
|
||||
Text(
|
||||
section['title'],
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black87,
|
||||
color: isDark ? Colors.white : Colors.black87,
|
||||
letterSpacing: -0.3,
|
||||
),
|
||||
),
|
||||
@@ -388,7 +406,7 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
'第 ${index + 1} 部分',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[500],
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
@@ -398,12 +416,19 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildSectionContent(section['features'], section['color']),
|
||||
_buildSectionContent(
|
||||
section['features'],
|
||||
section['color'],
|
||||
isDark,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (index < 4) ...[
|
||||
const Divider(height: 1, color: Color(0xFFF5F5F5)),
|
||||
Divider(
|
||||
height: 1,
|
||||
color: isDark ? Colors.grey[700] : const Color(0xFFF5F5F5),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildPreviewSection(section['title']),
|
||||
_buildPreviewSection(section['title'], isDark),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -412,7 +437,7 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionContent(List<String> features, Color color) {
|
||||
Widget _buildSectionContent(List<String> features, Color color, bool isDark) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: features.map((feature) {
|
||||
@@ -432,7 +457,7 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
feature,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey[700],
|
||||
color: isDark ? Colors.grey[300] : Colors.grey[700],
|
||||
height: 1.5,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
@@ -445,20 +470,20 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewSection(String title) {
|
||||
Widget _buildPreviewSection(String title, bool isDark) {
|
||||
Widget preview;
|
||||
switch (title) {
|
||||
case '首页功能':
|
||||
preview = _buildHomePreview();
|
||||
preview = _buildHomePreview(isDark);
|
||||
break;
|
||||
case '发现页面':
|
||||
preview = _buildDiscoverPreview();
|
||||
preview = _buildDiscoverPreview(isDark);
|
||||
break;
|
||||
case '足迹页面':
|
||||
preview = _buildFootprintPreview();
|
||||
preview = _buildFootprintPreview(isDark);
|
||||
break;
|
||||
case '个人中心':
|
||||
preview = _buildProfilePreview();
|
||||
preview = _buildProfilePreview(isDark);
|
||||
break;
|
||||
default:
|
||||
preview = const SizedBox.shrink();
|
||||
@@ -491,11 +516,11 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHomePreview() {
|
||||
Widget _buildHomePreview(bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
@@ -525,12 +550,15 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey[800],
|
||||
color: isDark ? Colors.white : Colors.grey[800],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'唐·李白',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -540,14 +568,14 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'床前明月光,疑是地上霜。\n举头望明月,低头思故乡。',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[700],
|
||||
color: isDark ? Colors.grey[300] : Colors.grey[700],
|
||||
height: 1.6,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
@@ -557,9 +585,9 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildPreviewAction(Icons.favorite_border, '点赞'),
|
||||
_buildPreviewAction(Icons.bookmark_border, '收藏'),
|
||||
_buildPreviewAction(Icons.share_outlined, '分享'),
|
||||
_buildPreviewAction(Icons.favorite_border, '点赞', isDark),
|
||||
_buildPreviewAction(Icons.bookmark_border, '收藏', isDark),
|
||||
_buildPreviewAction(Icons.share_outlined, '分享', isDark),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -567,11 +595,11 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDiscoverPreview() {
|
||||
Widget _buildDiscoverPreview(bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
@@ -580,16 +608,23 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.search, size: 18, color: Colors.grey[400]),
|
||||
Icon(
|
||||
Icons.search,
|
||||
size: 18,
|
||||
color: isDark ? Colors.grey[500] : Colors.grey[400],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'搜索诗词...',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey[400]),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isDark ? Colors.grey[500] : Colors.grey[400],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -597,27 +632,27 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
_buildPreviewTag('唐诗'),
|
||||
_buildPreviewTag('唐诗', isDark),
|
||||
const SizedBox(width: 8),
|
||||
_buildPreviewTag('宋词'),
|
||||
_buildPreviewTag('宋词', isDark),
|
||||
const SizedBox(width: 8),
|
||||
_buildPreviewTag('元曲'),
|
||||
_buildPreviewTag('元曲', isDark),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildPreviewListItem('将进酒', '李白'),
|
||||
_buildPreviewListItem('将进酒', '李白', isDark),
|
||||
const SizedBox(height: 8),
|
||||
_buildPreviewListItem('水调歌头', '苏轼'),
|
||||
_buildPreviewListItem('水调歌头', '苏轼', isDark),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFootprintPreview() {
|
||||
Widget _buildFootprintPreview(bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
@@ -625,25 +660,25 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildPreviewStat('128', '收藏'),
|
||||
_buildPreviewStat('45', '笔记'),
|
||||
_buildPreviewStat('89', '点赞'),
|
||||
_buildPreviewStat('128', '收藏', isDark),
|
||||
_buildPreviewStat('45', '笔记', isDark),
|
||||
_buildPreviewStat('89', '点赞', isDark),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildPreviewListItem('静夜思', '已收藏'),
|
||||
_buildPreviewListItem('静夜思', '已收藏', isDark),
|
||||
const SizedBox(height: 8),
|
||||
_buildPreviewListItem('春晓', '有笔记'),
|
||||
_buildPreviewListItem('春晓', '有笔记', isDark),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProfilePreview() {
|
||||
Widget _buildProfilePreview(bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
@@ -670,12 +705,15 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey[800],
|
||||
color: isDark ? Colors.white : Colors.grey[800],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Lv.12 · 诗意生活',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -685,9 +723,9 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildPreviewStat('156', '浏览'),
|
||||
_buildPreviewStat('89', '点赞'),
|
||||
_buildPreviewStat('45', '答题'),
|
||||
_buildPreviewStat('156', '浏览', isDark),
|
||||
_buildPreviewStat('89', '点赞', isDark),
|
||||
_buildPreviewStat('45', '答题', isDark),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -695,21 +733,31 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewAction(IconData icon, String label) {
|
||||
Widget _buildPreviewAction(IconData icon, String label, bool isDark) {
|
||||
return Column(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: Colors.grey[600]),
|
||||
Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: TextStyle(fontSize: 11, color: Colors.grey[600])),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewTag(String text) {
|
||||
Widget _buildPreviewTag(String text, bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: AppConstants.primaryColor.withValues(alpha: 0.3),
|
||||
@@ -726,11 +774,11 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewListItem(String title, String subtitle) {
|
||||
Widget _buildPreviewListItem(String title, String subtitle, bool isDark) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
@@ -740,20 +788,23 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[700],
|
||||
color: isDark ? Colors.grey[300] : Colors.grey[700],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewStat(String value, String label) {
|
||||
Widget _buildPreviewStat(String value, String label, bool isDark) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(
|
||||
@@ -765,12 +816,18 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(label, style: TextStyle(fontSize: 11, color: Colors.grey[500])),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[500],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProgressIndicator() {
|
||||
Widget _buildProgressIndicator(bool isDark) {
|
||||
return Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
@@ -783,9 +840,15 @@ class _BeginnerPageState extends State<BeginnerPage>
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
Colors.white.withValues(alpha: 0.95),
|
||||
Colors.white.withValues(alpha: 0.85),
|
||||
Colors.white.withValues(alpha: 0.0),
|
||||
(isDark ? const Color(0xFF1A1A1A) : Colors.white).withValues(
|
||||
alpha: 0.95,
|
||||
),
|
||||
(isDark ? const Color(0xFF1A1A1A) : Colors.white).withValues(
|
||||
alpha: 0.85,
|
||||
),
|
||||
(isDark ? const Color(0xFF1A1A1A) : Colors.white).withValues(
|
||||
alpha: 0.0,
|
||||
),
|
||||
],
|
||||
stops: const [0.0, 0.7, 1.0],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user