fix: column design for bootstrap

This commit is contained in:
Krille Fear 2021-10-10 13:35:16 +02:00
parent 741d4ddba3
commit eca3905e0c
1 changed files with 136 additions and 131 deletions

View File

@ -1,4 +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: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';
@ -91,40 +92,42 @@ 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 Scaffold( return OnePageCard(
appBar: AppBar( child: Scaffold(
leading: IconButton( appBar: AppBar(
icon: Icon(Icons.close), leading: IconButton(
onPressed: Navigator.of(context).pop, icon: Icon(Icons.close),
onPressed: Navigator.of(context).pop,
),
title: Text(L10n.of(context).securityKey),
), ),
title: Text(L10n.of(context).securityKey), body: ListView(
), padding: const EdgeInsets.all(16.0),
body: ListView( children: [
padding: const EdgeInsets.all(16.0), TextField(
children: [ minLines: 4,
TextField( maxLines: 4,
minLines: 4, readOnly: true,
maxLines: 4, controller: TextEditingController(text: key),
readOnly: true,
controller: TextEditingController(text: key),
),
const SizedBox(height: 16),
ElevatedButton.icon(
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), 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),
),
],
),
), ),
); );
} else { } else {
@ -158,109 +161,111 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
break; break;
case BootstrapState.openExistingSsss: case BootstrapState.openExistingSsss:
_recoveryKeyStored = true; _recoveryKeyStored = true;
return Scaffold( return OnePageCard(
appBar: AppBar( child: Scaffold(
leading: IconButton( appBar: AppBar(
icon: Icon(Icons.close), leading: IconButton(
onPressed: Navigator.of(context).pop, icon: Icon(Icons.close),
onPressed: Navigator.of(context).pop,
),
title: Text(L10n.of(context).pleaseEnterSecurityKey),
), ),
title: Text(L10n.of(context).pleaseEnterSecurityKey), body: ListView(
), padding: const EdgeInsets.all(16.0),
body: ListView( children: [
padding: const EdgeInsets.all(16.0), TextField(
children: [ minLines: 4,
TextField( maxLines: 4,
minLines: 4, autofocus: true,
maxLines: 4, autocorrect: false,
autofocus: true, autofillHints: _recoveryKeyInputLoading
autocorrect: false, ? null
autofillHints: _recoveryKeyInputLoading : [AutofillHints.password],
? null controller: _recoveryKeyTextEditingController,
: [AutofillHints.password], decoration: InputDecoration(
controller: _recoveryKeyTextEditingController, hintText: 'Abc123 Def456',
decoration: InputDecoration( labelText: L10n.of(context).securityKey,
hintText: 'Abc123 Def456', errorText: _recoveryKeyInputError,
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 = const SizedBox(height: 16),
L10n.of(context).oopsSomethingWentWrong); ElevatedButton.icon(
} finally { style: ElevatedButton.styleFrom(
setState(() => _recoveryKeyInputLoading = false); primary: Theme.of(context).secondaryHeaderColor,
onPrimary: Colors.red,
),
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);
} }
}), },
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 {
final req = await showFutureLoadingDialog(
context: context,
future: () => widget
.client.userDeviceKeys[widget.client.userID]
.startVerification(),
);
if (req.error != null) return;
await KeyVerificationDialog(request: req.result)
.show(context);
Navigator.of(context, rootNavigator: false).pop();
},
),
const SizedBox(height: 16),
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).secondaryHeaderColor,
onPrimary: Colors.red,
),
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);
}
},
)
],
), ),
); );
case BootstrapState.askWipeCrossSigning: case BootstrapState.askWipeCrossSigning: