feat: RsiLauncherEnhanceDialogUI fold DownloaderBoost

This commit is contained in:
xkeyC 2024-05-06 20:22:59 +08:00
parent 34d1007e30
commit 6e823dea9f

View File

@ -46,6 +46,8 @@ class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
final assarState = useState<RSILauncherStateData?>(null); final assarState = useState<RSILauncherStateData?>(null);
final expandEnhance = useState(false);
Future<void> readState() async { Future<void> readState() async {
workingText.value = S.current.tools_rsi_launcher_enhance_init_msg1; workingText.value = S.current.tools_rsi_launcher_enhance_init_msg1;
assarState.value = await _readState(context).unwrap(context: context); assarState.value = await _readState(context).unwrap(context: context);
@ -191,41 +193,83 @@ class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
], ],
)), )),
const SizedBox(height: 3), const SizedBox(height: 3),
if (assarState.value?.enableDownloaderBoost != null) if (assarState.value?.enableDownloaderBoost != null) ...[
Container( IconButton(
padding: const EdgeInsets.all(12), icon: Padding(
margin: const EdgeInsets.only(bottom: 12), padding: const EdgeInsets.only(top: 3, bottom: 3),
decoration: BoxDecoration( child: Row(
color: FluentTheme.of(context).cardColor, children: [
borderRadius: BorderRadius.circular(12), Expanded(
child: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(expandEnhance.value
? FluentIcons.chevron_up
: FluentIcons.chevron_down),
const SizedBox(width: 12),
Text(expandEnhance.value ? "收起额外功能" : "展开额外功能"),
],
))),
],
), ),
child: Row(children: [ ),
Expanded( onPressed: () async {
child: Column( if (!expandEnhance.value) {
crossAxisAlignment: CrossAxisAlignment.start, final userOK = await showConfirmDialogs(
children: [ context,
Text(S.current S.current.tools_rsi_launcher_enhance_note_title,
.tools_rsi_launcher_enhance_title_download_booster), Column(
const SizedBox(height: 3), mainAxisSize: MainAxisSize.min,
Text( children: [
S.current Text(S.current
.tools_rsi_launcher_enhance_subtitle_download_booster, .tools_rsi_launcher_enhance_note_msg),
style: TextStyle( ],
fontSize: 13,
color: Colors.white.withOpacity(.6),
),
), ),
], constraints: BoxConstraints(
)), maxWidth:
ToggleSwitch( MediaQuery.of(context).size.width * .55));
onChanged: (value) { if (!userOK) return;
assarState.value = assarState.value }
?.copyWith(enableDownloaderBoost: value); expandEnhance.value = !expandEnhance.value;
}, },
checked: ),
assarState.value?.enableDownloaderBoost ?? false, if (expandEnhance.value)
) Container(
])), padding: const EdgeInsets.all(12),
margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: FluentTheme.of(context).cardColor,
borderRadius: BorderRadius.circular(12),
),
child: Row(children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(S.current
.tools_rsi_launcher_enhance_title_download_booster),
const SizedBox(height: 3),
Text(
S.current
.tools_rsi_launcher_enhance_subtitle_download_booster,
style: TextStyle(
fontSize: 13,
color: Colors.white.withOpacity(.6),
),
),
],
)),
ToggleSwitch(
onChanged: (value) {
assarState.value = assarState.value
?.copyWith(enableDownloaderBoost: value);
},
checked: assarState.value?.enableDownloaderBoost ??
false,
)
])),
],
const SizedBox(height: 12), const SizedBox(height: 12),
Center( Center(
child: FilledButton( child: FilledButton(
@ -293,8 +337,11 @@ class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
); );
} catch (e) { } catch (e) {
if (!context.mounted) return null; if (!context.mounted) return null;
showToast(context, showToast(
S.current.tools_rsi_launcher_enhance_msg_error_get_launcher_info_error_with_args(e)); context,
S.current
.tools_rsi_launcher_enhance_msg_error_get_launcher_info_error_with_args(
e));
return null; return null;
} }
} }
@ -404,4 +451,4 @@ class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
} }
return scriptBuffer.toString(); return scriptBuffer.toString();
} }
} }