功能更新

This commit is contained in:
DelLevin-Home
2026-07-02 19:49:41 +08:00
parent 30a002feb2
commit 24fb7aab55
13 changed files with 475 additions and 177 deletions

View File

@@ -209,8 +209,6 @@ server/ # Python Flask 后端
└── static/ # 静态资源 └── static/ # 静态资源
``` ```
*共 134 个 Dart 源文件8 个 Python 源文件。*
## 数据存储 ## 数据存储
- **数据库位置**`<应用文档目录>/mooknote.db` - **数据库位置**`<应用文档目录>/mooknote.db`

View File

@@ -96,14 +96,14 @@ class _BookReviewsPageState extends State<BookReviewsPage> {
icon: Icon(_isSearching ? Icons.close : Icons.search), icon: Icon(_isSearching ? Icons.close : Icons.search),
onPressed: _toggleSearch, onPressed: _toggleSearch,
), ),
// 添加按钮
IconButton(
icon: const Icon(Icons.add),
onPressed: () => _navigateToAddReview(),
),
const SizedBox(width: 8), const SizedBox(width: 8),
], ],
), ),
floatingActionButton: FloatingActionButton.extended(
onPressed: () => _navigateToAddReview(),
icon: const Icon(Icons.add, size: 20),
label: const Text('添加书评'),
),
body: _isLoading body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: _filteredReviews.isEmpty : _filteredReviews.isEmpty

View File

@@ -99,12 +99,15 @@ class _BookTabPageState extends State<BookTabPage> {
Future<void> _loadFirst() async { Future<void> _loadFirst() async {
final provider = context.read<AppProvider>(); final provider = context.read<AppProvider>();
final isWallMode = provider.bookshelfMode;
final statusIdx = provider.bookStatusIndex; final statusIdx = provider.bookStatusIndex;
_lastStatusIndex = statusIdx; _lastStatusIndex = statusIdx;
_initialized = true; _initialized = true;
final status = _statusMap[statusIdx] ?? 'read'; // 书架模式:不筛选状态,使用用户选择的排序(默认创建时间)
final status = isWallMode ? null : (_statusMap[statusIdx] ?? 'read');
final sortMode = UserPrefs().bookSortMode;
setState(() { _isLoading = true; _offset = 0; _hasMore = true; }); setState(() { _isLoading = true; _offset = 0; _hasMore = true; });
final list = await provider.loadBooksPaged(status: status, offset: 0, sortMode: UserPrefs().bookSortMode); final list = await provider.loadBooksPaged(status: status, offset: 0, sortMode: sortMode);
if (!mounted) return; if (!mounted) return;
setState(() { _items.clear(); _items.addAll(list); _offset = list.length; _hasMore = list.length >= 20; _isLoading = false; }); setState(() { _items.clear(); _items.addAll(list); _offset = list.length; _hasMore = list.length >= 20; _isLoading = false; });
} }
@@ -113,8 +116,10 @@ class _BookTabPageState extends State<BookTabPage> {
if (_isLoading || !_hasMore) return; if (_isLoading || !_hasMore) return;
setState(() => _isLoading = true); setState(() => _isLoading = true);
final provider = context.read<AppProvider>(); final provider = context.read<AppProvider>();
final status = _statusMap[provider.bookStatusIndex] ?? 'read'; final isWallMode = provider.bookshelfMode;
final list = await provider.loadBooksPaged(status: status, offset: _offset, sortMode: UserPrefs().bookSortMode); final status = isWallMode ? null : (_statusMap[provider.bookStatusIndex] ?? 'read');
final sortMode = UserPrefs().bookSortMode;
final list = await provider.loadBooksPaged(status: status, offset: _offset, sortMode: sortMode);
if (!mounted) return; if (!mounted) return;
setState(() { _items.addAll(list); _offset += list.length; _hasMore = list.length >= 20; _isLoading = false; }); setState(() { _items.addAll(list); _offset += list.length; _hasMore = list.length >= 20; _isLoading = false; });
} }
@@ -128,8 +133,9 @@ class _BookTabPageState extends State<BookTabPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isWideContent = Breakpoint.isWideContent(context); final isWideContent = Breakpoint.isWideContent(context);
final provider = context.watch<AppProvider>(); final provider = context.watch<AppProvider>();
final isWallMode = provider.bookshelfMode;
final masterContent = Column(children: [ final masterContent = Column(children: [
const BookStatusBar(), if (!isWallMode) const BookStatusBar(),
Expanded(child: _buildBody(context)), Expanded(child: _buildBody(context)),
]); ]);
@@ -289,13 +295,15 @@ class _BookTabPageState extends State<BookTabPage> {
Widget _buildEmptyState(BuildContext context, int statusIndex) { Widget _buildEmptyState(BuildContext context, int statusIndex) {
final colors = Theme.of(context).colorScheme; final colors = Theme.of(context).colorScheme;
final statusText = ['已读', '在读', '想读'][statusIndex]; final provider = context.read<AppProvider>();
final isWallMode = provider.bookshelfMode;
final statusText = isWallMode ? '' : ['已读', '在读', '想读'][statusIndex];
return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(width: 80, height: 80, Container(width: 80, height: 80,
decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(20)), decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(20)),
child: Icon(Icons.menu_book_outlined, size: 40, color: colors.onSurface.withValues(alpha: 0.25))), child: Icon(Icons.menu_book_outlined, size: 40, color: colors.onSurface.withValues(alpha: 0.25))),
const SizedBox(height: 20), const SizedBox(height: 20),
Text('暂无$statusText的书籍', style: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))), Text(isWallMode ? '暂无书籍' : '暂无$statusText的书籍', style: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))),
])); ]));
} }
} }

View File

@@ -442,19 +442,22 @@ class _EpubDetailPageState extends State<EpubDetailPage> {
Row( Row(
children: [ children: [
Icon(Icons.menu_book_outlined, size: 14, color: colors.primary.withValues(alpha: 0.6)), Icon(Icons.menu_book_outlined, size: 14, color: colors.primary.withValues(alpha: 0.6)),
const Spacer(), const SizedBox(width: 6),
if (excerpt.chapter.isNotEmpty) if (excerpt.chapter.isNotEmpty)
Container( Expanded(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2), child: Container(
decoration: BoxDecoration( padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
color: colors.primary.withValues(alpha: 0.08), decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), color: colors.primary.withValues(alpha: 0.08),
), borderRadius: BorderRadius.circular(8),
child: Text( ),
excerpt.chapter, child: Text(
maxLines: 1, excerpt.chapter,
overflow: TextOverflow.ellipsis, maxLines: 1,
style: TextStyle(fontSize: 9, color: colors.primary.withValues(alpha: 0.7), fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right,
style: TextStyle(fontSize: 9, color: colors.primary.withValues(alpha: 0.7), fontWeight: FontWeight.w500),
),
), ),
), ),
], ],

View File

@@ -296,17 +296,23 @@ class _MainContentPageState extends State<MainContentPage> {
Future.delayed(const Duration(milliseconds: 400), () => _isTabTap = false); Future.delayed(const Duration(milliseconds: 400), () => _isTabTap = false);
}, },
onLongPress: tab.label == '影视' onLongPress: tab.label == '影视'
? () => _showSortMenu(context, '影视排序', UserPrefs().movieSortMode, [ ? () {
(0, '按更新时间排序', Icons.update), final isWallMode = UserPrefs().movieWallMode;
(1, '按创建时间排序', Icons.calendar_today_outlined), _showSortMenu(context, isWallMode ? '影视墙排序' : '影视排序', UserPrefs().movieSortMode, [
(2, '评分排序', Icons.star_outline), (0, '更新时间排序', Icons.update),
], (v) { UserPrefs().setMovieSortMode(v); context.read<AppProvider>().loadMovies(); }) (1, '按创建时间排序', Icons.calendar_today_outlined),
(2, '按评分排序', Icons.star_outline),
], (v) { UserPrefs().setMovieSortMode(v); context.read<AppProvider>().loadMovies(); });
}
: tab.label == '阅读' : tab.label == '阅读'
? () => _showSortMenu(context, '书籍排序', UserPrefs().bookSortMode, [ ? () {
(0, '按更新时间排序', Icons.update), final isWallMode = UserPrefs().bookshelfMode;
(1, '按创建时间排序', Icons.calendar_today_outlined), _showSortMenu(context, isWallMode ? '书架排序' : '书籍排序', UserPrefs().bookSortMode, [
(2, '评分排序', Icons.star_outline), (0, '更新时间排序', Icons.update),
], (v) { UserPrefs().setBookSortMode(v); context.read<AppProvider>().loadBooks(); }) (1, '按创建时间排序', Icons.calendar_today_outlined),
(2, '按评分排序', Icons.star_outline),
], (v) { UserPrefs().setBookSortMode(v); context.read<AppProvider>().loadBooks(); });
}
: tab.label == '笔记' : tab.label == '笔记'
? () => _showSortMenu(context, '笔记排序', UserPrefs().noteSortMode, [ ? () => _showSortMenu(context, '笔记排序', UserPrefs().noteSortMode, [
(0, '按更新时间排序', Icons.update), (0, '按更新时间排序', Icons.update),

View File

@@ -49,13 +49,11 @@ class _MoviePostersPageState extends State<MoviePostersPage> {
backgroundColor: colors.surface, backgroundColor: colors.surface,
appBar: AppBar( appBar: AppBar(
title: const Text('海报墙'), title: const Text('海报墙'),
actions: [ ),
IconButton( floatingActionButton: FloatingActionButton.extended(
icon: const Icon(Icons.add_photo_alternate), onPressed: _pickPoster,
onPressed: _pickPoster, icon: const Icon(Icons.add_photo_alternate, size: 20),
), label: const Text('添加海报'),
const SizedBox(width: 8),
],
), ),
body: _isLoading body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())

View File

@@ -96,14 +96,14 @@ class _MovieReviewsPageState extends State<MovieReviewsPage> {
icon: Icon(_isSearching ? Icons.close : Icons.search), icon: Icon(_isSearching ? Icons.close : Icons.search),
onPressed: _toggleSearch, onPressed: _toggleSearch,
), ),
// 添加按钮
IconButton(
icon: const Icon(Icons.add),
onPressed: () => _navigateToAddReview(),
),
const SizedBox(width: 8), const SizedBox(width: 8),
], ],
), ),
floatingActionButton: FloatingActionButton.extended(
onPressed: () => _navigateToAddReview(),
icon: const Icon(Icons.add, size: 20),
label: const Text('添加影评'),
),
body: _isLoading body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: _filteredReviews.isEmpty : _filteredReviews.isEmpty

