feat: Add more bootstrap features

This commit is contained in:
Christian Pauly 2021-02-13 14:26:03 +01:00
parent 7782784250
commit e4db84a798
2 changed files with 41 additions and 5 deletions

View File

@ -10,11 +10,15 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'key_verification_dialog.dart';
class BootstrapDialog extends StatefulWidget {
final bool wipe;
const BootstrapDialog({
Key key,
@required this.l10n,
@required this.client,
this.wipe = false,
}) : super(key: key);
Future<bool> show(BuildContext context) => PlatformInfos.isCupertinoStyle
@ -42,7 +46,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
bool _recoveryKeyStored = false;
bool _wipe = false;
bool _wipe;
void _createBootstrap(bool wipe) {
setState(() {
@ -56,6 +60,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
@override
Widget build(BuildContext context) {
_wipe ??= widget.wipe;
final buttons = <AdaptiveFlatButton>[];
Widget body = LinearProgressIndicator();
titleText = widget.l10n.loadingPleaseWait;
@ -155,6 +160,19 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
}
},
));
buttons.add(AdaptiveFlatButton(
child: Text('Transfer from another device'),
onPressed: () async {
final req = await widget
.client.userDeviceKeys[widget.client.userID]
.startVerification();
await KeyVerificationDialog(
request: req,
l10n: widget.l10n,
).show(context);
Navigator.of(context).pop();
},
));
buttons.add(AdaptiveFlatButton(
child: Text(widget.l10n.next),
onPressed: () async {

View File

@ -504,10 +504,28 @@ class _SettingsState extends State<Settings> {
trailing: Icon(Icons.wb_cloudy_outlined),
subtitle: Text(
'${client.encryption.keyManager.enabled ? L10n.of(context).onlineKeyBackupEnabled : L10n.of(context).onlineKeyBackupDisabled}\n${client.encryption.crossSigning.enabled ? L10n.of(context).crossSigningEnabled : L10n.of(context).crossSigningDisabled}'),
onTap: () => BootstrapDialog(
l10n: L10n.of(context),
client: Matrix.of(context).client,
).show(context),
onTap: () async {
if (await client.encryption.keyManager.isCached()) {
if (OkCancelResult.ok ==
await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).keysCached,
message:
'Wipe your chat backup to create a new security key?',
isDestructiveAction: true,
)) {
return BootstrapDialog(
l10n: L10n.of(context),
client: Matrix.of(context).client,
wipe: true,
).show(context);
}
}
return BootstrapDialog(
l10n: L10n.of(context),
client: Matrix.of(context).client,
).show(context);
},
),
},
Divider(thickness: 1),