From 03f7e7d8197e8f7ad938061fe093181a48c27c33 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 14 Aug 2023 07:09:06 +0300 Subject: [PATCH] fix(ui): Fix encryption key modal behaviour when no key found Closes #300 --- .../backups/copy_encryption_key_modal.dart | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/ui/pages/backups/copy_encryption_key_modal.dart b/lib/ui/pages/backups/copy_encryption_key_modal.dart index 42bc1ba9..dca9d705 100644 --- a/lib/ui/pages/backups/copy_encryption_key_modal.dart +++ b/lib/ui/pages/backups/copy_encryption_key_modal.dart @@ -6,6 +6,7 @@ import 'package:flutter/services.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart'; +import 'package:selfprivacy/ui/components/info_box/info_box.dart'; class CopyEncryptionKeyModal extends StatefulWidget { const CopyEncryptionKeyModal({ @@ -32,8 +33,27 @@ class _CopyEncryptionKeyModalState extends State { @override Widget build(final BuildContext context) { - final String encryptionKey = - context.watch().state.backblazeBucket!.encryptionKey; + final String? encryptionKey = + context.watch().state.backblazeBucket?.encryptionKey; + if (encryptionKey == null) { + return ListView( + controller: widget.scrollController, + padding: const EdgeInsets.all(16), + children: [ + const SizedBox(height: 16), + Text( + 'backup.backups_encryption_key'.tr(), + style: Theme.of(context).textTheme.headlineSmall, + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + InfoBox( + text: 'backup.backups_encryption_key_not_found'.tr(), + isWarning: true, + ), + ], + ); + } return ListView( controller: widget.scrollController, padding: const EdgeInsets.all(16),