View File

@@ -92,12 +92,15 @@ class _MovieTabPageState extends State<MovieTabPage> {
Future<void> _loadFirst() async { Future<void> _loadFirst() async {
final provider = context.read<AppProvider>(); final provider = context.read<AppProvider>();
final isWallMode = provider.movieWallMode;
final statusIdx = provider.movieStatusIndex; final statusIdx = provider.movieStatusIndex;
_lastStatusIndex = statusIdx; _lastStatusIndex = statusIdx;
_initialized = true; _initialized = true;
final status = _statusMap[statusIdx] ?? 'watched'; // 影视墙模式:不筛选状态,使用用户选择的排序(默认创建时间)
final status = isWallMode ? null : (_statusMap[statusIdx] ?? 'watched');
final sortMode = UserPrefs().movieSortMode;
setState(() { _isLoading = true; _offset = 0; _hasMore = true; }); setState(() { _isLoading = true; _offset = 0; _hasMore = true; });
final list = await provider.loadMoviesPaged(status: status, offset: 0, sortMode: UserPrefs().movieSortMode); final list = await provider.loadMoviesPaged(status: status, offset: 0, sortMode: sortMode);
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_items.clear(); _items.clear();
@@ -112,8 +115,10 @@ class _MovieTabPageState extends State<MovieTabPage> {
if (_isLoading || !_hasMore) return; if (_isLoading || !_hasMore) return;
setState(() => _isLoading = true); setState(() => _isLoading = true);
final provider = context.read<AppProvider>(); final provider = context.read<AppProvider>();
final status = _statusMap[provider.movieStatusIndex] ?? 'watched'; final isWallMode = provider.movieWallMode;
final list = await provider.loadMoviesPaged(status: status, offset: _offset, sortMode: UserPrefs().movieSortMode); final status = isWallMode ? null : (_statusMap[provider.movieStatusIndex] ?? 'watched');
final sortMode = UserPrefs().movieSortMode;
final list = await provider.loadMoviesPaged(status: status, offset: _offset, sortMode: sortMode);
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_items.addAll(list); _items.addAll(list);
@@ -142,11 +147,12 @@ class _MovieTabPageState extends State<MovieTabPage> {
final colors = Theme.of(context).colorScheme; final colors = Theme.of(context).colorScheme;
final isWideContent = Breakpoint.isWideContent(context); final isWideContent = Breakpoint.isWideContent(context);
final provider = context.watch<AppProvider>(); final provider = context.watch<AppProvider>();
final isWallMode = provider.movieWallMode;
final masterContent = Column( final masterContent = Column(
children: [ children: [
const MovieStatusBar(), if (!isWallMode) const MovieStatusBar(),
Divider(height: 0.5, thickness: 0.5, color: colors.outlineVariant), if (!isWallMode) Divider(height: 0.5, thickness: 0.5, color: colors.outlineVariant),
Expanded(child: _buildBody(context)), Expanded(child: _buildBody(context)),
], ],
); );
@@ -470,13 +476,15 @@ class _MovieTabPageState extends State<MovieTabPage> {
Widget _buildEmptyState(BuildContext context, int statusIndex) { Widget _buildEmptyState(BuildContext context, int statusIndex) {
final colors = Theme.of(context).colorScheme; final colors = Theme.of(context).colorScheme;
final statusText = ['已看', '在看', '想看'][statusIndex]; final provider = context.read<AppProvider>();
final isWallMode = provider.movieWallMode;
final statusText = isWallMode ? '' : ['已看', '在看', '想看'][statusIndex];
return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ return Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(width: 80, height: 80, Container(width: 80, height: 80,
decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(20)), decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(20)),
child: Icon(Icons.movie_outlined, size: 40, color: colors.onSurface.withValues(alpha: 0.25))), child: Icon(Icons.movie_outlined, size: 40, color: colors.onSurface.withValues(alpha: 0.25))),
const SizedBox(height: 20), const SizedBox(height: 20),
Text('暂无$statusText的影片', style: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))), Text(isWallMode ? '暂无影片' : '暂无$statusText的影片', style: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))),
])); ]));
} }
} }

