opt dialog style
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
d2c5ba058d
commit
dec1820694
@ -613,6 +613,7 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
Future.delayed(Duration.zero, () {
|
||||
if (!scopeNode.hasFocus) scopeNode.requestFocus();
|
||||
});
|
||||
const double padding = 16;
|
||||
return FocusScope(
|
||||
node: scopeNode,
|
||||
autofocus: true,
|
||||
@ -637,8 +638,8 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
child: AlertDialog(
|
||||
scrollable: true,
|
||||
title: title,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: contentPadding ?? 25, vertical: 10),
|
||||
contentPadding: EdgeInsets.fromLTRB(
|
||||
contentPadding ?? padding, 25, contentPadding ?? padding, 10),
|
||||
content: ConstrainedBox(
|
||||
constraints: contentBoxConstraints,
|
||||
child: Theme(
|
||||
@ -648,6 +649,7 @@ class CustomAlertDialog extends StatelessWidget {
|
||||
),
|
||||
child: content)),
|
||||
actions: actions,
|
||||
actionsPadding: EdgeInsets.fromLTRB(0, 0, padding, padding),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -701,9 +703,8 @@ void msgBox(String id, String type, String title, String text, String link,
|
||||
}
|
||||
dialogManager.show(
|
||||
(setState, close) => CustomAlertDialog(
|
||||
title: _msgBoxTitle(title),
|
||||
content:
|
||||
SelectableText(translate(text), style: const TextStyle(fontSize: 15)),
|
||||
title: null,
|
||||
content: msgboxContent(type, title, text),
|
||||
actions: buttons,
|
||||
onSubmit: hasOk ? submit : null,
|
||||
onCancel: hasCancel == true ? cancel : null,
|
||||
@ -712,30 +713,74 @@ void msgBox(String id, String type, String title, String text, String link,
|
||||
);
|
||||
}
|
||||
|
||||
Widget msgBoxButton(String text, void Function() onPressed) {
|
||||
return ButtonTheme(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
//limits the touch area to the button area
|
||||
minWidth: 0,
|
||||
//wraps child's width
|
||||
height: 0,
|
||||
child: TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: onPressed,
|
||||
child:
|
||||
Text(translate(text), style: TextStyle(color: MyTheme.accent))));
|
||||
Color? _msgboxColor(String type) {
|
||||
if (type == "input-password" || type == "custom-os-password") {
|
||||
return Color(0xFFAD448E);
|
||||
}
|
||||
if (type.contains("success")) {
|
||||
return Color(0xFF32bea6);
|
||||
}
|
||||
if (type.contains("error") || type == "re-input-password") {
|
||||
return Color(0xFFE04F5F);
|
||||
}
|
||||
return Color(0xFF2C8CFF);
|
||||
}
|
||||
|
||||
Widget _msgBoxTitle(String title) =>
|
||||
Text(translate(title), style: TextStyle(fontSize: 21));
|
||||
Widget msgboxIcon(String type) {
|
||||
IconData? iconData;
|
||||
if (type.contains("error") || type == "re-input-password") {
|
||||
iconData = Icons.cancel;
|
||||
}
|
||||
if (type.contains("success")) {
|
||||
iconData = Icons.check_circle;
|
||||
}
|
||||
if (type == "wait-uac" || type == "wait-remote-accept-nook") {
|
||||
iconData = Icons.hourglass_top;
|
||||
}
|
||||
if (type == 'on-uac' || type == 'on-foreground-elevated') {
|
||||
iconData = Icons.admin_panel_settings;
|
||||
}
|
||||
if (type == "info") {
|
||||
iconData = Icons.info;
|
||||
}
|
||||
if (iconData != null) {
|
||||
return Icon(iconData, size: 50, color: _msgboxColor(type))
|
||||
.marginOnly(right: 16);
|
||||
}
|
||||
|
||||
return Offstage();
|
||||
}
|
||||
|
||||
// title should be null
|
||||
Widget msgboxContent(String type, String title, String text) {
|
||||
return Row(
|
||||
children: [
|
||||
msgboxIcon(type),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
translate(title),
|
||||
style: TextStyle(fontSize: 21),
|
||||
).marginOnly(bottom: 10),
|
||||
Text(translate(text), style: const TextStyle(fontSize: 15)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void msgBoxCommon(OverlayDialogManager dialogManager, String title,
|
||||
Widget content, List<Widget> buttons,
|
||||
{bool hasCancel = true}) {
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: _msgBoxTitle(title),
|
||||
title: Text(
|
||||
translate(title),
|
||||
style: TextStyle(fontSize: 21),
|
||||
),
|
||||
content: content,
|
||||
actions: buttons,
|
||||
onCancel: hasCancel ? close : null,
|
||||
@ -1589,7 +1634,8 @@ class ServerConfig {
|
||||
Widget dialogButton(String text,
|
||||
{required VoidCallback? onPressed,
|
||||
bool isOutline = false,
|
||||
TextStyle? style}) {
|
||||
TextStyle? style,
|
||||
ButtonStyle? buttonStyle}) {
|
||||
if (isDesktop) {
|
||||
if (isOutline) {
|
||||
return OutlinedButton(
|
||||
@ -1598,7 +1644,7 @@ Widget dialogButton(String text,
|
||||
);
|
||||
} else {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(elevation: 0),
|
||||
style: ElevatedButton.styleFrom(elevation: 0).merge(buttonStyle),
|
||||
onPressed: onPressed,
|
||||
child: Text(translate(text), style: style),
|
||||
);
|
||||
|
@ -1426,12 +1426,8 @@ void showConfirmSwitchSidesDialog(
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Switch Sides')),
|
||||
content: Column(
|
||||
children: [
|
||||
Text(translate('Please confirm if you want to share your desktop?')),
|
||||
],
|
||||
),
|
||||
content: msgboxContent('info', 'Switch Sides',
|
||||
'Please confirm if you want to share your desktop?'),
|
||||
actions: [
|
||||
dialogButton('Cancel', onPressed: close, isOutline: true),
|
||||
dialogButton('OK', onPressed: submit),
|
||||
|
@ -9,7 +9,7 @@ import '../../models/model.dart';
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
void clientClose(String id, OverlayDialogManager dialogManager) {
|
||||
msgBox(id, '', 'Close', 'Are you sure to close the connection?', '',
|
||||
msgBox(id, 'info', 'Close', 'Are you sure to close the connection?', '',
|
||||
dialogManager);
|
||||
}
|
||||
|
||||
@ -33,8 +33,10 @@ void showRestartRemoteDevice(
|
||||
]),
|
||||
content: Text(
|
||||
"${translate('Are you sure you want to restart')} \n${pi.username}@${pi.hostname}($id) ?"),
|
||||
onCancel: close,
|
||||
onSubmit: () => close(true),
|
||||
actions: [
|
||||
dialogButton("Cancel", onPressed: () => close(), isOutline: true),
|
||||
dialogButton("Cancel", onPressed: close, isOutline: true),
|
||||
dialogButton("OK", onPressed: () => close(true)),
|
||||
],
|
||||
));
|
||||
@ -48,6 +50,18 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
||||
var validateLength = false;
|
||||
var validateSame = false;
|
||||
dialogManager.show((setState, close) {
|
||||
submit() async {
|
||||
close();
|
||||
dialogManager.showLoading(translate("Waiting"));
|
||||
if (await gFFI.serverModel.setPermanentPassword(p0.text)) {
|
||||
dialogManager.dismissAll();
|
||||
showSuccess();
|
||||
} else {
|
||||
dialogManager.dismissAll();
|
||||
showError();
|
||||
}
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate('Set your own password')),
|
||||
content: Form(
|
||||
@ -94,29 +108,17 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
||||
},
|
||||
),
|
||||
])),
|
||||
onCancel: close,
|
||||
onSubmit: (validateLength && validateSame) ? submit : null,
|
||||
actions: [
|
||||
dialogButton(
|
||||
'Cancel',
|
||||
onPressed: () {
|
||||
close();
|
||||
},
|
||||
onPressed: close,
|
||||
isOutline: true,
|
||||
),
|
||||
dialogButton(
|
||||
'OK',
|
||||
onPressed: (validateLength && validateSame)
|
||||
? () async {
|
||||
close();
|
||||
dialogManager.showLoading(translate("Waiting"));
|
||||
if (await gFFI.serverModel.setPermanentPassword(p0.text)) {
|
||||
dialogManager.dismissAll();
|
||||
showSuccess();
|
||||
} else {
|
||||
dialogManager.dismissAll();
|
||||
showError();
|
||||
}
|
||||
}
|
||||
: null,
|
||||
onPressed: (validateLength && validateSame) ? submit : null,
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -205,26 +207,36 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
||||
});
|
||||
}
|
||||
|
||||
void wrongPasswordDialog(String id, OverlayDialogManager dialogManager) {
|
||||
dialogManager.show((setState, close) => CustomAlertDialog(
|
||||
title: Text(translate('Wrong Password')),
|
||||
content: Text(translate('Do you want to enter again?')),
|
||||
actions: [
|
||||
dialogButton(
|
||||
'Cancel',
|
||||
onPressed: () {
|
||||
close();
|
||||
closeConnection();
|
||||
},
|
||||
isOutline: true,
|
||||
),
|
||||
dialogButton(
|
||||
'Retry',
|
||||
onPressed: () {
|
||||
enterPasswordDialog(id, dialogManager);
|
||||
},
|
||||
),
|
||||
]));
|
||||
void wrongPasswordDialog(
|
||||
String id, OverlayDialogManager dialogManager, type, title, text) {
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close) {
|
||||
cancel() {
|
||||
close();
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
submit() {
|
||||
enterPasswordDialog(id, dialogManager);
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: null,
|
||||
content: msgboxContent(type, title, text),
|
||||
onSubmit: submit,
|
||||
onCancel: cancel,
|
||||
actions: [
|
||||
dialogButton(
|
||||
'Cancel',
|
||||
onPressed: cancel,
|
||||
isOutline: true,
|
||||
),
|
||||
dialogButton(
|
||||
'Retry',
|
||||
onPressed: submit,
|
||||
),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
void showServerSettingsWithValue(
|
||||
@ -352,13 +364,15 @@ void showServerSettingsWithValue(
|
||||
});
|
||||
}
|
||||
|
||||
void showWaitUacDialog(String id, OverlayDialogManager dialogManager) {
|
||||
void showWaitUacDialog(
|
||||
String id, OverlayDialogManager dialogManager, String type) {
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show(
|
||||
tag: '$id-wait-uac',
|
||||
(setState, close) => CustomAlertDialog(
|
||||
title: Text(translate('Wait')),
|
||||
content: Text(translate('wait_accept_uac_tip')).marginAll(10),
|
||||
title: null,
|
||||
content: msgboxContent(type, 'Wait', 'wait_accept_uac_tip')
|
||||
.marginOnly(bottom: 10),
|
||||
));
|
||||
}
|
||||
|
||||
@ -516,16 +530,6 @@ void showOnBlockDialog(
|
||||
dialogManager.existing('$id-request-elevation')) {
|
||||
return;
|
||||
}
|
||||
var content = Column(children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"${translate(text)}${type.contains('uac') ? '\n' : '\n\n'}${translate('request_elevation_tip')}",
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(fontWeight: FontWeight.w400),
|
||||
).marginSymmetric(vertical: 15),
|
||||
),
|
||||
]);
|
||||
dialogManager.show(tag: '$id-$type', (setState, close) {
|
||||
void submit() {
|
||||
close();
|
||||
@ -533,12 +537,11 @@ void showOnBlockDialog(
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate(title)),
|
||||
content: content,
|
||||
title: null,
|
||||
content: msgboxContent(type, title,
|
||||
"${translate(text)}${type.contains('uac') ? '\n' : '\n\n'}${translate('request_elevation_tip')}"),
|
||||
actions: [
|
||||
dialogButton('Wait', onPressed: () {
|
||||
close();
|
||||
}, isOutline: true),
|
||||
dialogButton('Wait', onPressed: close, isOutline: true),
|
||||
dialogButton('Request Elevation', onPressed: submit),
|
||||
],
|
||||
onSubmit: submit,
|
||||
@ -556,8 +559,8 @@ void showElevationError(String id, String type, String title, String text,
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: Text(translate(title)),
|
||||
content: Text(translate(text)),
|
||||
title: null,
|
||||
content: msgboxContent(type, title, text),
|
||||
actions: [
|
||||
dialogButton('Cancel', onPressed: () {
|
||||
close();
|
||||
@ -570,6 +573,25 @@ void showElevationError(String id, String type, String title, String text,
|
||||
});
|
||||
}
|
||||
|
||||
void showWaitAcceptDialog(String id, String type, String title, String text,
|
||||
OverlayDialogManager dialogManager) {
|
||||
dialogManager.dismissAll();
|
||||
dialogManager.show((setState, close) {
|
||||
onCancel() {
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
return CustomAlertDialog(
|
||||
title: null,
|
||||
content: msgboxContent(type, title, text),
|
||||
actions: [
|
||||
dialogButton('Cancel', onPressed: onCancel, isOutline: true),
|
||||
],
|
||||
onCancel: onCancel,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<String?> validateAsync(String value) async {
|
||||
value = value.trim();
|
||||
if (value.isEmpty) {
|
||||
|
@ -263,19 +263,18 @@ class FfiModel with ChangeNotifier {
|
||||
final text = evt['text'];
|
||||
final link = evt['link'];
|
||||
if (type == 're-input-password') {
|
||||
wrongPasswordDialog(id, dialogManager);
|
||||
wrongPasswordDialog(id, dialogManager, type, title, text);
|
||||
} else if (type == 'input-password') {
|
||||
enterPasswordDialog(id, dialogManager);
|
||||
} else if (type == 'restarting') {
|
||||
showMsgBox(id, type, title, text, link, false, dialogManager,
|
||||
hasCancel: false);
|
||||
} else if (type == 'wait-remote-accept-nook') {
|
||||
msgBoxCommon(dialogManager, title, Text(translate(text)),
|
||||
[dialogButton("Cancel", onPressed: closeConnection)]);
|
||||
showWaitAcceptDialog(id, type, title, text, dialogManager);
|
||||
} else if (type == 'on-uac' || type == 'on-foreground-elevated') {
|
||||
showOnBlockDialog(id, type, title, text, dialogManager);
|
||||
} else if (type == 'wait-uac') {
|
||||
showWaitUacDialog(id, dialogManager);
|
||||
showWaitUacDialog(id, dialogManager, type);
|
||||
} else if (type == 'elevation-error') {
|
||||
showElevationError(id, type, title, text, dialogManager);
|
||||
} else {
|
||||
|
@ -1104,7 +1104,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
Some(misc::Union::PortableServiceRunning(b)) => {
|
||||
if b {
|
||||
self.handler.msgbox(
|
||||
"custom-nocancel",
|
||||
"custom-nocancel-success",
|
||||
"Successful",
|
||||
"Elevate successfully",
|
||||
"",
|
||||
|
Loading…
Reference in New Issue
Block a user