2024-03-10 19:44:53 +08:00
|
|
|
|
import 'package:fluent_ui/fluent_ui.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
|
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
|
2024-03-15 00:01:06 +08:00
|
|
|
|
import 'package:starcitizen_doctor/generated/l10n.dart';
|
2024-03-10 19:44:53 +08:00
|
|
|
|
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
|
|
|
|
|
|
|
|
|
class SettingsUI extends HookConsumerWidget {
|
|
|
|
|
const SettingsUI({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final sate = ref.watch(settingsUIModelProvider);
|
|
|
|
|
final model = ref.read(settingsUIModelProvider.notifier);
|
|
|
|
|
return Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
|
height: MediaQuery.of(context).size.height,
|
|
|
|
|
margin: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
2024-03-15 00:01:06 +08:00
|
|
|
|
makeSettingsItem(const Icon(FluentIcons.link, size: 20), S.current.setting_action_create_settings_shortcut,
|
|
|
|
|
subTitle: S.current.setting_action_create_desktop_shortcut, onTap: ()=> model.addShortCut(context)),
|
2024-03-10 19:44:53 +08:00
|
|
|
|
if (ConstConf.isMSE) ...[
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
makeSettingsItem(
|
2024-03-15 00:01:06 +08:00
|
|
|
|
const Icon(FluentIcons.reset_device, size: 20), S.current.setting_action_reset_auto_password_fill,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
subTitle:
|
|
|
|
|
"启用:${sate.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${sate.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${sate.autoLoginEmail} 密码:${sate.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}",
|
|
|
|
|
onTap: ()=> model.onResetAutoLogin(context)),
|
|
|
|
|
],
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
makeSettingsItem(const Icon(FontAwesomeIcons.microchip, size: 20),
|
2024-03-15 00:01:06 +08:00
|
|
|
|
S.current.setting_action_ignore_efficiency_cores_on_launch,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
subTitle:
|
|
|
|
|
"已设置的核心数量:${sate.inputGameLaunchECore} (此功能适用于首页的盒子一键启动 或 工具中的RSI启动器管理员模式,当为 0 时不启用此功能 )",
|
|
|
|
|
onTap:()=> model.setGameLaunchECore(context)),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
makeSettingsItem(const Icon(FluentIcons.folder_open, size: 20),
|
2024-03-15 00:01:06 +08:00
|
|
|
|
S.current.setting_action_set_launcher_file,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
subTitle: sate.customLauncherPath != null
|
|
|
|
|
? "${sate.customLauncherPath}"
|
2024-03-15 00:01:06 +08:00
|
|
|
|
: S.current.setting_action_info_manual_launcher_location_setting,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
onTap: ()=> model.setLauncherPath(context), onDel: () {
|
|
|
|
|
model.delName("custom_launcher_path");
|
|
|
|
|
}),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
makeSettingsItem(const Icon(FluentIcons.game, size: 20),
|
2024-03-15 00:01:06 +08:00
|
|
|
|
S.current.setting_action_set_game_file,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
subTitle: sate.customGamePath != null
|
|
|
|
|
? "${sate.customGamePath}"
|
2024-03-15 00:01:06 +08:00
|
|
|
|
: S.current.setting_action_info_manual_game_location_setting,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
onTap: ()=> model.setGamePath(context), onDel: () {
|
|
|
|
|
model.delName("custom_game_path");
|
|
|
|
|
}),
|
|
|
|
|
const SizedBox(height: 12),
|
2024-03-15 00:01:06 +08:00
|
|
|
|
makeSettingsItem(const Icon(FluentIcons.delete, size: 20), S.current.setting_action_clear_translation_file_cache,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
subTitle:
|
|
|
|
|
"缓存大小 ${(sate.locationCacheSize / 1024 / 1024).toStringAsFixed(2)}MB,清理盒子下载的汉化文件缓存,不会影响已安装的汉化",
|
|
|
|
|
onTap: ()=> model.cleanLocationCache(context)),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
makeSettingsItem(
|
2024-03-15 00:01:06 +08:00
|
|
|
|
const Icon(FluentIcons.speed_high, size: 20), S.current.setting_action_tool_site_access_acceleration,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
onTap: () =>
|
|
|
|
|
model.onChangeToolSiteMirror(!sate.isEnableToolSiteMirrors),
|
|
|
|
|
subTitle:
|
2024-03-15 00:01:06 +08:00
|
|
|
|
S.current.setting_action_info_mirror_server_info,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
onSwitch: model.onChangeToolSiteMirror,
|
|
|
|
|
switchStatus: sate.isEnableToolSiteMirrors),
|
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
makeSettingsItem(
|
2024-03-15 00:01:06 +08:00
|
|
|
|
const Icon(FluentIcons.document_set, size: 20), S.current.setting_action_view_log,
|
2024-03-10 19:44:53 +08:00
|
|
|
|
onTap: () => model.showLogs(),
|
2024-03-15 00:01:06 +08:00
|
|
|
|
subTitle: S.current.setting_action_info_view_log_file),
|
2024-03-10 19:44:53 +08:00
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget makeSettingsItem(Widget icon, String title,
|
|
|
|
|
{String? subTitle,
|
|
|
|
|
VoidCallback? onTap,
|
|
|
|
|
VoidCallback? onDel,
|
|
|
|
|
void Function(bool? b)? onSwitch,
|
|
|
|
|
bool switchStatus = false}) {
|
|
|
|
|
return Button(
|
|
|
|
|
onPressed: onTap,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 12, bottom: 12),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
icon,
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(title),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (subTitle != null) ...[
|
|
|
|
|
const SizedBox(height: 3),
|
|
|
|
|
Text(
|
|
|
|
|
subTitle,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 12, color: Colors.white.withOpacity(.6)),
|
|
|
|
|
)
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (onDel != null) ...[
|
|
|
|
|
Button(
|
|
|
|
|
onPressed: onDel,
|
|
|
|
|
child: const Padding(
|
|
|
|
|
padding: EdgeInsets.all(6),
|
|
|
|
|
child: Icon(FluentIcons.delete),
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
if (onSwitch != null) ...[
|
|
|
|
|
ToggleSwitch(checked: switchStatus, onChanged: onSwitch),
|
|
|
|
|
],
|
|
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
const Icon(FluentIcons.chevron_right),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-03-15 00:01:06 +08:00
|
|
|
|
}
|