View File

@@ -679,8 +679,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
try { try {
final now = DateTime.now(); final now = DateTime.now();
if (_isEditing) { if (_isEditing && widget.note != null) {
// 更新现有笔记 // 更新现有笔记(编辑已有笔记)
final updatedNote = widget.note!.copyWith( final updatedNote = widget.note!.copyWith(
title: _titleController.text.trim(), title: _titleController.text.trim(),
content: content, content: content,
@@ -689,8 +689,18 @@ class _NoteFormPageState extends State<NoteFormPage> {
updatedAt: now, updatedAt: now,
); );
await context.read<AppProvider>().updateNote(updatedNote); await context.read<AppProvider>().updateNote(updatedNote);
} else if (_savedNote != null) {
// 自动保存过的新笔记,更新它
final updatedNote = _savedNote!.copyWith(
title: _titleController.text.trim(),
content: content,
tags: _tags,
images: _images,
updatedAt: now,
);
await context.read<AppProvider>().updateNote(updatedNote);
} else { } else {
// 添加新笔记 - 先创建笔记获取ID // 添加新笔记
final noteId = now.millisecondsSinceEpoch.toString(); final noteId = now.millisecondsSinceEpoch.toString();
// 如果有图片需要移动到正确的ID目录 // 如果有图片需要移动到正确的ID目录

View File

@@ -1,5 +1,6 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
@@ -667,6 +668,12 @@ class _ProfilePageState extends State<ProfilePage> with RouteAware {
context, MaterialPageRoute(builder: (_) => const StatisticsPage())) context, MaterialPageRoute(builder: (_) => const StatisticsPage()))
), ),
(Icons.backup_outlined, '备份', () => _showBackupOptions(context)), (Icons.backup_outlined, '备份', () => _showBackupOptions(context)),
(
Icons.delete_outline,
'回收',
() => Navigator.push(
context, MaterialPageRoute(builder: (_) => const RecycleBinPage()))
),
( (
Icons.settings_outlined, Icons.settings_outlined,
'设置', '设置',
@@ -674,10 +681,9 @@ class _ProfilePageState extends State<ProfilePage> with RouteAware {
context, MaterialPageRoute(builder: (_) => const SettingsPage())) context, MaterialPageRoute(builder: (_) => const SettingsPage()))
), ),
( (
Icons.delete_outline, Icons.feedback_outlined,
'回收', '反馈',
() => Navigator.push( () => _showFeedbackDialog(context)
context, MaterialPageRoute(builder: (_) => const RecycleBinPage()))
), ),
]; ];
@@ -753,6 +759,96 @@ class _ProfilePageState extends State<ProfilePage> with RouteAware {
return count.toString(); return count.toString();
} }
// ─── 反馈弹窗 ────────────────────────────────────────────────────────
void _showFeedbackDialog(BuildContext context) {
final colors = Theme.of(context).colorScheme;
final email = 'dellevin99@gmail.com';
showModalBottomSheet(
context: context,
backgroundColor: colors.surface,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16))),
builder: (ctx) => SafeArea(
child: Column(mainAxisSize: MainAxisSize.min, children: [
Container(
width: 36,
height: 4,
margin: const EdgeInsets.only(top: 12, bottom: 16),
decoration: BoxDecoration(
color: colors.onSurface.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(2))),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Align(
alignment: Alignment.centerLeft,
child: Text('反馈',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: colors.onSurface)))),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: colors.surfaceContainerHighest.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
Icon(Icons.email_outlined,
size: 20, color: colors.primary.withValues(alpha: 0.8)),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('作者邮箱',
style: TextStyle(
fontSize: 12,
color: colors.onSurface.withValues(alpha: 0.5))),
const SizedBox(height: 2),
Text(email,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: colors.onSurface)),
],
),
),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: email));
ToastUtil.show(context, '已复制到剪贴板');
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: colors.primary.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(8),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.copy, size: 14, color: colors.primary),
const SizedBox(width: 4),
Text('复制', style: TextStyle(fontSize: 12, color: colors.primary, fontWeight: FontWeight.w600)),
],
),
),
),
],
),
),
),
const SizedBox(height: 16),
]),
),
);
}
// ─── 头像 ──────────────────────────────────────────────────────────── // ─── 头像 ────────────────────────────────────────────────────────────
Future<void> _pickAvatar() async { Future<void> _pickAvatar() async {
@@ -990,7 +1086,7 @@ class _SettingsPageState extends State<SettingsPage> {
height: 0.5, height: 0.5,
indent: 24, indent: 24,
endIndent: 24, endIndent: 24,
color: colors.outlineVariant), color: colors.outlineVariant),
_buildNavigationItem( _buildNavigationItem(
icon: Icons.tune_outlined, icon: Icons.tune_outlined,
title: '功能设置', title: '功能设置',
@@ -2596,6 +2692,8 @@ class _LayoutSettingsPageState extends State<LayoutSettingsPage> {
int _noteLayout = 0; int _noteLayout = 0;
int _movieLayout = 0; int _movieLayout = 0;
int _bookLayout = 0; int _bookLayout = 0;
bool _movieWallMode = false;
bool _bookshelfMode = false;
@override @override
void initState() { void initState() {
@@ -2603,6 +2701,8 @@ class _LayoutSettingsPageState extends State<LayoutSettingsPage> {
_noteLayout = _userPrefs.noteLayoutStyle; _noteLayout = _userPrefs.noteLayoutStyle;
_movieLayout = _userPrefs.movieLayoutStyle; _movieLayout = _userPrefs.movieLayoutStyle;
_bookLayout = _userPrefs.bookLayoutStyle; _bookLayout = _userPrefs.bookLayoutStyle;
_movieWallMode = _userPrefs.movieWallMode;
_bookshelfMode = _userPrefs.bookshelfMode;
} }
@override @override
@@ -2612,63 +2712,168 @@ class _LayoutSettingsPageState extends State<LayoutSettingsPage> {
backgroundColor: colors.surface, backgroundColor: colors.surface,
appBar: AppBar(title: const Text('布局设置')), appBar: AppBar(title: const Text('布局设置')),
body: ListView( body: ListView(
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(vertical: 16),
children: [ children: [
_buildSection( // ── 影视 ──
'影视布局', _buildCategoryHeader(Icons.movie_outlined, '影视', colors.primary),
[ _buildWallSwitch(
ButtonSegment( icon: Icons.wallpaper_outlined,
value: 0, title: '影视墙模式',
icon: Icon(Icons.grid_view_outlined, size: 16), subtitle: '显示全部影片,不区分状态',
label: Text('海报网格', style: TextStyle(fontSize: 12))), value: _movieWallMode,
ButtonSegment( onChanged: (v) => _setWallMode('movie', v),
value: 1, ),
icon: Icon(Icons.view_list_outlined, size: 16), _buildLayoutSelector(
label: Text('列表', style: TextStyle(fontSize: 12))), selected: _movieLayout,
ButtonSegment( options: [
value: 2, (0, Icons.grid_view_outlined, '海报网格'),
icon: Icon(Icons.crop_landscape_outlined, size: 16), (1, Icons.view_list_outlined, '列表'),
label: Text('大图卡片', style: TextStyle(fontSize: 12))), (2, Icons.crop_landscape_outlined, '大图卡片'),
], ],
_movieLayout, onChanged: (v) => _setLayout('movie', v),
(v) => _setLayout('movie', v)), ),
_buildSection( const SizedBox(height: 8),
'阅读布局', Divider(
[ height: 1,
ButtonSegment( indent: 16,
value: 0, endIndent: 16,
icon: Icon(Icons.grid_view_outlined, size: 16), color: colors.outlineVariant.withValues(alpha: 0.5)),
label: Text('封面网格', style: TextStyle(fontSize: 12))), const SizedBox(height: 8),
ButtonSegment(
value: 1, // ── 阅读 ──
icon: Icon(Icons.view_list_outlined, size: 16), _buildCategoryHeader(Icons.menu_book_outlined, '阅读', colors.primary),
label: Text('列表', style: TextStyle(fontSize: 12))), _buildWallSwitch(
], icon: Icons.auto_stories_outlined,
_bookLayout, title: '书架模式',
(v) => _setLayout('book', v)), subtitle: '显示全部书籍,不区分状态',
_buildSection( value: _bookshelfMode,
'笔记布局', onChanged: (v) => _setWallMode('book', v),
[ ),
ButtonSegment( _buildLayoutSelector(
value: 0, selected: _bookLayout,
icon: Icon(Icons.view_list_outlined, size: 16), options: [
label: Text('列表', style: TextStyle(fontSize: 12))), (0, Icons.grid_view_outlined, '海报网格'),
ButtonSegment( (1, Icons.view_list_outlined, '列表'),
value: 1, ],
icon: Icon(Icons.grid_view_outlined, size: 16), onChanged: (v) => _setLayout('book', v),
label: Text('瀑布流', style: TextStyle(fontSize: 12))), ),
ButtonSegment( const SizedBox(height: 8),
value: 2, Divider(
icon: Icon(Icons.timeline_outlined, size: 16), height: 1,
label: Text('时间线', style: TextStyle(fontSize: 12))), indent: 16,
], endIndent: 16,
_noteLayout, color: colors.outlineVariant.withValues(alpha: 0.5)),
(v) => _setLayout('note', v)), const SizedBox(height: 8),
// ── 笔记 ──
_buildCategoryHeader(Icons.note_outlined, '笔记', colors.primary),
_buildLayoutSelector(
selected: _noteLayout,
options: [
(0, Icons.view_list_outlined, '列表'),
(1, Icons.grid_view_outlined, '瀑布流'),
(2, Icons.timeline_outlined, '时间线'),
],
onChanged: (v) => _setLayout('note', v),
),
], ],
), ),
); );
} }
Widget _buildCategoryHeader(IconData icon, String title, Color color) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
child: Row(
children: [
Container(
width: 28,
height: 28,
decoration: BoxDecoration(
color: color.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, size: 16, color: color),
),
const SizedBox(width: 10),
Text(title,
style: TextStyle(
fontSize: 15, fontWeight: FontWeight.w700, color: color)),
],
),
);
}
Widget _buildWallSwitch({
required IconData icon,
required String title,
required String subtitle,
required bool value,
required ValueChanged<bool> onChanged,
}) {
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: colors.surfaceContainerHighest.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: colors.primary.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(10),
),
child: Icon(icon,
size: 20, color: colors.primary.withValues(alpha: 0.8)),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: colors.onSurface)),
const SizedBox(height: 2),
Text(subtitle,
style: TextStyle(
fontSize: 12,
color: colors.onSurface.withValues(alpha: 0.5))),
],
),
),
Switch(
value: value,
onChanged: onChanged,
activeThumbColor: colors.primary,
),
],
),
),
);
}
void _setWallMode(String type, bool value) async {
switch (type) {
case 'movie':
await _userPrefs.setMovieWallMode(value);
setState(() => _movieWallMode = value);
if (mounted) context.read<AppProvider>().setMovieWallMode(value);
case 'book':
await _userPrefs.setBookshelfMode(value);
setState(() => _bookshelfMode = value);
if (mounted) context.read<AppProvider>().setBookshelfMode(value);
}
}
void _setLayout(String type, int value) async { void _setLayout(String type, int value) async {
switch (type) { switch (type) {
case 'note': case 'note':
@@ -2684,46 +2889,64 @@ class _LayoutSettingsPageState extends State<LayoutSettingsPage> {
} }
} }
Widget _buildSection(String title, List<ButtonSegment<int>> segments, Widget _buildLayoutSelector({
int selected, ValueChanged<int> onChanged) { required int selected,
required List<(int, IconData, String)> options,
required ValueChanged<int> onChanged,
}) {
final colors = Theme.of(context).colorScheme; final colors = Theme.of(context).colorScheme;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, children: options.map((opt) {
children: [ final isSelected = selected == opt.$1;
Padding( return Expanded(
padding: const EdgeInsets.only(left: 4, bottom: 8), child: GestureDetector(
child: Text(title, onTap: () => onChanged(opt.$1),
style: TextStyle( child: AnimatedContainer(
fontSize: 11, duration: const Duration(milliseconds: 150),
fontWeight: FontWeight.w600, margin: const EdgeInsets.symmetric(horizontal: 4),
color: colors.onSurface)), padding: const EdgeInsets.symmetric(vertical: 14),
), decoration: BoxDecoration(
SegmentedButton<int>( color: isSelected
segments: segments, ? colors.primary
selected: {selected}, : colors.surfaceContainerHighest.withValues(alpha: 0.5),
onSelectionChanged: (s) => onChanged(s.first), borderRadius: BorderRadius.circular(12),
showSelectedIcon: false, border: Border.all(
style: ButtonStyle( color: isSelected
backgroundColor: WidgetStateProperty.resolveWith((s) => ? colors.primary
s.contains(WidgetState.selected) : colors.outlineVariant.withValues(alpha: 0.5),
? colors.onSurface width: isSelected ? 0 : 0.5,
: colors.surfaceContainerHighest), ),
foregroundColor: WidgetStateProperty.resolveWith((s) => ),
s.contains(WidgetState.selected) child: Column(
? colors.surface mainAxisSize: MainAxisSize.min,
: colors.onSurface.withValues(alpha: 0.6)), children: [
side: WidgetStateProperty.all(BorderSide.none), Icon(
shape: WidgetStateProperty.all(RoundedRectangleBorder( opt.$2,
borderRadius: BorderRadius.circular(10))), size: 22,
padding: WidgetStateProperty.all( color: isSelected
const EdgeInsets.symmetric(vertical: 10)), ? colors.onPrimary
tapTargetSize: MaterialTapTargetSize.shrinkWrap, : colors.onSurface.withValues(alpha: 0.5),
visualDensity: VisualDensity.standard, ),
const SizedBox(height: 6),
Text(
opt.$3,
style: TextStyle(
fontSize: 12,
fontWeight:
isSelected ? FontWeight.w600 : FontWeight.w500,
color: isSelected
? colors.onPrimary
: colors.onSurface.withValues(alpha: 0.5),
),
),
],
),
),
), ),
), );
], }).toList(),
), ),
); );
} }

