]>
Commit | Line | Data |
---|---|---|
0e468546 TM |
1 | import 'package:flutter/material.dart'; |
2 | import 'package:proxmox_login_manager/proxmox_general_settings_model.dart'; | |
3 | ||
4 | class ProxmoxGeneralSettingsForm extends StatefulWidget { | |
5 | @override | |
6 | _ProxmoxGeneralSettingsFormState createState() => | |
7 | _ProxmoxGeneralSettingsFormState(); | |
8 | } | |
9 | ||
10 | class _ProxmoxGeneralSettingsFormState | |
11 | extends State<ProxmoxGeneralSettingsForm> { | |
12 | Future<ProxmoxGeneralSettingsModel> _settings; | |
13 | @override | |
14 | void initState() { | |
15 | super.initState(); | |
16 | _settings = ProxmoxGeneralSettingsModel.fromLocalStorage(); | |
17 | } | |
18 | ||
19 | @override | |
20 | Widget build(BuildContext context) { | |
21 | return Scaffold( | |
22 | appBar: AppBar( | |
23 | title: Text('Settings'), | |
24 | ), | |
25 | body: FutureBuilder<ProxmoxGeneralSettingsModel>( | |
26 | future: _settings, | |
27 | builder: (context, snaptshot) { | |
28 | if (snaptshot.hasData) { | |
29 | final settings = snaptshot.data; | |
30 | return SingleChildScrollView( | |
31 | child: Column( | |
32 | children: [ | |
33 | SwitchListTile( | |
34 | title: Text('Validate SSL connections'), | |
35 | subtitle: Text('e.g. validates certificates'), | |
36 | value: settings.sslValidation, | |
37 | onChanged: (value) async { | |
38 | await settings | |
39 | .rebuild((b) => b.sslValidation = value) | |
40 | .toLocalStorage(); | |
41 | setState(() { | |
42 | _settings = | |
43 | ProxmoxGeneralSettingsModel.fromLocalStorage(); | |
44 | }); | |
45 | }, | |
46 | ) | |
47 | ], | |
48 | ), | |
49 | ); | |
50 | } | |
51 | ||
52 | return Center( | |
53 | child: CircularProgressIndicator(), | |
54 | ); | |
55 | }), | |
56 | ); | |
57 | } | |
58 | } |