barrierDismissible and onWillPop
This commit is contained in:
parent
61722f5b8e
commit
9dadd76a8d
@ -59,7 +59,7 @@ class DialogManager {
|
|||||||
|
|
||||||
static void reset([result]) {
|
static void reset([result]) {
|
||||||
if (_dialogContext != null) {
|
if (_dialogContext != null) {
|
||||||
Navigator.pop(_dialogContext!,result);
|
Navigator.pop(_dialogContext!, result);
|
||||||
}
|
}
|
||||||
_dialogContext = null;
|
_dialogContext = null;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ class DialogManager {
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
DialogManager.register(context);
|
DialogManager.register(context);
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (_, setState) => builder(setState,DialogManager.reset));
|
builder: (_, setState) => builder(setState, DialogManager.reset));
|
||||||
});
|
});
|
||||||
DialogManager.drop();
|
DialogManager.drop();
|
||||||
return res;
|
return res;
|
||||||
|
@ -71,21 +71,21 @@ void showServer() {
|
|||||||
var key = '';
|
var key = '';
|
||||||
DialogManager.show((setState, close) {
|
DialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('ID Server')),
|
title: Text(translate('ID Server')),
|
||||||
content: Form(
|
content: Form(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
initialValue: id0,
|
initialValue: id0,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: translate('ID Server'),
|
labelText: translate('ID Server'),
|
||||||
),
|
|
||||||
validator: validate,
|
|
||||||
onSaved: (String? value) {
|
|
||||||
if (value != null) id = value.trim();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
/*
|
validator: validate,
|
||||||
|
onSaved: (String? value) {
|
||||||
|
if (value != null) id = value.trim();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
/*
|
||||||
TextFormField(
|
TextFormField(
|
||||||
initialValue: relay0,
|
initialValue: relay0,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@ -97,46 +97,50 @@ void showServer() {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
*/
|
*/
|
||||||
TextFormField(
|
TextFormField(
|
||||||
initialValue: key0,
|
initialValue: key0,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Key',
|
labelText: 'Key',
|
||||||
),
|
|
||||||
validator: null,
|
|
||||||
onSaved: (String? value) {
|
|
||||||
if (value != null) key = value.trim();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
])),
|
validator: null,
|
||||||
actions: [
|
onSaved: (String? value) {
|
||||||
TextButton(
|
if (value != null) key = value.trim();
|
||||||
style: flatButtonStyle,
|
},
|
||||||
onPressed: () {
|
),
|
||||||
|
])),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
style: flatButtonStyle,
|
||||||
|
onPressed: () {
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
child: Text(translate('Cancel')),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
style: flatButtonStyle,
|
||||||
|
onPressed: () {
|
||||||
|
if (formKey.currentState != null &&
|
||||||
|
formKey.currentState!.validate()) {
|
||||||
|
formKey.currentState!.save();
|
||||||
|
if (id != id0)
|
||||||
|
FFI.setByName('option',
|
||||||
|
'{"name": "custom-rendezvous-server", "value": "$id"}');
|
||||||
|
if (relay != relay0)
|
||||||
|
FFI.setByName(
|
||||||
|
'option', '{"name": "relay-server", "value": "$relay"}');
|
||||||
|
if (key != key0)
|
||||||
|
FFI.setByName('option', '{"name": "key", "value": "$key"}');
|
||||||
close();
|
close();
|
||||||
},
|
}
|
||||||
child: Text(translate('Cancel')),
|
},
|
||||||
),
|
child: Text(translate('OK')),
|
||||||
TextButton(
|
),
|
||||||
style: flatButtonStyle,
|
],
|
||||||
onPressed: () {
|
onWillPop: () async {
|
||||||
if (formKey.currentState != null &&
|
return true;
|
||||||
formKey.currentState!.validate()) {
|
},
|
||||||
formKey.currentState!.save();
|
);
|
||||||
if (id != id0)
|
}, barrierDismissible: true);
|
||||||
FFI.setByName('option',
|
|
||||||
'{"name": "custom-rendezvous-server", "value": "$id"}');
|
|
||||||
if (relay != relay0)
|
|
||||||
FFI.setByName(
|
|
||||||
'option', '{"name": "relay-server", "value": "$relay"}');
|
|
||||||
if (key != key0)
|
|
||||||
FFI.setByName('option', '{"name": "key", "value": "$key"}');
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(translate('OK')),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String? validate(value) {
|
String? validate(value) {
|
||||||
@ -169,18 +173,10 @@ void showAbout() {
|
|||||||
)),
|
)),
|
||||||
)),
|
)),
|
||||||
]),
|
]),
|
||||||
actions: [
|
actions: [],
|
||||||
TextButton(
|
|
||||||
style: flatButtonStyle,
|
|
||||||
onPressed: () {
|
|
||||||
close();
|
|
||||||
},
|
|
||||||
child: Text(translate('OK')),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
}, barrierDismissible: true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user