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,7 +193,48 @@ class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
], ],
)), )),
const SizedBox(height: 3), const SizedBox(height: 3),
if (assarState.value?.enableDownloaderBoost != null) if (assarState.value?.enableDownloaderBoost != null) ...[
IconButton(
icon: Padding(
padding: const EdgeInsets.only(top: 3, bottom: 3),
child: Row(
children: [
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 ? "收起额外功能" : "展开额外功能"),
],
))),
],
),
),
onPressed: () async {
if (!expandEnhance.value) {
final userOK = await showConfirmDialogs(
context,
S.current.tools_rsi_launcher_enhance_note_title,
Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(S.current
.tools_rsi_launcher_enhance_note_msg),
],
),
constraints: BoxConstraints(
maxWidth:
MediaQuery.of(context).size.width * .55));
if (!userOK) return;
}
expandEnhance.value = !expandEnhance.value;
},
),
if (expandEnhance.value)
Container( Container(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
margin: const EdgeInsets.only(bottom: 12), margin: const EdgeInsets.only(bottom: 12),
@ -222,10 +265,11 @@ class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
assarState.value = assarState.value assarState.value = assarState.value
?.copyWith(enableDownloaderBoost: value); ?.copyWith(enableDownloaderBoost: value);
}, },
checked: checked: assarState.value?.enableDownloaderBoost ??
assarState.value?.enableDownloaderBoost ?? false, 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;
} }
} }