From daf66bd737ec22eb6bcf726990b21c4093a35412 Mon Sep 17 00:00:00 2001 From: DelLevin-Home Date: Tue, 26 May 2026 21:24:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=96=B0=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E9=80=9A=E7=9F=A5=E6=A0=8F=EF=BC=8C?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=95=8C=E9=9D=A2=E5=8A=A0=E5=85=A5=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E8=AF=8D=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 15 + .../top/iletter/mooknote/MainActivity.kt | 24 +- .../main/res/mipmap-hdpi/ic_launcher_m.png | Bin 0 -> 355 bytes .../main/res/mipmap-mdpi/ic_launcher_m.png | Bin 0 -> 239 bytes .../main/res/mipmap-xhdpi/ic_launcher_m.png | Bin 0 -> 447 bytes .../main/res/mipmap-xxhdpi/ic_launcher_m.png | Bin 0 -> 829 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_m.png | Bin 0 -> 1297 bytes assets/icon/app_icon_m.png | Bin 0 -> 12638 bytes lib/main.dart | 9 +- lib/pages/app_icon_picker_page.dart | 104 +++-- lib/pages/movies/movie_detail_page.dart | 37 +- .../movies/movie_review_detail_page.dart | 267 ++++++------ lib/pages/movies/movie_review_form_page.dart | 396 ++++++++++-------- lib/pages/statistics_page.dart | 86 ++++ lib/utils/user_prefs.dart | 4 + lib/widgets/custom_drawer.dart | 21 - tool/generate_icon.dart | 206 +++++++++ 17 files changed, 766 insertions(+), 403 deletions(-) create mode 100644 android/app/src/main/res/mipmap-hdpi/ic_launcher_m.png create mode 100644 android/app/src/main/res/mipmap-mdpi/ic_launcher_m.png create mode 100644 android/app/src/main/res/mipmap-xhdpi/ic_launcher_m.png create mode 100644 android/app/src/main/res/mipmap-xxhdpi/ic_launcher_m.png create mode 100644 android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_m.png create mode 100644 assets/icon/app_icon_m.png create mode 100644 tool/generate_icon.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7c14e19..079b5ad 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -48,6 +48,21 @@ + + + + + + + + { - pm.setComponentEnabledSetting(icon1, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) - pm.setComponentEnabledSetting(icon2, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP) - } - else -> { - pm.setComponentEnabledSetting(icon2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) - pm.setComponentEnabledSetting(icon1, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP) - } + // 先全部禁用 + pm.setComponentEnabledSetting(icon1, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) + pm.setComponentEnabledSetting(icon2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) + pm.setComponentEnabledSetting(icon3, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) + + // 启用选中的 + val target = when (iconName) { + "app_icon2" -> icon2 + "app_icon_m" -> icon3 + else -> icon1 } + pm.setComponentEnabledSetting(target, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP) } private fun getCurrentIcon(): String { val pm = packageManager - val icon1 = ComponentName(this, "${packageName}.MainActivityIcon1") val icon2 = ComponentName(this, "${packageName}.MainActivityIcon2") + val icon3 = ComponentName(this, "${packageName}.MainActivityIcon3") return when { pm.getComponentEnabledSetting(icon2) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED -> "app_icon2" + pm.getComponentEnabledSetting(icon3) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED -> "app_icon_m" else -> "app_icon" } } diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_m.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_m.png new file mode 100644 index 0000000000000000000000000000000000000000..676e4892b4f8ee6854b6a29b5ecde1f1cc04e776 GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@Zgyv2VAS$-aSW-L^Y)e}-(dqD=Zkm# zUwUij@Y>T%^QZKKRh>SzDL0=-+RJ~Iv3-@Ad+`eQO{bOO8`^@VZ*vQpz7>c=*yo6< zlp0QNFm7I=_e89~ZNe4T7-j(nhPUiN(+m3dG*mxfy`!xEK(3PU`w8wH?r{ffH!}a9 z+w)z9wM(o15nn@0W0?32Tlob%4x7E-%;60%TX4~}>@2H>alm^c>olei))iX=zSuNq zG5w9wDiU+J+IX+q^{glBmCw~*<^(weo?pV&^~;K3m*k4CcV7KwxXWPDwWWyPA+)h- zqS8CY6z77bFfg(RIAkeIkg{MXWoW!|fN=#g$C7i4 y^)h>lwJ%)>oWAYYPDZUiE5tXop6uCHvhPxQwOc3kgZbb_s`e z4+bkIw+oDH7a0FCrZdkAE-w7?smqw>1lx+=ycM&yf0Mc(RVX^?Zn}e7iu~l8$qp<5 zKkqc?EchCnX?eWiKGQsbiN!o8n6&O!vKrht#LP28@?&rPVzwTJ8G?lpRvv6;T6V}< n`E|+53d&ho$oe(UN@tEY7MOYV*2AwrA24{j`njxgN@xNAxo=mV literal 0 HcmV?d00001 diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_m.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_m.png new file mode 100644 index 0000000000000000000000000000000000000000..4caabc5fcd1cc2888e270a3d319a5743e988f429 GIT binary patch literal 447 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>U~KbraSW-L^Y+e3-opk0&Vk?W zmjpFklf3jy{6MtA#hULn{%3#Inv}WQc6dwNQ{l-MYBT42EZy>v_s|cv#F}P|o*aDtD4kKvWj%ZcJ1{d*j$p0Hk0)}J6(+4$uI z_Y(Iw1=~+dFJD&YJX86~z|ioozx)NzRkIkcyk}-OaO>x(+YAgF%nz+q40+GQaNwuF z@??#BEDR01li%=N`YXr4aD{i1mDlrV28Ij9r`{OEzGq-?us@J7r_UT{NW*!iHGkIq zu470Jh&o{-9Nl>?{VuYSjx@acQ#ccy}m3>$tvG(XoX#~>raz-RyG z*$)PW4|WZ)EnPqh7BEJ*u6V=9z#zr2+&YfafuW!Wn;-rZFRH3xVCdjwU`SzS5N8lL z@|Zb+fuX6QhJlB{L7<<%fsujZ(MLxE33--g7}aPXA;&TKVWWX$UCEW^J!voOcRl#u VzTxNRqd?a)c)I$ztaD0e0sttutJ?qo literal 0 HcmV?d00001 diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_m.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_m.png new file mode 100644 index 0000000000000000000000000000000000000000..a426ff8bea8bf9905fea96737276af6bee39da1c GIT binary patch literal 829 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q4M;wBd$farftkhA#WAE}&f80#lWqs_ums-y zf9c!4xAQnAwJwrVD$>;YIB|V=-M@q*(LTQ>-k*BQ(_Y4_*~?zQ%h}7G14J-%IeY2% zKI*u1dXdSZFHIVJntMgMl)dzufkNI3Y!-cC(%{q3?U(IfPd?IY$aIL~V?s}Zfs>7d zvO}l@JL649hhFxK@8T00SgusHq?I%3S~zXq-EgQql?&mm!1rD;O@WlL~B8-duEa7g-wUI zRB&ayOpLN&-SWYLw~r~RW)7P>qpt0RGJ8f{dk}fo#J^ZL;NV2F-JCC;DgXTz5WSbB zjlr#*w$;hz>S*&Q=2}h{z_b0K*bx+C`eHJ%Rx9Rxux%xUVTQGRK`njxgN@xNAW7Ss? literal 0 HcmV?d00001 diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_m.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_m.png new file mode 100644 index 0000000000000000000000000000000000000000..c04e9bf98f396a5b38347947ce277c289a5911f8 GIT binary patch literal 1297 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;V7cMx;uumf=j~Z(Ysf_qvGOO*vZ-bCLI|&*SdA z1?LRby=Z&s^R_#0g3%V8U7DvZt$LBBAsko2yyW!L=`nRDLB!GGpQ7iP15BpJe?;Nf zFt{RQ5FCDoi$G9hMFI_g7~9OZ>o~%(vjx?%ki>zdFhIfgzCn!<*g9Q{=h$4W2Qq+PBy0_q%yK z?d%=a4VU-X%E%>LVGOCQe_n3Oz`vm6hW5Vwk7mm?uy4q@arOTCfAiQMFzU#bJ+;@` z|CF(UA-XO0XaA}EN(Q+D+Y-xH>Dfwh@IPP_37I~R2N>+t46%I+qW#+rGFLFfhi#w7 z)66bW%kV|8w!#0i#WW<4;iF^|tTbyzEN~gN=h_)(z`y zFMqZJ%u|%x_by)cb%`ZVu;_+$R+Rs&!^~3_x9{Eb!sknlI8XsH`?bLv(W{F5wzpY7 zFg&&5sdgQz;4h^k#YyEpAhS(v_?LC!(x zA)|^AIh3sp)6%L62Crv~8nf6JWXLrvs$}Rwa6r<(mcMYg^WEpr!p?e7d1OcD#5H)VjWl zPrr8Yk{9kC^EGsT8D5fo>T2(?E7|j6|D<~xx4by+xjskp*ThT4(cN`xz6b|>S-iA6 z>fd}xGb2lar!1_!$a`t#G10pQa}#SW@?P;dE_yfMtUzGN!b1|1sZY-`TCO;rvx#QODrv>gTe~DWM4f)@C^m literal 0 HcmV?d00001 diff --git a/assets/icon/app_icon_m.png b/assets/icon/app_icon_m.png new file mode 100644 index 0000000000000000000000000000000000000000..85437e781c4ae67912b776bb421c73f087061487 GIT binary patch literal 12638 zcmeHOdstIfwm*oET1BR{tq-cvN~N7vafY^;iUC_6m@42SkSYT9s}`MFLa$tc2`6Cf z=ya?iFx6TLs6>Ht5FEWV2;`y8j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GR>Cn zPL#X|qHy_qBi9;$S(-zit%}k?ssrUyk8?BNe-Qj3bW0C23(Q3n>7ON0>;K;u79Jp? z2yoz0`HiF87bCERuN0oCi8>EkY_{CGmkEUGuH7FhTZ>x)u&#(geGw51J4ag-x`aX} z=(XAMsdd~eF!yPwe2*d*J~bxq4Bc{z$^Qk0T`UZ>S23su-ytu2A(oAqh;{w4@VqH- Z^Cw4dED6tf4*)RvlDNe+uWoqne*wf?kVXIi literal 0 HcmV?d00001 diff --git a/lib/main.dart b/lib/main.dart index 28b114d..db902a5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -57,15 +57,21 @@ class _MyAppState extends State with WidgetsBindingObserver { super.initState(); WidgetsBinding.instance.addObserver(this); widget.appProvider.loadThemeMode(); + widget.appProvider.addListener(_onThemeChanged); _updateSystemUI(widget.appProvider.themeMode); } @override void dispose() { + widget.appProvider.removeListener(_onThemeChanged); WidgetsBinding.instance.removeObserver(this); super.dispose(); } + void _onThemeChanged() { + _updateSystemUI(widget.appProvider.themeMode); + } + @override void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { @@ -85,6 +91,8 @@ class _MyAppState extends State with WidgetsBindingObserver { } final isDark = brightness == Brightness.dark; SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark, systemNavigationBarColor: isDark ? const Color(0xFF1A1A1A) : Colors.white, systemNavigationBarIconBrightness: isDark ? Brightness.light : Brightness.dark, )); @@ -100,7 +108,6 @@ class _MyAppState extends State with WidgetsBindingObserver { ], child: Consumer( builder: (context, provider, _) { - _updateSystemUI(provider.themeMode); return MaterialApp( title: 'MookNote', debugShowCheckedModeBanner: false, diff --git a/lib/pages/app_icon_picker_page.dart b/lib/pages/app_icon_picker_page.dart index 5d823de..bd1e749 100644 --- a/lib/pages/app_icon_picker_page.dart +++ b/lib/pages/app_icon_picker_page.dart @@ -18,6 +18,7 @@ class _AppIconPickerPageState extends State { final List> _icons = [ {'name': 'app_icon', 'label': '默认图标'}, {'name': 'app_icon2', 'label': '风格二'}, + {'name': 'app_icon_m', 'label': '风格三'}, ]; @override @@ -28,35 +29,22 @@ class _AppIconPickerPageState extends State { Future _loadCurrentIcon() async { final nativeIcon = await AppIconChannel.getCurrentIcon(); - setState(() { - _currentIconName = nativeIcon; - }); + setState(() => _currentIconName = nativeIcon); } Future _selectIcon(String iconName) async { if (iconName == _currentIconName) return; - try { final success = await AppIconChannel.switchIcon(iconName); - if (success) { await _userPrefs.setAppIconName(iconName); - setState(() { - _currentIconName = iconName; - }); - - if (mounted) { - ToastUtil.show(context, '图标已切换,请返回桌面查看'); - } + setState(() => _currentIconName = iconName); + if (mounted) ToastUtil.show(context, '图标已切换,请返回桌面查看'); } else { - if (mounted) { - ToastUtil.show(context, '图标切换失败'); - } + if (mounted) ToastUtil.show(context, '图标切换失败'); } } catch (e) { - if (mounted) { - ToastUtil.show(context, '切换出错: $e'); - } + if (mounted) ToastUtil.show(context, '切换出错: $e'); } } @@ -64,66 +52,68 @@ class _AppIconPickerPageState extends State { Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return Scaffold( - backgroundColor: colors.surface, + backgroundColor: colors.surfaceContainerHigh, appBar: AppBar( title: const Text('应用图标'), ), - body: GridView.builder( - padding: const EdgeInsets.all(24), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - childAspectRatio: 0.85, - crossAxisSpacing: 16, - mainAxisSpacing: 16, - ), + body: ListView.builder( + padding: const EdgeInsets.symmetric(vertical: 12), itemCount: _icons.length, itemBuilder: (context, index) { final icon = _icons[index]; final isSelected = _currentIconName == icon['name']; - return GestureDetector( + return InkWell( onTap: () => _selectIcon(icon['name']!), child: Container( + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), decoration: BoxDecoration( - color: isSelected ? colors.outlineVariant : colors.surfaceContainerHigh, - borderRadius: BorderRadius.circular(16), + color: colors.surface, + borderRadius: BorderRadius.circular(12), border: Border.all( - color: isSelected ? colors.primary : colors.outlineVariant, - width: isSelected ? 2 : 1, + color: isSelected ? colors.primary : Colors.transparent, + width: isSelected ? 2 : 0, ), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + child: Row( children: [ - Image.asset( - 'assets/icon/${icon['name']}.png', + Container( width: 64, height: 64, - errorBuilder: (context, error, stackTrace) { - return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(14), + border: Border.all(color: colors.outlineVariant, width: 0.5), + ), + clipBehavior: Clip.antiAlias, + child: Image.asset( + 'assets/icon/${icon['name']}.png', + width: 64, + height: 64, + fit: BoxFit.cover, + errorBuilder: (_, __, ___) => Container( width: 64, height: 64, - decoration: BoxDecoration( - color: colors.outlineVariant, - borderRadius: BorderRadius.circular(12), - ), - child: Icon(Icons.image_not_supported, color: colors.onSurface.withValues(alpha: 0.4)), - ); - }, - ), - const SizedBox(height: 12), - Text( - icon['label']!, - style: TextStyle( - fontSize: 14, - fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, - color: colors.onSurface, + color: colors.surfaceContainerHighest, + child: Icon(Icons.image_not_supported, size: 24, color: colors.onSurface.withValues(alpha: 0.3)), + ), ), ), - if (isSelected) ...[ - const SizedBox(height: 4), - Icon(Icons.check_circle, size: 18, color: colors.primary), - ], + const SizedBox(width: 16), + Expanded( + child: Text( + icon['label']!, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w500, + color: colors.onSurface, + ), + ), + ), + if (isSelected) + Icon(Icons.check_circle, size: 22, color: colors.primary) + else + Icon(Icons.radio_button_unchecked, size: 22, color: colors.onSurface.withValues(alpha: 0.2)), ], ), ), diff --git a/lib/pages/movies/movie_detail_page.dart b/lib/pages/movies/movie_detail_page.dart index d94a69a..6948e0a 100644 --- a/lib/pages/movies/movie_detail_page.dart +++ b/lib/pages/movies/movie_detail_page.dart @@ -9,6 +9,7 @@ import 'package:permission_handler/permission_handler.dart'; import '../../providers/app_provider.dart'; import '../../models/data_models.dart'; import '../../utils/toast_util.dart'; +import '../../utils/user_prefs.dart'; import 'movie_reviews_page.dart'; import 'movie_posters_page.dart'; import 'movie_share_page.dart'; @@ -24,15 +25,17 @@ class MovieDetailPage extends StatefulWidget { } class _MovieDetailPageState extends State { + late bool _showExactDate; + @override - void didChangeDependencies() { - super.didChangeDependencies(); - _refreshMovieData(); + void initState() { + super.initState(); + _showExactDate = UserPrefs().showExactReleaseDate; } - void _refreshMovieData() { - final provider = context.read(); - provider.loadMovies(); + void _toggleDateDisplay() { + setState(() => _showExactDate = !_showExactDate); + UserPrefs().setShowExactReleaseDate(_showExactDate); } @override @@ -275,11 +278,23 @@ class _MovieDetailPageState extends State { ), const SizedBox(height: 8), if (movie.releaseDate != null) - Text( - '${movie.releaseDate!.year}年${movie.releaseDate!.month.toString().padLeft(2, '0')}月上映', - style: TextStyle( - fontSize: 14, - color: colors.onSurface.withValues(alpha: 0.4), + GestureDetector( + onTap: _toggleDateDisplay, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + _showExactDate + ? '${movie.releaseDate!.year}年${movie.releaseDate!.month.toString().padLeft(2, '0')}月${movie.releaseDate!.day.toString().padLeft(2, '0')}日上映' + : '${movie.releaseDate!.year}年${movie.releaseDate!.month.toString().padLeft(2, '0')}月上映', + style: TextStyle( + fontSize: 14, + color: colors.onSurface.withValues(alpha: 0.4), + ), + ), + const SizedBox(width: 4), + Icon(Icons.tune, size: 14, color: colors.onSurface.withValues(alpha: 0.2)), + ], ), ), const SizedBox(height: 8), diff --git a/lib/pages/movies/movie_review_detail_page.dart b/lib/pages/movies/movie_review_detail_page.dart index c0a06bb..d769520 100644 --- a/lib/pages/movies/movie_review_detail_page.dart +++ b/lib/pages/movies/movie_review_detail_page.dart @@ -1,7 +1,9 @@ +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../models/data_models.dart'; import '../../providers/app_provider.dart'; +import '../../utils/toast_util.dart'; import 'movie_review_form_page.dart'; /// 影评详情页 @@ -28,162 +30,149 @@ class _MovieReviewDetailPageState extends State { _review = widget.review; } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - _refreshReviewData(); - } - Future _refreshReviewData() async { final provider = context.read(); final reviews = await provider.getMovieReviews(widget.movieId); - final updatedReview = reviews - .where((r) => r.id == widget.review.id) - .firstOrNull; + final updatedReview = reviews.where((r) => r.id == widget.review.id).firstOrNull; if (updatedReview != null && updatedReview.id == _review.id) { - setState(() { - _review = updatedReview; - }); + setState(() => _review = updatedReview); } } - @override - Widget build(BuildContext context) { - final colors = Theme.of(context).colorScheme; - return Scaffold( - backgroundColor: colors.surface, - appBar: AppBar( - title: const Text('影评详情'), - actions: [ - // 编辑按钮 - IconButton( - icon: const Icon(Icons.edit_outlined), - onPressed: () => _navigateToEdit(context), - ), - const SizedBox(width: 8), - ], - ), - body: SingleChildScrollView( - padding: const EdgeInsets.all(24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // 影评内容 - Text( - _review.content, - style: TextStyle( - fontSize: 16, - color: colors.onSurface, - height: 1.8, - ), - ), - - const SizedBox(height: 32), - - // 分隔线 - Container( - height: 0.5, - color: colors.outline, - ), - - const SizedBox(height: 24), - - // 影评人 - _buildInfoRow( - icon: Icons.person_outline, - label: '影评人:', - value: _review.reviewer.isNotEmpty ? _review.reviewer : '匿名', - colors: colors, - ), - - const SizedBox(height: 16), - - // 来源 - if (_review.source.isNotEmpty) - _buildInfoRow( - icon: Icons.source_outlined, - label: '来源:', - value: _review.source, - colors: colors, - ), - - if (_review.source.isNotEmpty) const SizedBox(height: 16), - - // 类型 - _buildInfoRow( - icon: Icons.category_outlined, - label: '类型:', - value: _review.typeText, - colors: colors, - ), - - const SizedBox(height: 16), - - // 时间 - _buildInfoRow( - icon: Icons.access_time, - label: '时间:', - value: _formatDate(_review.createdAt), - colors: colors, - ), - ], - ), - ), - ); + Movie? _getMovie() { + return context.read().movies.where((m) => m.id == widget.movieId).firstOrNull; } - /// 构建信息行 - Widget _buildInfoRow({ - required IconData icon, - required String label, - required String value, - required ColorScheme colors, - }) { - return Row( - children: [ - Icon( - icon, - size: 20, - color: colors.onSurface.withValues(alpha: 0.4), - ), - const SizedBox(width: 12), - // 固定宽度容器,以"影评人:"的最大宽度为准 - SizedBox( - width: 64, - child: Text( - label, - style: TextStyle( - fontSize: 14, - color: colors.onSurface.withValues(alpha: 0.4), - ), + Future _deleteReview() async { + final colors = Theme.of(context).colorScheme; + final confirmed = await showDialog( + context: context, + builder: (ctx) => AlertDialog( + backgroundColor: colors.surface, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + title: Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)), + content: Text('确定要删除这条影评吗?', style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.6))), + actions: [ + TextButton(onPressed: () => Navigator.pop(ctx, false), child: Text('取消', style: TextStyle(color: colors.onSurface.withValues(alpha: 0.5)))), + ElevatedButton( + onPressed: () => Navigator.pop(ctx, true), + style: ElevatedButton.styleFrom(backgroundColor: colors.error, foregroundColor: colors.onError, elevation: 0, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), + child: const Text('删除'), ), - ), - Expanded( - child: Text( - value, - style: TextStyle( - fontSize: 15, - color: colors.onSurface, - ), - ), - ), - ], + ], + ), ); + if (confirmed == true) { + await context.read().removeMovieReview(_review.id); + if (mounted) { ToastUtil.show(context, '已删除'); Navigator.pop(context); } + } + } + + void _navigateToEdit(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (_) => MovieReviewFormPage(movieId: widget.movieId, review: _review)), + ).then((_) => _refreshReviewData()); } String _formatDate(DateTime date) { return '${date.year}.${date.month.toString().padLeft(2, '0')}.${date.day.toString().padLeft(2, '0')}'; } - void _navigateToEdit(BuildContext context) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => MovieReviewFormPage( - movieId: widget.movieId, - review: _review, - ), + @override + Widget build(BuildContext context) { + final colors = Theme.of(context).colorScheme; + final movie = _getMovie(); + + return Scaffold( + backgroundColor: colors.surfaceContainerHigh, + appBar: AppBar( + title: const Text('影评详情'), + actions: [ + IconButton(icon: const Icon(Icons.edit_outlined, size: 20), onPressed: () => _navigateToEdit(context), tooltip: '编辑'), + IconButton(icon: Icon(Icons.delete_outline, size: 20, color: colors.error.withValues(alpha: 0.7)), onPressed: _deleteReview, tooltip: '删除'), + const SizedBox(width: 4), + ], ), - ).then((_) => _refreshReviewData()); + body: SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + // ── 电影信息卡片 ────────────────────── + if (movie != null) _buildMovieCard(movie, colors), + if (movie != null) const SizedBox(height: 16), + + // ── 影评内容卡片 ────────────────────── + _buildContentCard(colors), + const SizedBox(height: 16), + + // ── 元信息卡片 ──────────────────────── + _buildInfoCard(colors), + ]), + ), + ); } + + Widget _buildMovieCard(Movie movie, ColorScheme colors) => Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(12)), + child: Row(children: [ + Container( + width: 52, height: 68, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(6), color: colors.surfaceContainerHighest), + clipBehavior: Clip.antiAlias, + child: movie.posterPath != null + ? Image.file(File(movie.posterPath!), fit: BoxFit.cover, errorBuilder: (_, __, ___) => Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25))) + : Icon(Icons.movie_outlined, size: 22, color: colors.onSurface.withValues(alpha: 0.25)), + ), + const SizedBox(width: 12), + Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(movie.title, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface), maxLines: 2, overflow: TextOverflow.ellipsis), + if (movie.rating != null) ...[const SizedBox(height: 4), Row(children: [ + Icon(Icons.star, size: 14, color: const Color(0xFFFFB800)), + const SizedBox(width: 2), + Text('${movie.rating}', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: colors.onSurface.withValues(alpha: 0.6))), + ])], + ])), + ]), + ); + + Widget _buildContentCard(ColorScheme colors) => Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(12)), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(_review.content, style: TextStyle(fontSize: 16, color: colors.onSurface, height: 1.8)), + const SizedBox(height: 16), + Row(children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3), + decoration: BoxDecoration(color: colors.primary.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(10)), + child: Text(_review.typeText, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color: colors.primary)), + ), + ]), + ]), + ); + + Widget _buildInfoCard(ColorScheme colors) => Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration(color: colors.surface, borderRadius: BorderRadius.circular(12)), + child: Column(children: [ + _infoRow(Icons.person_outline, '影评人', _review.reviewer.isNotEmpty ? _review.reviewer : '匿名', colors), + Divider(height: 24, color: colors.outlineVariant), + if (_review.source.isNotEmpty) ...[ + _infoRow(Icons.link, '来源', _review.source, colors), + const Divider(height: 24), + ], + _infoRow(Icons.access_time, '时间', _formatDate(_review.createdAt), colors), + ]), + ); + + Widget _infoRow(IconData icon, String label, String value, ColorScheme colors) => Row(children: [ + Icon(icon, size: 18, color: colors.onSurface.withValues(alpha: 0.35)), + const SizedBox(width: 10), + Text(label, style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.4))), + const Spacer(), + Text(value, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onSurface)), + ]); } diff --git a/lib/pages/movies/movie_review_form_page.dart b/lib/pages/movies/movie_review_form_page.dart index d995eaf..5941b8c 100644 --- a/lib/pages/movies/movie_review_form_page.dart +++ b/lib/pages/movies/movie_review_form_page.dart @@ -1,19 +1,16 @@ +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../providers/app_provider.dart'; import '../../models/data_models.dart'; import '../../utils/toast_util.dart'; -/// 添加/编辑影评页面 - 极简设计 +/// 添加/编辑影评页面 class MovieReviewFormPage extends StatefulWidget { final String movieId; final MovieReview? review; - const MovieReviewFormPage({ - super.key, - required this.movieId, - this.review, - }); + const MovieReviewFormPage({super.key, required this.movieId, this.review}); @override State createState() => _MovieReviewFormPageState(); @@ -29,11 +26,10 @@ class _MovieReviewFormPageState extends State { @override void initState() { super.initState(); - final review = widget.review; - _contentController = TextEditingController(text: review?.content ?? ''); - _reviewerController = TextEditingController(text: review?.reviewer ?? ''); - _sourceController = TextEditingController(text: review?.source ?? ''); - _reviewType = review?.reviewType ?? 1; + _contentController = TextEditingController(text: widget.review?.content ?? ''); + _reviewerController = TextEditingController(text: widget.review?.reviewer ?? ''); + _sourceController = TextEditingController(text: widget.review?.source ?? ''); + _reviewType = widget.review?.reviewType ?? 1; } @override @@ -44,107 +40,92 @@ class _MovieReviewFormPageState extends State { super.dispose(); } + Movie? _getMovie() { + return context.read().movies.where((m) => m.id == widget.movieId).firstOrNull; + } + + // ═══════════════════════════════════════════════════════════════════ + @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; final isEdit = widget.review != null; + final movie = _getMovie(); return Scaffold( backgroundColor: colors.surface, appBar: AppBar( title: Text(isEdit ? '编辑影评' : '写影评'), - actions: [ - TextButton( - onPressed: _saveReview, - child: const Text( - '保存', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), - ), - ), - const SizedBox(width: 8), - ], ), body: Form( key: _formKey, child: Column( children: [ - // 顶部信息栏 - Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide(color: colors.outline, width: 0.5), - ), - ), - child: Row( - children: [ - // 类型选择 - _buildTypeSelector(colors), - const SizedBox(width: 16), - // 评论人 - Expanded( - child: TextField( - controller: _reviewerController, - style: TextStyle(fontSize: 14, color: colors.onSurface), - decoration: InputDecoration( - hintText: '评论人', - hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)), - border: InputBorder.none, - isDense: true, - contentPadding: EdgeInsets.zero, - ), - ), - ), - const SizedBox(width: 16), - // 来源 - SizedBox( - width: 100, - child: TextField( - controller: _sourceController, - style: TextStyle(fontSize: 14, color: colors.onSurface), - decoration: InputDecoration( - hintText: '来源', - hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)), - border: InputBorder.none, - isDense: true, - contentPadding: EdgeInsets.zero, - ), - ), - ), - ], - ), - ), - - // 评论内容区域 Expanded( - child: TextFormField( - controller: _contentController, - maxLines: null, - expands: true, - textAlignVertical: TextAlignVertical.top, - style: TextStyle( - fontSize: 16, - color: colors.onSurface, - height: 1.7, + child: SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // ── 电影信息卡片 ────────────────── + if (movie != null) _buildMovieCard(movie, colors), + const SizedBox(height: 20), + + // ── 类型选择 ────────────────────── + Text('影评类型', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.5))), + const SizedBox(height: 8), + _buildTypeSelector(colors), + const SizedBox(height: 20), + + // ── 元信息 ──────────────────────── + _buildMetaField( + icon: Icons.person_outline, + hint: '评论人(选填)', + controller: _reviewerController, + colors: colors, + ), + const SizedBox(height: 12), + _buildMetaField( + icon: Icons.link, + hint: '来源(选填)', + controller: _sourceController, + colors: colors, + ), + const SizedBox(height: 20), + + // ── 评论内容 ────────────────────── + Text('评论内容', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.5))), + const SizedBox(height: 8), + _buildContentField(colors), + ], ), - decoration: InputDecoration( - hintText: '写下你的影评...', - hintStyle: TextStyle( - fontSize: 16, - color: colors.onSurface.withValues(alpha: 0.25), + ), + ), + + // ── 底部保存按钮 ────────────────────── + Container( + padding: EdgeInsets.only( + left: 16, right: 16, top: 12, + bottom: MediaQuery.of(context).padding.bottom + 12, + ), + decoration: BoxDecoration( + color: colors.surface, + border: Border(top: BorderSide(color: colors.outlineVariant, width: 0.5)), + ), + child: SizedBox( + width: double.infinity, + height: 48, + child: ElevatedButton( + onPressed: _saveReview, + style: ElevatedButton.styleFrom( + backgroundColor: colors.primary, + foregroundColor: colors.onPrimary, + elevation: 0, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), ), - border: InputBorder.none, - contentPadding: const EdgeInsets.all(16), + child: Text(isEdit ? '更新影评' : '保存影评', + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)), ), - validator: (value) { - if (value == null || value.trim().isEmpty) { - return '请输入评论内容'; - } - return null; - }, ), ), ], @@ -153,84 +134,173 @@ class _MovieReviewFormPageState extends State { ); } - /// 构建类型选择器 - Widget _buildTypeSelector(ColorScheme colors) { - return GestureDetector( - onTap: () => _showTypeSelector(), - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), - decoration: BoxDecoration( - border: Border.all(color: colors.outline), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - _reviewType == 1 ? '短评' : '长评', - style: TextStyle( - fontSize: 13, - color: colors.onSurface.withValues(alpha: 0.6), - ), - ), - const SizedBox(width: 4), - Icon( - Icons.arrow_drop_down, - size: 16, - color: colors.onSurface.withValues(alpha: 0.4), - ), - ], - ), - ), - ); - } + // ═══════════════════════════════════════════════════════════════════ + // 电影信息卡片 + // ═══════════════════════════════════════════════════════════════════ - /// 显示类型选择 - void _showTypeSelector() { - showModalBottomSheet( - context: context, - backgroundColor: Colors.transparent, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), - builder: (context) { - final colors = Theme.of(context).colorScheme; - return Container( - color: colors.surface, - child: SafeArea( + Widget _buildMovieCard(Movie movie, ColorScheme colors) { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: colors.surfaceContainerHighest, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + Container( + width: 56, height: 72, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6), + color: colors.outlineVariant, + ), + clipBehavior: Clip.antiAlias, + child: movie.posterPath != null + ? Image.file(File(movie.posterPath!), fit: BoxFit.cover, + errorBuilder: (_, __, ___) => Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25))) + : Icon(Icons.movie_outlined, size: 24, color: colors.onSurface.withValues(alpha: 0.25)), + ), + const SizedBox(width: 14), + Expanded( child: Column( - mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - ListTile( - title: const Text('短评'), - trailing: _reviewType == 1 - ? Icon(Icons.check, color: colors.onSurface) - : null, - onTap: () { - setState(() => _reviewType = 1); - Navigator.pop(context); - }, - ), - Divider(height: 0.5, color: colors.outline), - ListTile( - title: const Text('长评'), - trailing: _reviewType == 2 - ? Icon(Icons.check, color: colors.onSurface) - : null, - onTap: () { - setState(() => _reviewType = 2); - Navigator.pop(context); - }, - ), + Text(movie.title, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface), maxLines: 2, overflow: TextOverflow.ellipsis), + if (movie.rating != null) ...[ + const SizedBox(height: 4), + Row(children: [ + Icon(Icons.star, size: 14, color: const Color(0xFFFFB800)), + const SizedBox(width: 2), + Text('${movie.rating}', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: colors.onSurface.withValues(alpha: 0.6))), + ]), + ], ], ), ), - ); - }, + ], + ), ); } + // ═══════════════════════════════════════════════════════════════════ + // 类型选择器(分段按钮) + // ═══════════════════════════════════════════════════════════════════ + + Widget _buildTypeSelector(ColorScheme colors) { + return SegmentedButton( + segments: const [ + ButtonSegment(value: 1, label: Text('短评'), icon: Icon(Icons.short_text)), + ButtonSegment(value: 2, label: Text('长评'), icon: Icon(Icons.menu_book)), + ], + selected: {_reviewType}, + onSelectionChanged: (v) => setState(() => _reviewType = v.first), + style: ButtonStyle( + backgroundColor: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.selected)) return colors.primary; + return colors.surfaceContainerHighest; + }), + foregroundColor: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.selected)) return colors.onPrimary; + return colors.onSurface.withValues(alpha: 0.6); + }), + iconColor: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.selected)) return colors.onPrimary; + return colors.onSurface.withValues(alpha: 0.4); + }), + ), + ); + } + + // ═══════════════════════════════════════════════════════════════════ + // 元信息输入 + // ═══════════════════════════════════════════════════════════════════ + + Widget _buildMetaField({ + required IconData icon, + required String hint, + required TextEditingController controller, + required ColorScheme colors, + }) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 14), + decoration: BoxDecoration( + color: colors.surfaceContainerHighest, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + children: [ + Icon(icon, size: 18, color: colors.onSurface.withValues(alpha: 0.35)), + const SizedBox(width: 10), + Expanded( + child: TextField( + controller: controller, + style: TextStyle(fontSize: 14, color: colors.onSurface), + decoration: InputDecoration( + hintText: hint, + hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.3)), + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + contentPadding: const EdgeInsets.symmetric(vertical: 12), + ), + ), + ), + ], + ), + ); + } + + // ═══════════════════════════════════════════════════════════════════ + // 内容输入区 + 字数统计 + // ═══════════════════════════════════════════════════════════════════ + + Widget _buildContentField(ColorScheme colors) { + return Container( + decoration: BoxDecoration( + color: colors.surfaceContainerHighest, + borderRadius: BorderRadius.circular(10), + ), + child: Column( + children: [ + TextFormField( + controller: _contentController, + maxLines: 10, + minLines: 6, + textAlignVertical: TextAlignVertical.top, + style: TextStyle(fontSize: 15, color: colors.onSurface, height: 1.7), + decoration: InputDecoration( + hintText: '写下你的影评...', + hintStyle: TextStyle(fontSize: 15, color: colors.onSurface.withValues(alpha: 0.25)), + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + contentPadding: const EdgeInsets.all(14), + ), + validator: (value) { + if (value == null || value.trim().isEmpty) return '请输入评论内容'; + return null; + }, + ), + Padding( + padding: const EdgeInsets.only(right: 14, bottom: 10), + child: Align( + alignment: Alignment.centerRight, + child: Text( + '${_contentController.text.length} 字', + style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.3)), + ), + ), + ), + ], + ), + ); + } + + // ═══════════════════════════════════════════════════════════════════ + // 保存 + // ═══════════════════════════════════════════════════════════════════ + Future _saveReview() async { - if (!_formKey.currentState!.validate()) { - return; - } + if (!_formKey.currentState!.validate()) return; final now = DateTime.now(); @@ -258,9 +328,7 @@ class _MovieReviewFormPageState extends State { } if (!mounted) return; - ToastUtil.show(context, widget.review == null ? '添加成功' : '更新成功'); - Navigator.pop(context); } } diff --git a/lib/pages/statistics_page.dart b/lib/pages/statistics_page.dart index 89280f8..05abd72 100644 --- a/lib/pages/statistics_page.dart +++ b/lib/pages/statistics_page.dart @@ -1,3 +1,4 @@ +import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/app_provider.dart'; @@ -13,6 +14,7 @@ class StatisticsPage extends StatefulWidget { } class _StatisticsPageState extends State { + int _cloudTabIndex = 0; // 0=影视, 1=书籍, 2=笔记 bool get _showMovies => UserPrefs().showMovieTab; bool get _showBooks => UserPrefs().showBookTab; bool get _showNotes => UserPrefs().showNoteTab; @@ -50,6 +52,8 @@ class _StatisticsPageState extends State { _buildNoteTagDistribution('笔记标签分布', notes), const SizedBox(height: 28), ], + _buildTagCloud(movies, books, notes), + const SizedBox(height: 28), _buildRatingDistribution('评分分布', movies, books), const SizedBox(height: 28), _buildMonthlyTrend(movies, books, notes), @@ -398,6 +402,88 @@ class _StatisticsPageState extends State { return 5 - diff; // index 0..5 where 0=5 months ago, 5=current month } + // ─── 标签词云 ────────────────────────────────────────────────────────── + + Widget _buildTagCloud(List movies, List books, List notes) { + final colors = Theme.of(context).colorScheme; + final tabs = []; + if (_showMovies) tabs.add('影视'); + if (_showBooks) tabs.add('书籍'); + if (_showNotes) tabs.add('笔记'); + if (tabs.isEmpty) return const SizedBox.shrink(); + + // 确保 cloudTabIndex 在有效范围内 + if (_cloudTabIndex >= tabs.length) _cloudTabIndex = 0; + + final tagCounts = {}; + switch (tabs[_cloudTabIndex]) { + case '影视': + for (final m in movies) { for (final g in m.genres) { tagCounts[g] = (tagCounts[g] ?? 0) + 1; } } + break; + case '书籍': + for (final b in books) { for (final g in b.genres) { tagCounts[g] = (tagCounts[g] ?? 0) + 1; } } + break; + case '笔记': + for (final n in notes) { for (final t in n.tags) { tagCounts[t] = (tagCounts[t] ?? 0) + 1; } } + break; + } + + final sorted = tagCounts.entries.toList()..sort((a, b) => b.value.compareTo(a.value)); + if (sorted.isEmpty) return const SizedBox.shrink(); + + final maxCount = sorted.first.value; + final minCount = sorted.last.value; + final range = math.max(maxCount - minCount, 1); + + const cloudColors = [ + Color(0xFFE53935), Color(0xFF4A90D9), Color(0xFF7E57C2), + Color(0xFF66BB6A), Color(0xFFFF8F00), Color(0xFF00ACC1), + Color(0xFF5C6BC0), Color(0xFF26A69A), Color(0xFF8D6E63), + ]; + + return _buildCard( + title: '标签词云', + child: Column(children: [ + // Tab 切换 + Row( + children: tabs.map((t) { + final i = tabs.indexOf(t); + final selected = _cloudTabIndex == i; + return Expanded( + child: GestureDetector( + onTap: () => setState(() => _cloudTabIndex = i), + child: Container( + padding: const EdgeInsets.symmetric(vertical: 8), + margin: EdgeInsets.only(right: i < tabs.length - 1 ? 6 : 0), + decoration: BoxDecoration( + color: selected ? colors.primary : colors.surfaceContainerHighest, + borderRadius: BorderRadius.circular(8), + ), + child: Text(t, textAlign: TextAlign.center, style: TextStyle(fontSize: 13, fontWeight: selected ? FontWeight.w600 : FontWeight.w500, color: selected ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.5))), + ), + ), + ); + }).toList(), + ), + const SizedBox(height: 16), + // 词云 + Wrap( + spacing: 6, + runSpacing: 6, + children: sorted.map((e) { + final ratio = (e.value - minCount) / range; + final fontSize = (12.0 + ratio * 18.0).roundToDouble(); + final c = cloudColors[((ratio * (cloudColors.length - 1)).round()).clamp(0, cloudColors.length - 1)]; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 1), + child: Text(e.key, style: TextStyle(fontSize: fontSize, fontWeight: fontSize > 18 ? FontWeight.w700 : FontWeight.w500, color: c, height: 1.3)), + ); + }).toList(), + ), + ]), + ); + } + // ─── 通用卡片 ──────────────────────────────────────────────────────── Widget _buildCard({required String title, required Widget child}) { diff --git a/lib/utils/user_prefs.dart b/lib/utils/user_prefs.dart index 8c3c1c4..6194e21 100644 --- a/lib/utils/user_prefs.dart +++ b/lib/utils/user_prefs.dart @@ -46,6 +46,10 @@ class UserPrefs { /// 主题模式: 0=跟随系统, 1=浅色, 2=深色 int get themeMode => prefs.getInt('themeMode') ?? 0; Future setThemeMode(int value) => prefs.setInt('themeMode', value); + + /// 上映日期:显示到日(true)/ 显示到月(false) + bool get showExactReleaseDate => prefs.getBool('showExactReleaseDate') ?? true; + Future setShowExactReleaseDate(bool value) => prefs.setBool('showExactReleaseDate', value); /// 是否首次启动 bool get isFirstLaunch => prefs.getBool('isFirstLaunch') ?? true; diff --git a/lib/widgets/custom_drawer.dart b/lib/widgets/custom_drawer.dart index 4e83b28..c7dfc2c 100644 --- a/lib/widgets/custom_drawer.dart +++ b/lib/widgets/custom_drawer.dart @@ -125,27 +125,6 @@ class _CustomDrawerState extends State { _buildProfileStatRow(Icons.menu_book_outlined, bookCount, '阅读'), const SizedBox(height: 12), _buildProfileStatRow(Icons.note_outlined, noteCount, '笔记'), - const SizedBox(height: 14), - Divider(height: 1, color: colors.outlineVariant), - InkWell( - onTap: () { - Navigator.pop(context); - Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsPage())); - }, - borderRadius: BorderRadius.circular(8), - child: Padding( - padding: const EdgeInsets.only(top: 14), - child: Row( - children: [ - Icon(Icons.settings_outlined, size: 16, color: colors.onSurface.withValues(alpha: 0.4)), - const SizedBox(width: 8), - Text('设置', style: TextStyle(fontSize: 13, color: colors.onSurface.withValues(alpha: 0.5))), - const Spacer(), - Icon(Icons.chevron_right, size: 14, color: colors.onSurface.withValues(alpha: 0.2)), - ], - ), - ), - ), ], ), ); diff --git a/tool/generate_icon.dart b/tool/generate_icon.dart new file mode 100644 index 0000000..b185284 --- /dev/null +++ b/tool/generate_icon.dart @@ -0,0 +1,206 @@ +import 'dart:io'; +import 'dart:typed_data'; +import 'dart:math' as math; + +void main() { + final outputDir = Directory('assets/icon'); + if (!outputDir.existsSync()) outputDir.createSync(recursive: true); + + final bytes1024 = generateIcon(1024); + File('${outputDir.path}/app_icon_m.png').writeAsBytesSync(bytes1024); + print('Generated app_icon_m.png (1024×1024)'); + + final androidMipmapDir = 'android/app/src/main/res'; + final densities = { + 'mipmap-mdpi': 48, 'mipmap-hdpi': 72, 'mipmap-xhdpi': 96, + 'mipmap-xxhdpi': 144, 'mipmap-xxxhdpi': 192, + }; + for (final entry in densities.entries) { + final dir = Directory('$androidMipmapDir/${entry.key}'); + if (!dir.existsSync()) dir.createSync(recursive: true); + File('${dir.path}/ic_launcher_m.png').writeAsBytesSync(generateIcon(entry.value)); + print('Generated ${entry.key}/ic_launcher_m.png'); + } + print('Done!'); +} + +Uint8List generateIcon(int size) { + final bm = _Bitmap(size, size); + + // 透明背景 + for (int y = 0; y < size; y++) { + for (int x = 0; x < size; x++) { + bm.setPixel(x, y, 0, 0, 0, 0); + } + } + + // 圆角黑底 + final cr = (size * 0.22).round(); + _fillRoundedRect(bm, 0, 0, size, size, cr, 0, 0, 0, 255); + + // 绘制标准 M + _drawStandardM(bm); + + return _encodePng(bm); +} + +/// 用扫描线 + 区间运算绘制标准 M +void _drawStandardM(_Bitmap bm) { + const int r = 255, g = 255, b = 255, a = 255; + final size = bm.width; + + final letterW = size * 0.36; + final letterH = size * 0.38; + final stroke = letterW * 0.24; + + final cx = size / 2.0; + final cy = size / 2.0; + final hw = letterW / 2.0; + final hh = letterH / 2.0; + final hs = stroke / 2.0; + + final top = cy - hh; + final bot = cy + hh; + final leftOuter = cx - hw - hs; + final leftInner = cx - hw + hs; + final rightInner = cx + hw - hs; + final rightOuter = cx + hw + hs; + final botC = bot; // 对角线与竖笔底边齐平 + + // V 形切口的底端 y + final vBotY = cy - hh * 0.15; + // V 形在 vBotY 处的半宽 + final vBotHW = hw * 0.30; + + final minY = top.floor().clamp(0, size - 1); + final maxY = botC.ceil().clamp(0, size - 1); + + for (int y = minY; y <= maxY; y++) { + // 该行的像素掩码 + final row = List.filled(size, false); + + // ── 填充各部件 ── + + // 左竖笔 + if (y >= top && y <= bot) { + _setRange(row, leftOuter, leftInner); + } + // 右竖笔 + if (y >= top && y <= bot) { + _setRange(row, rightInner, rightOuter); + } + // 左对角线(左边缘从 bar 外缘开始,保持连续无断裂) + if (y >= top && y <= botC) { + final t = (y - top) / (botC - top); + final l = leftOuter + (cx - hs - leftOuter) * t; + final r = leftInner + (cx + hs - leftInner) * t; + _setRange(row, l, r); + } + // 右对角线(右边缘从 bar 外缘开始,保持连续无断裂) + if (y >= top && y <= botC) { + final t = (y - top) / (botC - top); + final l = rightInner + (cx - hs - rightInner) * t; + final r = rightOuter + (cx + hs - rightOuter) * t; + _setRange(row, l, r); + } + // V 形切口(清除中心区域) + if (y >= top && y <= vBotY) { + final vt = (y - top) / (vBotY - top); + final vw = vBotHW * vt; // V 宽度随 y 增大而增大 + _clearRange(row, cx - vw, cx + vw); + } + + // ── 输出 ── + _fillRowFromMask(bm, row, y, r, g, b, a); + } +} + +void _setRange(List row, double from, double to) { + final a = from.round().clamp(0, row.length - 1); + final b = to.round().clamp(0, row.length - 1); + final start = math.min(a, b); + final end = math.max(a, b); + for (int i = start; i <= end; i++) { + row[i] = true; + } +} + +void _clearRange(List row, double from, double to) { + final a = from.round().clamp(0, row.length - 1); + final b = to.round().clamp(0, row.length - 1); + final start = math.min(a, b); + final end = math.max(a, b); + for (int i = start; i <= end; i++) { + row[i] = false; + } +} + +void _fillRowFromMask(_Bitmap bm, List row, int y, int r, int g, int b, int a) { + for (int x = 0; x < row.length; x++) { + if (row[x]) bm.setPixel(x, y, r, g, b, a); + } +} + +// ═══════════════════════════════════════════════════════════════════ + +void _fillRoundedRect(_Bitmap bm, int x, int y, int w, int h, int rr, int r, int g, int b, int a) { + final radius = rr.clamp(0, math.min(w, h) ~/ 2); + for (int dy = 0; dy < h; dy++) { + for (int dx = 0; dx < w; dx++) { + bool inside = true; + if (dx < radius && dy < radius) { + inside = math.sqrt((radius - dx) * (radius - dx) + (radius - dy) * (radius - dy)) <= radius; + } else if (dx >= w - radius && dy < radius) { + inside = math.sqrt((dx - (w - radius - 1)) * (dx - (w - radius - 1)) + (radius - dy) * (radius - dy)) <= radius; + } else if (dx < radius && dy >= h - radius) { + inside = math.sqrt((radius - dx) * (radius - dx) + (dy - (h - radius - 1)) * (dy - (h - radius - 1))) <= radius; + } else if (dx >= w - radius && dy >= h - radius) { + inside = math.sqrt((dx - (w - radius - 1)) * (dx - (w - radius - 1)) + (dy - (h - radius - 1)) * (dy - (h - radius - 1))) <= radius; + } + if (inside) bm.setPixel(x + dx, y + dy, r, g, b, a); + } + } +} + +// ── Bitmap ──────────────────────────────────────────────────────── + +class _Bitmap { + final int width, height; + final Uint8List data; + _Bitmap(this.width, this.height) : data = Uint8List(width * height * 4); + void setPixel(int x, int y, int r, int g, int b, int a) { + if (x < 0 || x >= width || y < 0 || y >= height) return; + final o = (y * width + x) * 4; + data[o] = r; data[o + 1] = g; data[o + 2] = b; data[o + 3] = a; + } +} + +// ── PNG Encoder ─────────────────────────────────────────────────── + +Uint8List _encodePng(_Bitmap bm) { + final w = bm.width, h = bm.height; + final raw = []; + for (int y = 0; y < h; y++) { + raw.add(0); + raw.addAll(bm.data.sublist(y * w * 4, (y + 1) * w * 4)); + } + final deflated = ZLibEncoder().convert(raw); + final buf = BytesBuilder(); + buf.add(_chunk('IHDR', [..._be32(w), ..._be32(h), 8, 6, 0, 0, 0])); + buf.add(_chunk('IDAT', deflated)); + buf.add(_chunk('IEND', [])); + return Uint8List.fromList([137, 80, 78, 71, 13, 10, 26, 10, ...buf.toBytes()]); +} + +List _chunk(String type, List data) { + final body = [...type.codeUnits, ...data]; + return [..._be32(data.length), ...body, ..._be32(_crc32(body))]; +} + +List _be32(int v) => [(v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF]; + +int _crc32(List data) { + int crc = 0xFFFFFFFF; + for (final b in data) { crc ^= b; for (int i = 0; i < 8; i++) crc = (crc & 1) != 0 ? (crc >> 1) ^ 0xEDB88320 : (crc >> 1); } + return crc ^ 0xFFFFFFFF; +}