mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-01-18 11:17:06 +00:00
Do not allow starting site if there are errors (#220)
This commit is contained in:
parent
301dc6c394
commit
6ed64b7349
1 changed files with 14 additions and 12 deletions
|
@ -134,6 +134,19 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildConfig() {
|
Widget _buildConfig() {
|
||||||
|
void handleChange(v) async {
|
||||||
|
try {
|
||||||
|
if (v) {
|
||||||
|
await widget.site.start();
|
||||||
|
} else {
|
||||||
|
await widget.site.stop();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
var action = v ? 'start' : 'stop';
|
||||||
|
Utils.popError(context, 'Failed to $action the site', error.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ConfigSection(children: <Widget>[
|
return ConfigSection(children: <Widget>[
|
||||||
ConfigItem(
|
ConfigItem(
|
||||||
label: Text('Status'),
|
label: Text('Status'),
|
||||||
|
@ -145,18 +158,7 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
|
||||||
Switch.adaptive(
|
Switch.adaptive(
|
||||||
value: widget.site.connected,
|
value: widget.site.connected,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
onChanged: (v) async {
|
onChanged: widget.site.errors.length > 0 && !widget.site.connected ? null : handleChange,
|
||||||
try {
|
|
||||||
if (v) {
|
|
||||||
await widget.site.start();
|
|
||||||
} else {
|
|
||||||
await widget.site.stop();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
var action = v ? 'start' : 'stop';
|
|
||||||
Utils.popError(context, 'Failed to $action the site', error.toString());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
])),
|
])),
|
||||||
ConfigPageItem(
|
ConfigPageItem(
|
||||||
|
|
Loading…
Reference in a new issue