fix: Bootstrap column design

onboarding
Krille Fear 3 years ago
parent a42bda479b
commit eb8eea892f

@ -1,5 +1,5 @@
import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:fluffychat/widgets/layouts/one_page_card.dart'; import 'package:fluffychat/config/themes.dart';
import 'package:matrix/encryption.dart'; import 'package:matrix/encryption.dart';
import 'package:matrix/encryption/utils/bootstrap.dart'; import 'package:matrix/encryption/utils/bootstrap.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
@ -92,41 +92,46 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
_recoveryKeyStored == false) { _recoveryKeyStored == false) {
final key = bootstrap.newSsssKey.recoveryKey; final key = bootstrap.newSsssKey.recoveryKey;
titleText = L10n.of(context).securityKey; titleText = L10n.of(context).securityKey;
return OnePageCard( return AlertDialog(
child: Scaffold( title: AppBar(
appBar: AppBar( centerTitle: true,
leading: IconButton( leading: IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
onPressed: Navigator.of(context).pop, onPressed: Navigator.of(context).pop,
),
title: Text(L10n.of(context).securityKey),
), ),
body: ListView( title: Text(L10n.of(context).securityKey),
padding: const EdgeInsets.all(16.0), ),
children: [ content: Center(
TextField( child: ConstrainedBox(
minLines: 4, constraints:
maxLines: 4, BoxConstraints(maxWidth: FluffyThemes.columnWidth * 1.5),
readOnly: true, child: ListView(
controller: TextEditingController(text: key), padding: const EdgeInsets.all(16.0),
), children: [
const SizedBox(height: 16), TextField(
ElevatedButton.icon( minLines: 4,
icon: Icon(Icons.copy_outlined), maxLines: 4,
label: Text(L10n.of(context).copyToClipboard), readOnly: true,
onPressed: () => Clipboard.setData(ClipboardData(text: key)), controller: TextEditingController(text: key),
),
const SizedBox(height: 16),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).secondaryHeaderColor,
onPrimary: Theme.of(context).primaryColor,
), ),
icon: Icon(Icons.check_outlined), const SizedBox(height: 16),
label: Text(L10n.of(context).iWroteDownTheKey), ElevatedButton.icon(
onPressed: () => setState(() => _recoveryKeyStored = true), icon: Icon(Icons.copy_outlined),
), label: Text(L10n.of(context).copyToClipboard),
], onPressed: () => Clipboard.setData(ClipboardData(text: key)),
),
const SizedBox(height: 16),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).secondaryHeaderColor,
onPrimary: Theme.of(context).primaryColor,
),
icon: Icon(Icons.check_outlined),
label: Text(L10n.of(context).iWroteDownTheKey),
onPressed: () => setState(() => _recoveryKeyStored = true),
),
],
),
), ),
), ),
); );
@ -161,110 +166,115 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
break; break;
case BootstrapState.openExistingSsss: case BootstrapState.openExistingSsss:
_recoveryKeyStored = true; _recoveryKeyStored = true;
return OnePageCard( return Scaffold(
child: Scaffold( appBar: AppBar(
appBar: AppBar( centerTitle: true,
leading: IconButton( leading: IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
onPressed: Navigator.of(context).pop, onPressed: Navigator.of(context).pop,
),
title: Text(L10n.of(context).pleaseEnterSecurityKey),
), ),
body: ListView( title: Text(L10n.of(context).pleaseEnterSecurityKey),
padding: const EdgeInsets.all(16.0), ),
children: [ body: Center(
TextField( child: ConstrainedBox(
minLines: 4, constraints:
maxLines: 4, BoxConstraints(maxWidth: FluffyThemes.columnWidth * 1.5),
autofocus: true, child: ListView(
autocorrect: false, padding: const EdgeInsets.all(16.0),
autofillHints: _recoveryKeyInputLoading children: [
? null TextField(
: [AutofillHints.password], minLines: 4,
controller: _recoveryKeyTextEditingController, maxLines: 4,
decoration: InputDecoration( autofocus: true,
hintText: 'Abc123 Def456', autocorrect: false,
labelText: L10n.of(context).securityKey, autofillHints: _recoveryKeyInputLoading
errorText: _recoveryKeyInputError, ? null
: [AutofillHints.password],
controller: _recoveryKeyTextEditingController,
decoration: InputDecoration(
hintText: 'Abc123 Def456',
labelText: L10n.of(context).securityKey,
errorText: _recoveryKeyInputError,
),
), ),
), const SizedBox(height: 16),
const SizedBox(height: 16), ElevatedButton.icon(
ElevatedButton.icon( icon: Icon(Icons.lock_open_outlined),
icon: Icon(Icons.lock_open_outlined), label: Text(L10n.of(context).unlockChatBackup),
label: Text(L10n.of(context).unlockChatBackup), onPressed: () async {
setState(() {
_recoveryKeyInputError = null;
_recoveryKeyInputLoading = true;
});
try {
await bootstrap.newSsssKey.unlock(
keyOrPassphrase:
_recoveryKeyTextEditingController.text,
);
await bootstrap.openExistingSsss();
} catch (e, s) {
Logs().w('Unable to unlock SSSS', e, s);
setState(() => _recoveryKeyInputError =
L10n.of(context).oopsSomethingWentWrong);
} finally {
setState(() => _recoveryKeyInputLoading = false);
}
}),
const SizedBox(height: 16),
Row(children: [
Expanded(child: Divider()),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(L10n.of(context).or),
),
Expanded(child: Divider()),
]),
const SizedBox(height: 16),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).secondaryHeaderColor,
onPrimary: Theme.of(context).primaryColor,
),
icon: Icon(Icons.transfer_within_a_station_outlined),
label: Text(L10n.of(context).transferFromAnotherDevice),
onPressed: () async { onPressed: () async {
setState(() { final req = await showFutureLoadingDialog(
_recoveryKeyInputError = null; context: context,
_recoveryKeyInputLoading = true; future: () => widget
}); .client.userDeviceKeys[widget.client.userID]
try { .startVerification(),
await bootstrap.newSsssKey.unlock( );
keyOrPassphrase: if (req.error != null) return;
_recoveryKeyTextEditingController.text, await KeyVerificationDialog(request: req.result)
); .show(context);
await bootstrap.openExistingSsss(); Navigator.of(context, rootNavigator: false).pop();
} catch (e, s) { },
Logs().w('Unable to unlock SSSS', e, s);
setState(() => _recoveryKeyInputError =
L10n.of(context).oopsSomethingWentWrong);
} finally {
setState(() => _recoveryKeyInputLoading = false);
}
}),
const SizedBox(height: 16),
Row(children: [
Expanded(child: Divider()),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(L10n.of(context).or),
),
Expanded(child: Divider()),
]),
const SizedBox(height: 16),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).secondaryHeaderColor,
onPrimary: Theme.of(context).primaryColor,
), ),
icon: Icon(Icons.transfer_within_a_station_outlined), const SizedBox(height: 16),
label: Text(L10n.of(context).transferFromAnotherDevice), ElevatedButton.icon(
onPressed: () async { style: ElevatedButton.styleFrom(
final req = await showFutureLoadingDialog( primary: Theme.of(context).secondaryHeaderColor,
context: context, onPrimary: Colors.red,
future: () => widget ),
.client.userDeviceKeys[widget.client.userID] icon: Icon(Icons.delete_outlined),
.startVerification(), label: Text(L10n.of(context).securityKeyLost),
); onPressed: () async {
if (req.error != null) return; if (OkCancelResult.ok ==
await KeyVerificationDialog(request: req.result) await showOkCancelAlertDialog(
.show(context); useRootNavigator: false,
Navigator.of(context, rootNavigator: false).pop(); context: context,
}, title: L10n.of(context).securityKeyLost,
), message: L10n.of(context).wipeChatBackup,
const SizedBox(height: 16), okLabel: L10n.of(context).ok,
ElevatedButton.icon( cancelLabel: L10n.of(context).cancel,
style: ElevatedButton.styleFrom( isDestructiveAction: true,
primary: Theme.of(context).secondaryHeaderColor, )) {
onPrimary: Colors.red, _createBootstrap(true);
), }
icon: Icon(Icons.delete_outlined), },
label: Text(L10n.of(context).securityKeyLost), )
onPressed: () async { ],
if (OkCancelResult.ok == ),
await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context).securityKeyLost,
message: L10n.of(context).wipeChatBackup,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
isDestructiveAction: true,
)) {
_createBootstrap(true);
}
},
)
],
), ),
), ),
); );

Loading…
Cancel
Save