feat: setting pages重构#10
Conversation
|
关于页面在小窗口会有点溢出,现在最小窗口大小还不是很合理,不过我打算到时候用window_manager来定制窗口样式(去标题栏按钮等),也不在这个PR的职责内了,所以暂时先不管 |
There was a problem hiding this comment.
Pull request overview
This PR refactors the settings pages (SettingPage, AboutPage, ThemePage, LogSettingPage, LogViewerPage, JavaPage) to modernize the UI and improve code structure. The refactor adopts Material Design 3 principles with consistent card styling (elevation 0, outlined borders), replaces separate navigation with a unified drawer-based navigation pattern using IndexedStack for state preservation, and consolidates common styling patterns. The about page is also updated to use the global gAppVersion constant instead of reading from SharedPreferences.
Changes:
- Implemented unified navigation drawer in SettingPage with IndexedStack for state preservation
- Standardized card styling across all settings pages using MD3 guidelines (elevation: 0, outlined borders with colorScheme.outlineVariant)
- Refactored ThemePage to use SegmentedButton for theme mode selection and improved color picker UI
- Enhanced LogViewerPage with FutureBuilder pattern and centralized date formatting
- Improved JavaPage with better variable naming and UI consistency
- Updated AboutPage to use global gAppVersion constant and extracted helper method for card creation
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/pages/setting_page.dart | Replaced card-based navigation with NavigationDrawer and IndexedStack; removed slide navigation |
| lib/pages/setting/theme.dart | Replaced switch-based UI with SegmentedButton; customized color picker to match MD3; changed dialog button from "确定" to "关闭" |
| lib/pages/setting/log_viewer/log_setting.dart | Updated Card styling to MD3 standards; improved layout of log level dropdown |
| lib/pages/setting/log_viewer.dart | Converted to FutureBuilder pattern; added centralized date formatting; removed loading state variable; improved UI layout |
| lib/pages/setting/java.dart | Renamed variables for clarity; refactored UI with consistent card styling; improved code organization with better documentation |
| lib/pages/setting/about.dart | Replaced _appVersion with gAppVersion; extracted _buildCardWithListTile helper method; updated card styling to MD3 standards |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6724292 to
fba6d2b
Compare
fba6d2b to
29d0380
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| child: Text( | ||
| '设备上的Java列表', | ||
| style: Theme.of(context).textTheme.headlineMedium, |
There was a problem hiding this comment.
Java 页面原先 AppBar 上有“刷新”按钮,当前重构后 _refresh() 只在 initState() 调用一次,UI 上不再提供重新扫描/刷新 Java 列表的入口。这会导致用户安装/移除 Java 后只能重启应用才能更新列表。建议在标题区域增加一个刷新 IconButton(类似 LogViewer 的刷新),或提供下拉刷新等触发方式来调用 _refresh()。
| child: Text( | |
| '设备上的Java列表', | |
| style: Theme.of(context).textTheme.headlineMedium, | |
| child: Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
| children: [ | |
| Text( | |
| '设备上的Java列表', | |
| style: Theme.of(context).textTheme.headlineMedium, | |
| ), | |
| IconButton( | |
| icon: const Icon(Icons.refresh), | |
| tooltip: '刷新', | |
| onPressed: _refresh, | |
| ), | |
| ], |
|
啊我还没改好搜索java的( |
搜索Java应该是只打开设置Java的页面才会去搜索吧,我原本的Java搜索是参考hmcl写的 |
|
最近没什么时间摸电脑T_T 所以这个可能会拖比较久 |
没事,我最近也没啥空,甚至今年上半年因为实习之类的都没啥空,不出意外今年上半年最多只能再发一个版 :( |
将系统默认Java的标记从 'java' 改为 'default'(可能会有兼容问题)
|
这个pr我觉得有点职责过重了,java留到下个pr先? |
也可以,这个pr先把setting改完,java相关的另外再开pr吧 |
856d8c1 to
189464d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Expanded( | ||
| child: IndexedStack( | ||
| index: _selectedIndex, | ||
| children: _settingPageItems.map((item) => item.page).toList(), | ||
| ), |
There was a problem hiding this comment.
IndexedStack 会在首次 build 时构建所有子页面并触发它们的 initState。当前设置页的子项里包含 JavaPage(会启动 Java 扫描)和 LogViewerPage(会加载日志),这会让打开设置页就立刻执行这些耗时操作,即使用户没有切换到对应 tab。建议在这里也改用 LazyLoadIndexedStack(项目已在 main.dart 引入)或用 WidgetBuilder 延迟创建页面,避免不必要的初始化与性能开销。
There was a problem hiding this comment.
个人认为打开页面之后加载子页面更合理点
| SizedBox(width: 8), | ||
| Chip(label: Text(javaRuntime.info.vendor ?? 'Unknown')), | ||
| if (isCurrent) ...[ | ||
| Chip(label: Text('当前')), |
There was a problem hiding this comment.
似乎也不是特别必要?毕竟已经有加深颜色作为视觉提示了,加多了一个反而让 Chip 数量对不齐
There was a problem hiding this comment.
加深颜色对于当前的显示不太明显, 我觉得应该找个更好的方案吧


重构后






关于视觉不统一与其他页面与代码复用:
不在这个PR的职责内,下个PR会提取出一些组件然后全局替换和做一些代码重构