The setting screen UI was previously defined in this repo. If a new app
settings needs to be added eg: privacy policy link, app version string.
The change had to be done in the package even though the change is not
package specific.

Inorder to fix that, move settings page to `pve_flutter_frontend` and use
`ProxmoxGeneralSettingsForm` as a widget in the new settings page.

Signed-off-by: Shan Shaji <s.sh...@proxmox.com>
---
 lib/proxmox_general_settings_form.dart | 58 +++++++++++---------------
 lib/proxmox_login_form.dart            |  5 +--
 lib/proxmox_login_selector.dart        | 13 +++---
 3 files changed, 31 insertions(+), 45 deletions(-)

diff --git a/lib/proxmox_general_settings_form.dart 
b/lib/proxmox_general_settings_form.dart
index cb0afef..e39f91d 100644
--- a/lib/proxmox_general_settings_form.dart
+++ b/lib/proxmox_general_settings_form.dart
@@ -12,6 +12,7 @@ class ProxmoxGeneralSettingsForm extends StatefulWidget {
 class _ProxmoxGeneralSettingsFormState
     extends State<ProxmoxGeneralSettingsForm> {
   Future<ProxmoxGeneralSettingsModel>? _settings;
+
   @override
   void initState() {
     super.initState();
@@ -20,41 +21,30 @@ class _ProxmoxGeneralSettingsFormState
 
   @override
   Widget build(BuildContext context) {
-    return Scaffold(
-      appBar: AppBar(
-        title: const Text('Settings'),
-      ),
-      body: FutureBuilder<ProxmoxGeneralSettingsModel>(
-          future: _settings,
-          builder: (context, snaptshot) {
-            if (snaptshot.hasData) {
-              final settings = snaptshot.data!;
-              return SingleChildScrollView(
-                child: Column(
-                  children: [
-                    SwitchListTile(
-                      title: const Text('Validate SSL connections'),
-                      subtitle: const Text('e.g. validates certificates'),
-                      value: settings.sslValidation!,
-                      onChanged: (value) async {
-                        await settings
-                            .rebuild((b) => b.sslValidation = value)
-                            .toLocalStorage();
-                        setState(() {
-                          _settings =
-                              ProxmoxGeneralSettingsModel.fromLocalStorage();
-                        });
-                      },
-                    )
-                  ],
-                ),
-              );
-            }
+    return FutureBuilder<ProxmoxGeneralSettingsModel>(
+      future: _settings,
+      builder: (context, snapShot) {
+        if (snapShot.hasData) {
+          final settings = snapShot.data!;
+          return SwitchListTile(
+            title: const Text('Validate SSL connections'),
+            subtitle: const Text('e.g. validates certificates'),
+            value: settings.sslValidation!,
+            onChanged: (value) async {
+              await settings
+                  .rebuild((b) => b.sslValidation = value)
+                  .toLocalStorage();
+              setState(() {
+                _settings = ProxmoxGeneralSettingsModel.fromLocalStorage();
+              });
+            },
+          );
+        }
 
-            return const Center(
-              child: CircularProgressIndicator(),
-            );
-          }),
+        return const Center(
+          child: CircularProgressIndicator(),
+        );
+      },
     );
   }
 }
diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart
index 5a2db3b..db9994b 100644
--- a/lib/proxmox_login_form.dart
+++ b/lib/proxmox_login_form.dart
@@ -6,7 +6,6 @@ import 'package:collection/collection.dart';
 import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart'
     as proxclient;
 import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart';
-import 'package:proxmox_login_manager/proxmox_general_settings_form.dart';
 import 'package:proxmox_login_manager/proxmox_general_settings_model.dart';
 import 'package:proxmox_login_manager/proxmox_login_model.dart';
 import 'package:proxmox_login_manager/proxmox_tfa_form.dart';
@@ -829,9 +828,7 @@ class ProxmoxCertificateErrorDialog extends StatelessWidget 
{
           child: const Text('Close'),
         ),
         TextButton(
-          onPressed: () => Navigator.of(context).pushReplacement(
-              MaterialPageRoute(
-                  builder: (context) => const ProxmoxGeneralSettingsForm())),
+          onPressed: () => Navigator.popAndPushNamed(context, '/settings'),
           child: const Text('Settings'),
         )
       ],
diff --git a/lib/proxmox_login_selector.dart b/lib/proxmox_login_selector.dart
index ba84d7d..c8d9813 100644
--- a/lib/proxmox_login_selector.dart
+++ b/lib/proxmox_login_selector.dart
@@ -1,6 +1,5 @@
 import 'package:flutter/material.dart';
 import 'package:built_collection/built_collection.dart';
-import 'package:proxmox_login_manager/proxmox_general_settings_form.dart';
 import 'package:proxmox_login_manager/proxmox_login_form.dart';
 import 'package:proxmox_login_manager/proxmox_login_model.dart';
 import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart'
@@ -52,12 +51,12 @@ class _ProxmoxLoginSelectorState extends 
State<ProxmoxLoginSelector> {
         ),
         actions: [
           IconButton(
-              icon: const Icon(Icons.settings),
-              onPressed: () {
-                Navigator.of(context).push(MaterialPageRoute(
-                  builder: (context) => const ProxmoxGeneralSettingsForm(),
-                ));
-              })
+            icon: const Icon(Icons.settings),
+            onPressed: () => Navigator.pushNamed(
+              context,
+              '/settings',
+            ),
+          )
         ],
       ),
       body: FutureBuilder<ProxmoxLoginStorage?>(
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to