View File

@@ -62,9 +62,15 @@ class AppProvider extends ChangeNotifier {
// 影视列表布局样式 (0: 网格, 1: 列表, 2: 大图卡片) // 影视列表布局样式 (0: 网格, 1: 列表, 2: 大图卡片)
int _movieLayoutStyle = 0; int _movieLayoutStyle = 0;
// 影视墙模式(不显示分类,按创建时间排序)
bool _movieWallMode = false;
// 阅读选中的状态 (0: 读完1: 在读2: 准备读) // 阅读选中的状态 (0: 读完1: 在读2: 准备读)
int _bookStatusIndex = 0; int _bookStatusIndex = 0;
// 书架模式(不显示分类,按创建时间排序)
bool _bookshelfMode = false;
// 侧边菜单是否打开 // 侧边菜单是否打开
bool _drawerOpen = false; bool _drawerOpen = false;
@@ -95,6 +101,8 @@ class AppProvider extends ChangeNotifier {
void initMainTabIndex() { void initMainTabIndex() {
final userPrefs = UserPrefs(); final userPrefs = UserPrefs();
_movieLayoutStyle = userPrefs.movieLayoutStyle; _movieLayoutStyle = userPrefs.movieLayoutStyle;
_movieWallMode = userPrefs.movieWallMode;
_bookshelfMode = userPrefs.bookshelfMode;
final defaultIndex = userPrefs.defaultMainTabIndex; final defaultIndex = userPrefs.defaultMainTabIndex;
// 确保选中的标签是启用的 // 确保选中的标签是启用的
final showMovie = userPrefs.showMovieTab; final showMovie = userPrefs.showMovieTab;
@@ -164,7 +172,9 @@ class AppProvider extends ChangeNotifier {
Note? get selectedNote => _selectedNote; Note? get selectedNote => _selectedNote;
int get movieStatusIndex => _movieStatusIndex; int get movieStatusIndex => _movieStatusIndex;
int get movieLayoutStyle => _movieLayoutStyle; int get movieLayoutStyle => _movieLayoutStyle;
bool get movieWallMode => _movieWallMode;
int get bookStatusIndex => _bookStatusIndex; int get bookStatusIndex => _bookStatusIndex;
bool get bookshelfMode => _bookshelfMode;
bool get drawerOpen => _drawerOpen; bool get drawerOpen => _drawerOpen;
bool get bottomNavVisible => _bottomNavVisible; bool get bottomNavVisible => _bottomNavVisible;
ThemeMode get themeMode => _themeMode; ThemeMode get themeMode => _themeMode;
@@ -276,11 +286,23 @@ class AppProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void setMovieWallMode(bool enabled) {
_movieWallMode = enabled;
UserPrefs().setMovieWallMode(enabled);
notifyListeners();
}
void setBookStatusIndex(int index) { void setBookStatusIndex(int index) {
_bookStatusIndex = index; _bookStatusIndex = index;
notifyListeners(); notifyListeners();
} }
void setBookshelfMode(bool enabled) {
_bookshelfMode = enabled;
UserPrefs().setBookshelfMode(enabled);
notifyListeners();
}
void toggleDrawer() { void toggleDrawer() {
_drawerOpen = !_drawerOpen; _drawerOpen = !_drawerOpen;
notifyListeners(); notifyListeners();

View File

@@ -165,6 +165,14 @@ class UserPrefs {
int get bookLayoutStyle => prefs.getInt('bookLayoutStyle') ?? 0; int get bookLayoutStyle => prefs.getInt('bookLayoutStyle') ?? 0;
Future<bool> setBookLayoutStyle(int value) => prefs.setInt('bookLayoutStyle', value); Future<bool> setBookLayoutStyle(int value) => prefs.setInt('bookLayoutStyle', value);
/// 影视墙模式(不显示分类,按创建时间排序)
bool get movieWallMode => prefs.getBool('movieWallMode') ?? false;
Future<bool> setMovieWallMode(bool value) => prefs.setBool('movieWallMode', value);
/// 书架模式(不显示分类,按创建时间排序)
bool get bookshelfMode => prefs.getBool('bookshelfMode') ?? false;
Future<bool> setBookshelfMode(bool value) => prefs.setBool('bookshelfMode', value);
// ========== 应用图标设置 ========== // ========== 应用图标设置 ==========
// ========== Markdown 阅读器 ========== // ========== Markdown 阅读器 ==========

View File

@@ -107,9 +107,16 @@ class _TagSidePanelState extends State<TagSidePanel> {
children: [ children: [
Text('标签', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)), Text('标签', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)),
const Spacer(), const Spacer(),
IconButton( GestureDetector(
onPressed: () => Navigator.pop(context), onTap: () => Navigator.pop(context),
icon: Icon(Icons.close, size: 20, color: colors.onSurface.withValues(alpha: 0.6)), child: Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
decoration: BoxDecoration(
color: colors.primary,
borderRadius: BorderRadius.circular(20),
),
child: Text('保存', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: colors.onPrimary)),
),
), ),
], ],
), ),
@@ -160,29 +167,34 @@ class _TagSidePanelState extends State<TagSidePanel> {
), ),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Wrap( child: SizedBox(
spacing: 8, width: double.infinity,
runSpacing: 8, child: Wrap(
children: _selected.map((tag) { spacing: 8,
return Container( runSpacing: 8,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), alignment: WrapAlignment.start,
decoration: BoxDecoration( crossAxisAlignment: WrapCrossAlignment.start,
color: colors.primary, children: _selected.map((tag) {
borderRadius: BorderRadius.circular(16), return Container(
), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
child: GestureDetector( decoration: BoxDecoration(
onTap: () => _toggleTag(tag), color: colors.primary,
child: Row( borderRadius: BorderRadius.circular(16),
mainAxisSize: MainAxisSize.min,
children: [
Text(tag, style: TextStyle(fontSize: 13, color: colors.onPrimary)),
const SizedBox(width: 4),
Icon(Icons.close, size: 14, color: colors.onPrimary),
],
), ),
), child: GestureDetector(
); onTap: () => _toggleTag(tag),
}).toList(), child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(tag, style: TextStyle(fontSize: 13, color: colors.onPrimary)),
const SizedBox(width: 4),
Icon(Icons.close, size: 14, color: colors.onPrimary),
],
),
),
);
}).toList(),
),
), ),
), ),
], ],
@@ -201,6 +213,8 @@ class _TagSidePanelState extends State<TagSidePanel> {
child: Wrap( child: Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.start,
children: widget.allAvailableTags.map((tag) { children: widget.allAvailableTags.map((tag) {
final isSelected = _selected.contains(tag); final isSelected = _selected.contains(tag);
return GestureDetector( return GestureDetector(