From 776b0124410ead5b32245bde45fc4b8282d2704a Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Sun, 21 Nov 2021 10:27:08 +0100 Subject: [PATCH] design: Redesign and simplify bootstrap --- assets/l10n/intl_en.arb | 4 +- lib/pages/bootstrap/bootstrap_dialog.dart | 46 ++++++++++++++++------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 92bd28dc..12d049cc 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2612,5 +2612,7 @@ "removeFromSpaceDescription": "This removes this chat from the current space. It will then still be visible under \"All chats\".", "addToSpaceDescription": "Select a space to add this chat to it.", "start": "Start", - "setupChatBackupNow": "Set up your chat backup now" + "setupChatBackupNow": "Set up your chat backup now", + "pleaseEnterSecurityKeyDescription": "To unlock your chat backup, please enter your security key that has been generated in a previous session. Your security key is NOT your password.", + "saveTheSecurityKeyNow": "Save the security key now" } diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index ab42c8c9..5dac5627 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -8,6 +7,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:matrix/encryption.dart'; import 'package:matrix/encryption/utils/bootstrap.dart'; import 'package:matrix/matrix.dart'; +import 'package:share/share.dart'; import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -54,6 +54,7 @@ class _BootstrapDialogState extends State { String titleText; bool _recoveryKeyStored = false; + bool _recoveryKeyCopied = false; bool _wipe; @@ -100,6 +101,15 @@ class _BootstrapDialogState extends State { child: ListView( padding: const EdgeInsets.all(16.0), children: [ + Text( + L10n.of(context).chatBackupDescription, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 16, + fontStyle: FontStyle.italic, + ), + ), + const Divider(height: 64), TextField( minLines: 4, maxLines: 4, @@ -108,9 +118,12 @@ class _BootstrapDialogState extends State { ), const SizedBox(height: 16), ElevatedButton.icon( - icon: const Icon(Icons.copy_outlined), - label: Text(L10n.of(context).copyToClipboard), - onPressed: () => Clipboard.setData(ClipboardData(text: key)), + icon: const Icon(Icons.save_alt_outlined), + label: Text(L10n.of(context).saveTheSecurityKeyNow), + onPressed: () { + Share.share(key); + setState(() => _recoveryKeyCopied = true); + }, ), const SizedBox(height: 16), ElevatedButton.icon( @@ -119,8 +132,10 @@ class _BootstrapDialogState extends State { onPrimary: Theme.of(context).primaryColor, ), icon: const Icon(Icons.check_outlined), - label: Text(L10n.of(context).iWroteDownTheKey), - onPressed: () => setState(() => _recoveryKeyStored = true), + label: Text(L10n.of(context).next), + onPressed: _recoveryKeyCopied + ? () => setState(() => _recoveryKeyStored = true) + : null, ), ], ), @@ -175,13 +190,17 @@ class _BootstrapDialogState extends State { padding: const EdgeInsets.all(16.0), children: [ Text( - L10n.of(context).setupChatBackupDescription, + L10n.of(context).pleaseEnterSecurityKeyDescription, textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 16, + fontStyle: FontStyle.italic, + ), ), - const SizedBox(height: 16), + const Divider(height: 64), TextField( - minLines: 4, - maxLines: 4, + minLines: 1, + maxLines: 1, autocorrect: false, readOnly: _recoveryKeyInputLoading, autofillHints: _recoveryKeyInputLoading @@ -229,7 +248,7 @@ class _BootstrapDialogState extends State { () => _recoveryKeyInputLoading = false); } }), - const SizedBox(height: 16), + const SizedBox(height: 32), Row(children: [ const Expanded(child: Divider()), Padding( @@ -238,14 +257,13 @@ class _BootstrapDialogState extends State { ), const Expanded(child: Divider()), ]), - const SizedBox(height: 16), + const SizedBox(height: 32), ElevatedButton.icon( style: ElevatedButton.styleFrom( primary: Theme.of(context).secondaryHeaderColor, onPrimary: Theme.of(context).primaryColor, ), - icon: - const Icon(Icons.transfer_within_a_station_outlined), + icon: const Icon(Icons.cast_connected_outlined), label: Text(L10n.of(context).transferFromAnotherDevice), onPressed: _recoveryKeyInputLoading ? null