[pve-devel] [PATCH pve-flutter-frontend 2/5] console: wrap console with appbar

Dominik Csapak d.csapak at proxmox.com
Mon Apr 15 12:30:24 CEST 2024


so one can return to the previous view without having to use the back
button of the device.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 lib/widgets/pve_console_menu_widget.dart | 107 ++++++++++++-----------
 1 file changed, 57 insertions(+), 50 deletions(-)

diff --git a/lib/widgets/pve_console_menu_widget.dart b/lib/widgets/pve_console_menu_widget.dart
index 243baf1..9c91d30 100644
--- a/lib/widgets/pve_console_menu_widget.dart
+++ b/lib/widgets/pve_console_menu_widget.dart
@@ -234,63 +234,70 @@ class PVEWebConsoleState extends State<PVEWebConsole> {
           value: ticket,
         ),
         builder: (context, snapshot) {
-          return SafeArea(
-            child: InAppWebView(
-              onReceivedServerTrustAuthRequest: (controller, challenge) async {
-                final cert = challenge.protectionSpace.sslCertificate;
-                final certBytes = cert?.x509Certificate?.encoded;
-                final sslError = challenge.protectionSpace.sslError?.message;
+          return Scaffold(
+              appBar: AppBar(
+                title: const Text("Console"),
+              ),
+              body: SafeArea(
+                child: InAppWebView(
+                  onReceivedServerTrustAuthRequest:
+                      (controller, challenge) async {
+                    final cert = challenge.protectionSpace.sslCertificate;
+                    final certBytes = cert?.x509Certificate?.encoded;
+                    final sslError =
+                        challenge.protectionSpace.sslError?.message;
 
-                String? issuedTo = cert?.issuedTo?.CName.toString();
-                String? hash = certBytes != null
-                    ? sha256.convert(certBytes).toString()
-                    : null;
+                    String? issuedTo = cert?.issuedTo?.CName.toString();
+                    String? hash = certBytes != null
+                        ? sha256.convert(certBytes).toString()
+                        : null;
 
-                final settings =
-                    await ProxmoxGeneralSettingsModel.fromLocalStorage();
+                    final settings =
+                        await ProxmoxGeneralSettingsModel.fromLocalStorage();
 
-                bool trust = false;
-                if (hash != null && settings.trustedFingerprints != null) {
-                  trust = settings.trustedFingerprints!.contains(hash);
-                }
+                    bool trust = false;
+                    if (hash != null && settings.trustedFingerprints != null) {
+                      trust = settings.trustedFingerprints!.contains(hash);
+                    }
 
-                if (!trust) {
-                  // format hash to '01:23:...' format
-                  String? formattedHash = hash?.toUpperCase().replaceAllMapped(
-                      RegExp(r"[a-zA-Z0-9]{2}"),
-                      (match) => "${match.group(0)}:");
-                  formattedHash = formattedHash?.substring(
-                      0, formattedHash.length - 1); // remove last ':'
+                    if (!trust) {
+                      // format hash to '01:23:...' format
+                      String? formattedHash = hash
+                          ?.toUpperCase()
+                          .replaceAllMapped(RegExp(r"[a-zA-Z0-9]{2}"),
+                              (match) => "${match.group(0)}:");
+                      formattedHash = formattedHash?.substring(
+                          0, formattedHash.length - 1); // remove last ':'
 
-                  if (context.mounted) {
-                    trust = await showTLSWarning(
-                        context,
-                        sslError ?? 'An unknown TLS error has occurred',
-                        issuedTo ?? 'unknown',
-                        formattedHash ?? 'unknown');
-                  }
-                }
+                      if (context.mounted) {
+                        trust = await showTLSWarning(
+                            context,
+                            sslError ?? 'An unknown TLS error has occurred',
+                            issuedTo ?? 'unknown',
+                            formattedHash ?? 'unknown');
+                      }
+                    }
 
-                // save Fingerprint
-                if (trust && hash != null) {
-                  await settings
-                      .rebuild((b) => b..trustedFingerprints.add(hash))
-                      .toLocalStorage();
-                  print(settings.toJson());
-                }
+                    // save Fingerprint
+                    if (trust && hash != null) {
+                      await settings
+                          .rebuild((b) => b..trustedFingerprints.add(hash))
+                          .toLocalStorage();
+                      print(settings.toJson());
+                    }
 
-                final action = trust
-                    ? ServerTrustAuthResponseAction.PROCEED
-                    : ServerTrustAuthResponseAction.CANCEL;
-                return ServerTrustAuthResponse(action: action);
-              },
-              onWebViewCreated: (controller) {
-                webViewController = controller;
-                controller.loadUrl(
-                    urlRequest: URLRequest(url: Uri.parse(consoleUrl)));
-              },
-            ),
-          );
+                    final action = trust
+                        ? ServerTrustAuthResponseAction.PROCEED
+                        : ServerTrustAuthResponseAction.CANCEL;
+                    return ServerTrustAuthResponse(action: action);
+                  },
+                  onWebViewCreated: (controller) {
+                    webViewController = controller;
+                    controller.loadUrl(
+                        urlRequest: URLRequest(url: Uri.parse(consoleUrl)));
+                  },
+                ),
+              ));
         });
   }
 
-- 
2.39.2





More information about the pve-devel mailing list