深色模式、首页设置页面和功能优化

This commit is contained in:
Developer
2026-04-02 07:06:55 +08:00
parent f0a62ed68b
commit 954d173329
88 changed files with 12157 additions and 7578 deletions

View File

@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../constants/app_constants.dart';
import '../views/footprint/liked_poetry_manager.dart';
import '../widgets/tabbed_nav_app_bar.dart';
@@ -8,6 +7,8 @@ import 'active/active_search_page.dart';
import 'footprint/all_list.dart';
import 'footprint/collect_notes.dart';
import 'footprint/local_jilu.dart';
import '../services/get/favorites_controller.dart';
import '../services/get/theme_controller.dart';
/// 时间: 2026-03-22
/// 功能: 收藏页面
@@ -24,67 +25,78 @@ class FavoritesPage extends StatefulWidget {
class _FavoritesPageState extends State<FavoritesPage>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final List<String> _categories = ['全部', '点赞', '笔记', '推送', '每日一句'];
final TextEditingController _searchBarController = TextEditingController();
bool _isGridView = true;
final controller = Get.put(FavoritesController());
final themeController = Get.find<ThemeController>();
@override
void initState() {
super.initState();
_tabController = TabController(length: _categories.length, vsync: this);
_tabController = TabController(
length: controller.categories.length,
vsync: this,
);
_tabController.addListener(() {
setState(() {});
controller.setCurrentTabIndex(_tabController.index);
});
}
@override
void dispose() {
_tabController.dispose();
_searchBarController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: TabbedNavAppBar.build(
title: '足迹',
tabController: _tabController,
tabLabels: _categories,
tabBarScrollable: true,
tabLabelPadding: const EdgeInsets.symmetric(horizontal: 10),
actions: [
IconButton(
icon: Icon(_isGridView ? Icons.view_list : Icons.grid_view),
onPressed: _toggleViewMode,
),
IconButton(
icon: const Icon(Icons.filter_list),
onPressed: _showFilterOptions,
),
],
),
body: Column(
children: [
_buildSearchBar(),
Expanded(
child: TabBarView(
controller: _tabController,
children: _categories
.map((category) => _buildFavoriteList(category))
.toList(),
return Obx(() {
final isDark = themeController.isDarkMode;
return Scaffold(
backgroundColor: isDark ? const Color(0xFF1A1A1A) : null,
appBar: TabbedNavAppBar.build(
title: '足迹',
tabLabels: controller.categories,
tabController: _tabController,
tabBarScrollable: true,
tabLabelPadding: const EdgeInsets.symmetric(horizontal: 10),
actions: [
IconButton(
icon: Icon(
controller.isGridView.value ? Icons.view_list : Icons.grid_view,
color: isDark ? Colors.white70 : null,
),
onPressed: controller.toggleViewMode,
),
),
],
),
floatingActionButton: _buildFloatingButton(),
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat,
);
IconButton(
icon: Icon(
Icons.filter_list,
color: isDark ? Colors.white70 : null,
),
onPressed: () => controller.showFilterOptions(context),
),
],
),
body: Column(
children: [
_buildSearchBar(controller, isDark),
Expanded(
child: TabBarView(
controller: _tabController,
children: controller.categories
.map((category) => _buildFavoriteList(category, controller))
.toList(),
),
),
],
),
floatingActionButton: _buildFloatingButton(controller),
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat,
);
});
}
Widget _buildFloatingButton() {
final currentIndex = _tabController.index;
final currentCategory = _categories[currentIndex];
Widget _buildFloatingButton(FavoritesController controller) {
final currentCategory =
controller.categories[controller.currentTabIndex.value];
if (currentCategory != '笔记') {
return const SizedBox.shrink();
@@ -92,9 +104,7 @@ class _FavoritesPageState extends State<FavoritesPage>
return FloatingActionButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute<void>(builder: (_) => const CollectNotesPage()),
);
Get.to(const CollectNotesPage());
},
child: const Icon(Icons.add),
backgroundColor: AppConstants.primaryColor,
@@ -103,7 +113,7 @@ class _FavoritesPageState extends State<FavoritesPage>
);
}
Widget _buildSearchBar() {
Widget _buildSearchBar(FavoritesController controller, bool isDark) {
return Container(
margin: EdgeInsets.fromLTRB(
AppConstants.pageHorizontalPadding,
@@ -112,27 +122,31 @@ class _FavoritesPageState extends State<FavoritesPage>
16,
),
decoration: BoxDecoration(
color: Colors.grey[100],
color: isDark ? Colors.grey[850] : Colors.grey[100],
borderRadius: BorderRadius.circular(12),
),
child: TextField(
controller: _searchBarController,
readOnly: true,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => ActiveSearchPage(
initialQuery: _searchBarController.text.trim().isEmpty
? null
: _searchBarController.text.trim(),
),
Get.to(
ActiveSearchPage(
initialQuery: controller.searchQuery.value.isEmpty
? null
: controller.searchQuery.value,
),
);
},
decoration: InputDecoration(
hintText: '点按搜索全站诗词…',
prefixIcon: const Icon(Icons.search, color: Colors.grey),
suffixIcon: Icon(Icons.chevron_right, color: Colors.grey[500]),
hintStyle: TextStyle(color: isDark ? Colors.grey[500] : Colors.grey),
prefixIcon: Icon(
Icons.search,
color: isDark ? Colors.grey[500] : Colors.grey,
),
suffixIcon: Icon(
Icons.chevron_right,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
@@ -143,7 +157,7 @@ class _FavoritesPageState extends State<FavoritesPage>
);
}
Widget _buildFavoriteList(String category) {
Widget _buildFavoriteList(String category, FavoritesController controller) {
// 如果是"全部"标签,显示统一的收藏列表(点赞+笔记)
if (category == '全部') {
return const AllListPage();
@@ -161,77 +175,40 @@ class _FavoritesPageState extends State<FavoritesPage>
// 其他标签显示占位内容,但支持下拉刷新
return RefreshIndicator(
onRefresh: () async {
// 模拟刷新其他分类数据
await Future.delayed(const Duration(milliseconds: 500));
},
onRefresh: controller.refreshContent,
child: _buildPlaceholderContent(category),
);
}
Widget _buildPlaceholderContent(String category) {
final isDark = themeController.isDarkMode;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.category_outlined, size: 64, color: Colors.grey[400]),
Icon(
Icons.category_outlined,
size: 64,
color: isDark ? Colors.grey[600] : Colors.grey[400],
),
const SizedBox(height: 16),
Text(
'$category功能暂未开放',
style: TextStyle(fontSize: 16, color: Colors.grey[600]),
style: TextStyle(
fontSize: 16,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
const SizedBox(height: 8),
Text(
'敬请期待后续更新',
style: TextStyle(fontSize: 14, color: Colors.grey[500]),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
),
],
),
);
}
void _toggleViewMode() {
setState(() {
_isGridView = !_isGridView;
});
}
void _showFilterOptions() {
showModalBottomSheet(
context: context,
builder: (context) => Container(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'筛选选项',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 16),
ListTile(
leading: const Icon(Icons.date_range),
title: const Text('按时间排序'),
onTap: () {
Navigator.pop(context);
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('按时间排序')));
},
),
ListTile(
leading: const Icon(Icons.title),
title: const Text('按标题排序'),
onTap: () {
Navigator.pop(context);
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('按标题排序')));
},
),
],
),
),
);
}
}