mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-01-18 03:07:02 +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() {
|
||||
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>[
|
||||
ConfigItem(
|
||||
label: Text('Status'),
|
||||
|
@ -145,18 +158,7 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
|
|||
Switch.adaptive(
|
||||
value: widget.site.connected,
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
onChanged: (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());
|
||||
}
|
||||
},
|
||||
onChanged: widget.site.errors.length > 0 && !widget.site.connected ? null : handleChange,
|
||||
)
|
||||
])),
|
||||
ConfigPageItem(
|
||||
|
|
Loading…
Reference in a new issue