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