public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-flutter-frontend 09/10] fix guest backup widget start display
Date: Thu,  8 Sep 2022 11:55:49 +0200	[thread overview]
Message-ID: <20220908095550.2913416-13-d.csapak@proxmox.com> (raw)
In-Reply-To: <20220908095550.2913416-1-d.csapak@proxmox.com>

when we changed from ScaffoldState to ScaffoldMessengerState, we missed
that we have to wrap the scaffold in a ScaffoldMessenger, otherwise
there is no current state and we never could show a snack

we also have to do the null safety of the 'nodesVZDumpCreateBackup'
differently, since we get a Future<String?>, which cannot be converted
to FutureOr<String>, we got an exception (that we never saw because
of the Missing ScaffoldMessenger)

same is true for the 'remove' button

despite that the backup always actually ran, but the user did not get
any visual feedback

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 lib/widgets/pve_guest_backup_widget.dart | 144 ++++++++++++-----------
 1 file changed, 73 insertions(+), 71 deletions(-)

diff --git a/lib/widgets/pve_guest_backup_widget.dart b/lib/widgets/pve_guest_backup_widget.dart
index e6aebde..05cd725 100644
--- a/lib/widgets/pve_guest_backup_widget.dart
+++ b/lib/widgets/pve_guest_backup_widget.dart
@@ -265,11 +265,11 @@ class PveGuestBackupContent extends StatelessWidget {
                     ),
                     OutlinedButton.icon(
                       onPressed: () async {
-                        final guard = await (_showConfirmDialog(
+                        final guard = (await _showConfirmDialog(
                                 context,
                                 'Attention',
                                 'Do you really want to delete this backup?')
-                            as FutureOr<bool>);
+                           )!;
                         if (guard) {
                           fBloc.events.add(DeleteFile(volid));
                           Navigator.of(context).pop();
@@ -417,77 +417,79 @@ class _PveBackupFormState extends State<PveBackupForm> {
 
   @override
   Widget build(BuildContext context) {
-    return Scaffold(
+    return ScaffoldMessenger(
       key: _scaffoldKey,
-      appBar: AppBar(
-        iconTheme: IconThemeData(color: Colors.black),
-        backgroundColor: Colors.transparent,
-        elevation: 0,
-        title: Text(
-          "Schedule backup",
-          style: TextStyle(color: Colors.black),
+      child: Scaffold(
+        appBar: AppBar(
+          iconTheme: IconThemeData(color: Colors.black),
+          backgroundColor: Colors.transparent,
+          elevation: 0,
+          title: Text(
+            "Schedule backup",
+            style: TextStyle(color: Colors.black),
+          ),
         ),
-      ),
-      body: SingleChildScrollView(
-          padding: EdgeInsets.all(8),
-          child: Form(
-            key: _formKey,
-            onChanged: () {
-              final isValid = _formKey.currentState!.validate();
-              setState(() {
-                enableSubmitButton = isValid;
-              });
-            },
-            child: Column(
-              children: [
-                PveStorageSelectorDropdown(
-                  labelText: 'Storage',
-                  sBloc: widget.sBloc,
-                  allowBlank: false,
-                ),
-                _createModeDropdown(),
-                _createCompressionDropdown(),
-                TextFormField(
-                  decoration: InputDecoration(
-                    labelText: 'Email to',
-                    helperText: ' ',
+        body: SingleChildScrollView(
+            padding: EdgeInsets.all(8),
+            child: Form(
+              key: _formKey,
+              onChanged: () {
+                final isValid = _formKey.currentState!.validate();
+                setState(() {
+                  enableSubmitButton = isValid;
+                });
+              },
+              child: Column(
+                children: [
+                  PveStorageSelectorDropdown(
+                    labelText: 'Storage',
+                    sBloc: widget.sBloc,
+                    allowBlank: false,
                   ),
-                  controller: emailToController,
-                  autovalidateMode: AutovalidateMode.onUserInteraction,
-                  validator: (value) {
-                    if (value!.isNotEmpty && !Validators.isValidEmail(value)) {
-                      return 'Please enter valid email address';
-                    }
-                    return null;
-                  },
-                ),
-                OutlinedButton.icon(
-                    onPressed: enableSubmitButton
-                        ? () {
-                            //TODO remove when async validation is implemented
-                            if (!_formKey.currentState!.validate()) {
-                              setState(() {
-                                enableSubmitButton = false;
-                              });
-                              return;
-                            }
+                  _createModeDropdown(),
+                  _createCompressionDropdown(),
+                  TextFormField(
+                    decoration: InputDecoration(
+                      labelText: 'Email to',
+                      helperText: ' ',
+                    ),
+                    controller: emailToController,
+                    autovalidateMode: AutovalidateMode.onUserInteraction,
+                    validator: (value) {
+                      if (value!.isNotEmpty && !Validators.isValidEmail(value)) {
+                        return 'Please enter valid email address';
+                      }
+                      return null;
+                    },
+                  ),
+                  OutlinedButton.icon(
+                      onPressed: enableSubmitButton
+                          ? () {
+                              //TODO remove when async validation is implemented
+                              if (!_formKey.currentState!.validate()) {
+                                setState(() {
+                                  enableSubmitButton = false;
+                                });
+                                return;
+                              }
 
-                            startBackup(
-                              widget.sBloc.apiClient,
-                              widget.sBloc.latestState.nodeID,
-                              widget.sBloc.latestState.selected!.id,
-                              widget.guestID,
-                              compression,
-                              mode!,
-                              mailTo: emailToController!.text,
-                            );
-                          }
-                        : null,
-                    icon: Icon(Icons.save),
-                    label: Text('Start backup now'))
-              ],
-            ),
-          )),
+                              startBackup(
+                                widget.sBloc.apiClient,
+                                widget.sBloc.latestState.nodeID,
+                                widget.sBloc.latestState.selected!.id,
+                                widget.guestID,
+                                compression,
+                                mode!,
+                                mailTo: emailToController!.text,
+                              );
+                            }
+                          : null,
+                      icon: Icon(Icons.save),
+                      label: Text('Start backup now'))
+                ],
+              ),
+            )),
+      )
     );
   }
 
@@ -501,11 +503,11 @@ class _PveBackupFormState extends State<PveBackupForm> {
     String? mailTo,
   }) async {
     try {
-      final jobId = await (apiClient.nodesVZDumpCreateBackup(
+      final jobId = (await apiClient.nodesVZDumpCreateBackup(
           node, storage, guestId,
           compressionType: compression,
           mode: mode,
-          mailTo: mailTo) as FutureOr<String>);
+          mailTo: mailTo))!;
 
       await showTaskLogBottomSheet(context, apiClient, node, jobId,
           icon: Icon(Icons.save), jobTitle: Text('Backup $guestId'));
-- 
2.30.2





  parent reply	other threads:[~2022-09-08  9:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  9:55 [pve-devel] [PATCH proxmox-login-manager/pve-flutter-frontend] fixes & update to flutter 3.3 Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH proxmox-login-manager 1/3] login_form: keep Continue button above Android softnav Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH proxmox-login-manager 2/3] migrate from FlatButton to TextButton Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH proxmox-login-manager 3/3] improve colors of login screen Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 01/10] avoid elements hiding behind Android softnav buttons Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 02/10] increase compileSdkVersion to 32 Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 03/10] fix null handling in MainActivity.kt Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 04/10] move to OutlinedButton from OutlineButton Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 05/10] move to TextButton from FlatButton Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 06/10] move to ElevatedButton from RaisedButton Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 07/10] improve colors for indicator/toggles Dominik Csapak
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 08/10] fix typo Opague -> Opaque Dominik Csapak
2022-09-08  9:55 ` Dominik Csapak [this message]
2022-09-08  9:55 ` [pve-devel] [PATCH pve-flutter-frontend 10/10] fix options view when ostype is null Dominik Csapak
2022-09-08 15:31 ` [pve-devel] applied-series: [PATCH proxmox-login-manager/pve-flutter-frontend] fixes & update to flutter 3.3 Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220908095550.2913416-13-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal