Merge pull request #3844 from grummbeer/unify-dialog-tiles

Dialogs Mobile. Cleanup dialogs with radio/checkbox tiles.
This commit is contained in:
RustDesk 2023-03-30 10:29:46 +08:00 committed by GitHub
commit 623bd7cba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 35 deletions

View File

@ -1154,25 +1154,32 @@ class AndroidPermissionManager {
} }
} }
// TODO move this to mobile/widgets.
// Used only for mobile, pages remote, settings, dialog
// TODO remove argument contentPadding, its not used, getToggle() has not
RadioListTile<T> getRadio<T>( RadioListTile<T> getRadio<T>(
String name, T toValue, T curValue, void Function(T?) onChange, String name, T toValue, T curValue, void Function(T?) onChange,
{EdgeInsetsGeometry? contentPadding}) { {EdgeInsetsGeometry? contentPadding}) {
return RadioListTile<T>( return RadioListTile<T>(
contentPadding: contentPadding, contentPadding: contentPadding ?? EdgeInsets.zero,
visualDensity: VisualDensity.compact,
controlAffinity: ListTileControlAffinity.trailing, controlAffinity: ListTileControlAffinity.trailing,
title: Text(translate(name)), title: Text(translate(name)),
value: toValue, value: toValue,
groupValue: curValue, groupValue: curValue,
onChanged: onChange, onChanged: onChange,
dense: true,
); );
} }
// TODO move this to mobile/widgets.
// Used only for mobile, pages remote, settings, dialog
CheckboxListTile getToggle( CheckboxListTile getToggle(
String id, void Function(void Function()) setState, option, name, String id, void Function(void Function()) setState, option, name,
{FFI? ffi}) { {FFI? ffi}) {
final opt = bind.sessionGetToggleOptionSync(id: id, arg: option); final opt = bind.sessionGetToggleOptionSync(id: id, arg: option);
return CheckboxListTile( return CheckboxListTile(
contentPadding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
value: opt, value: opt,
onChanged: (v) { onChanged: (v) {
setState(() { setState(() {
@ -1182,7 +1189,6 @@ CheckboxListTile getToggle(
(ffi ?? gFFI).qualityMonitorModel.checkShowQualityMonitor(id); (ffi ?? gFFI).qualityMonitorModel.checkShowQualityMonitor(id);
} }
}, },
dense: true,
title: Text(translate(name))); title: Text(translate(name)));
} }

View File

@ -696,10 +696,8 @@ class _RemotePageState extends State<RemotePage> {
// return CustomAlertDialog( // return CustomAlertDialog(
// title: Text(translate('Physical Keyboard Input Mode')), // title: Text(translate('Physical Keyboard Input Mode')),
// content: Column(mainAxisSize: MainAxisSize.min, children: [ // content: Column(mainAxisSize: MainAxisSize.min, children: [
// getRadio('Legacy mode', 'legacy', current, setMode, // getRadio('Legacy mode', 'legacy', current, setMode),
// contentPadding: EdgeInsets.zero), // getRadio('Map mode', 'map', current, setMode),
// getRadio('Map mode', 'map', current, setMode,
// contentPadding: EdgeInsets.zero),
// ])); // ]));
// }, clickMaskDismiss: true); // }, clickMaskDismiss: true);
// } // }
@ -1069,7 +1067,6 @@ void showOptions(
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: displays + radios + toggles + more), children: displays + radios + toggles + more),
contentPadding: 0,
); );
}, clickMaskDismiss: true, backDismiss: true); }, clickMaskDismiss: true, backDismiss: true);
} }

View File

@ -502,19 +502,18 @@ void showLanguageSettings(OverlayDialogManager dialogManager) async {
} }
return CustomAlertDialog( return CustomAlertDialog(
title: SizedBox.shrink(), content: Column(
content: Column( children: [
children: [ getRadio('Default', '', lang, setLang),
getRadio('Default', '', lang, setLang), Divider(color: MyTheme.border),
Divider(color: MyTheme.border), ] +
] + langs.map((e) {
langs.map((e) { final key = e[0] as String;
final key = e[0] as String; final name = e[1] as String;
final name = e[1] as String; return getRadio(name, key, lang, setLang);
return getRadio(name, key, lang, setLang); }).toList(),
}).toList(), ),
), );
actions: []);
}, backDismiss: true, clickMaskDismiss: true); }, backDismiss: true, clickMaskDismiss: true);
} catch (e) { } catch (e) {
// //
@ -536,14 +535,12 @@ void showThemeSettings(OverlayDialogManager dialogManager) async {
} }
return CustomAlertDialog( return CustomAlertDialog(
title: SizedBox.shrink(), content: Column(children: [
contentPadding: 10, getRadio('Light', ThemeMode.light, themeMode, setTheme),
content: Column(children: [ getRadio('Dark', ThemeMode.dark, themeMode, setTheme),
getRadio('Light', ThemeMode.light, themeMode, setTheme), getRadio('Follow System', ThemeMode.system, themeMode, setTheme)
getRadio('Dark', ThemeMode.dark, themeMode, setTheme), ]),
getRadio('Follow System', ThemeMode.system, themeMode, setTheme) );
]),
actions: []);
}, backDismiss: true, clickMaskDismiss: true); }, backDismiss: true, clickMaskDismiss: true);
} }

View File

@ -128,12 +128,19 @@ void setTemporaryPasswordLengthDialog(
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate("Set one-time password length")), title: Text(translate("Set one-time password length")),
content: Column( content: Row(
mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: children: lengths
lengths.map((e) => getRadio(e, e, length, setLength)).toList()), .map(
actions: [], (value) => Row(
contentPadding: 14, children: [
Text(value),
Radio(
value: value, groupValue: length, onChanged: setLength),
],
),
)
.toList()),
); );
}, backDismiss: true, clickMaskDismiss: true); }, backDismiss: true, clickMaskDismiss: true);
} }