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.
| return Card( | ||
| // 裁剪掉ListTile超出圆角的部分 | ||
| clipBehavior: Clip.antiAlias, | ||
|
|
||
| elevation: 0, | ||
|
|
||
| shape: RoundedRectangleBorder( | ||
| side: BorderSide( | ||
| color: Theme.of(context).colorScheme.outlineVariant, | ||
| ), | ||
| borderRadius: BorderRadius.circular(12), | ||
| ), | ||
|
|
||
| child: ListTile( | ||
| title: Text(info.version), | ||
|
|
||
| subtitle: Text( | ||
| info.path.isNotEmpty ? info.path : '路径未知', | ||
| ), | ||
|
|
||
| trailing: Row( | ||
| mainAxisSize: MainAxisSize.min, | ||
| children: [ | ||
| const Chip(label: Text('系统默认')), | ||
|
|
||
| const SizedBox(width: kDefaultPadding / 2), | ||
|
|
||
| Chip(label: Text(info.vendor ?? 'Unknown')), | ||
| ], | ||
| ), | ||
|
|
||
| onTap: () => _setSystemJava(), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
The system Java card is missing the visual indication when it's selected. Previously, it would highlight with primaryContainer color when _currentJavaPath == 'java' or _currentJavaPath == null. This visual feedback should be restored to indicate which Java is currently active.
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.
| return Text('加载失败:${snapshot.error}'); | ||
| } | ||
|
|
||
| logs = snapshot.data ?? []; |
There was a problem hiding this comment.
FutureBuilder 的 builder 中直接给状态字段赋值 logs = snapshot.data ?? [] 会在 build 过程中产生副作用,且当前会按 SharedPreferences 追加顺序(旧→新)展示日志;旧实现会 reversed 以便新日志优先。建议把 snapshot.data 先转换成局部 final logs = ...(必要时 .reversed.toList()),并用该局部变量渲染列表/控制按钮启用状态,避免在 build 中修改 State 字段。
| logs = snapshot.data ?? []; | |
| final logs = (snapshot.data ?? []).reversed.toList(); |
There was a problem hiding this comment.
我觉得上面是旧的下面是新的更合理点🤔
There was a problem hiding this comment.
我觉得上面是旧的下面是新的更合理点🤔
新日志的显示优先级肯定是比旧日志高的,新→旧明显更合理
There was a problem hiding this comment.
我觉得上面是旧的下面是新的更合理点🤔
新日志的显示优先级肯定是比旧日志高的,新→旧明显更合理
我觉得应该是和控制台一样,新的在下,自动滚动 我觉得可以搞个设置
| // 去重返回 | ||
| return result.toSet().toList(); |
There was a problem hiding this comment.
searchPotentialJavaExecutables() currently returns result.toSet().toList() for deduplication, but JavaRuntime does not override ==/hashCode (identity equality only). This means duplicates will not actually be removed (and order may be unstable). Consider deduping by executable (as之前的 Map 实现) or implement value equality/hashCode in JavaRuntime based on executable (and possibly info.version/isJdk).
| // 去重返回 | |
| return result.toSet().toList(); | |
| // 去重返回(按 executable 路径去重) | |
| final Map<String, JavaRuntime> uniqueByExecutable = {}; | |
| for (final runtime in result) { | |
| // 后出现的同一路径会覆盖先前的,确保最终列表中每个 executable 唯一 | |
| uniqueByExecutable[runtime.executable] = runtime; | |
| } | |
| return uniqueByExecutable.values.toList(); |
| 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的职责内,下个PR会提取出一些组件然后全局替换和做一些代码重构