Skip to content

feat: setting pages重构#10

Open
futurw4v wants to merge 20 commits intolxdklp:mainfrom
futurw4v:feature/setting_page
Open

feat: setting pages重构#10
futurw4v wants to merge 20 commits intolxdklp:mainfrom
futurw4v:feature/setting_page

Conversation

@futurw4v
Copy link
Contributor

  1. 重构了SettingPage AboutPage ThemePage LogSettingPage LogViewerPage JavaPage,优化样式与代码结构
  2. 更改了about页面里的版权信息

重构后
image
image
image
image
image
image

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

@futurw4v
Copy link
Contributor Author

futurw4v commented Feb 19, 2026

关于页面在小窗口会有点溢出,现在最小窗口大小还不是很合理,不过我打算到时候用window_manager来定制窗口样式(去标题栏按钮等),也不在这个PR的职责内了,所以暂时先不管

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 131 to 164
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(),
),
);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

搜索java好像有点问题?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

分割符的问题,改了不过还没改完

@futurw4v futurw4v force-pushed the feature/setting_page branch from 6724292 to fba6d2b Compare February 20, 2026 15:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?? [];
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FutureBuilder 的 builder 中直接给状态字段赋值 logs = snapshot.data ?? [] 会在 build 过程中产生副作用,且当前会按 SharedPreferences 追加顺序(旧→新)展示日志;旧实现会 reversed 以便新日志优先。建议把 snapshot.data 先转换成局部 final logs = ...(必要时 .reversed.toList()),并用该局部变量渲染列表/控制按钮启用状态,避免在 build 中修改 State 字段。

Suggested change
logs = snapshot.data ?? [];
final logs = (snapshot.data ?? []).reversed.toList();

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得上面是旧的下面是新的更合理点🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得上面是旧的下面是新的更合理点🤔

新日志的显示优先级肯定是比旧日志高的,新→旧明显更合理

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得上面是旧的下面是新的更合理点🤔

新日志的显示优先级肯定是比旧日志高的,新→旧明显更合理

我觉得应该是和控制台一样,新的在下,自动滚动 我觉得可以搞个设置

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

实现起来比较麻烦,必要性不高,直接新的在前就行了

Comment on lines +109 to +110
// 去重返回
return result.toSet().toList();
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
// 去重返回
return result.toSet().toList();
// 去重返回(按 executable 路径去重)
final Map<String, JavaRuntime> uniqueByExecutable = {};
for (final runtime in result) {
// 后出现的同一路径会覆盖先前的,确保最终列表中每个 executable 唯一
uniqueByExecutable[runtime.executable] = runtime;
}
return uniqueByExecutable.values.toList();

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +63
child: Text(
'设备上的Java列表',
style: Theme.of(context).textTheme.headlineMedium,
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 页面原先 AppBar 上有“刷新”按钮,当前重构后 _refresh() 只在 initState() 调用一次,UI 上不再提供重新扫描/刷新 Java 列表的入口。这会导致用户安装/移除 Java 后只能重启应用才能更新列表。建议在标题区域增加一个刷新 IconButton(类似 LogViewer 的刷新),或提供下拉刷新等触发方式来调用 _refresh()

Suggested change
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,
),
],

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一块可能会重写

@futurw4v
Copy link
Contributor Author

啊我还没改好搜索java的(
我想的是遍历
但是每次启动都遍历有点吃性能

@lxdklp
Copy link
Owner

lxdklp commented Feb 21, 2026

啊我还没改好搜索java的(
我想的是遍历
但是每次启动都遍历有点吃性能

搜索Java应该是只打开设置Java的页面才会去搜索吧,我原本的Java搜索是参考hmcl写的

@futurw4v
Copy link
Contributor Author

最近没什么时间摸电脑T_T 所以这个可能会拖比较久

@lxdklp
Copy link
Owner

lxdklp commented Feb 23, 2026

最近没什么时间摸电脑T_T 所以这个可能会拖比较久

没事,我最近也没啥空,甚至今年上半年因为实习之类的都没啥空,不出意外今年上半年最多只能再发一个版 :(

将系统默认Java的标记从 'java' 改为 'default'(可能会有兼容问题)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants