mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
feat: Add more bootstrap features
This commit is contained in:
parent
7782784250
commit
e4db84a798
@ -10,11 +10,15 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
|
||||||
|
import 'key_verification_dialog.dart';
|
||||||
|
|
||||||
class BootstrapDialog extends StatefulWidget {
|
class BootstrapDialog extends StatefulWidget {
|
||||||
|
final bool wipe;
|
||||||
const BootstrapDialog({
|
const BootstrapDialog({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.l10n,
|
@required this.l10n,
|
||||||
@required this.client,
|
@required this.client,
|
||||||
|
this.wipe = false,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
Future<bool> show(BuildContext context) => PlatformInfos.isCupertinoStyle
|
Future<bool> show(BuildContext context) => PlatformInfos.isCupertinoStyle
|
||||||
@ -42,7 +46,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||||||
|
|
||||||
bool _recoveryKeyStored = false;
|
bool _recoveryKeyStored = false;
|
||||||
|
|
||||||
bool _wipe = false;
|
bool _wipe;
|
||||||
|
|
||||||
void _createBootstrap(bool wipe) {
|
void _createBootstrap(bool wipe) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -56,6 +60,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
_wipe ??= widget.wipe;
|
||||||
final buttons = <AdaptiveFlatButton>[];
|
final buttons = <AdaptiveFlatButton>[];
|
||||||
Widget body = LinearProgressIndicator();
|
Widget body = LinearProgressIndicator();
|
||||||
titleText = widget.l10n.loadingPleaseWait;
|
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(
|
buttons.add(AdaptiveFlatButton(
|
||||||
child: Text(widget.l10n.next),
|
child: Text(widget.l10n.next),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
@ -504,10 +504,28 @@ class _SettingsState extends State<Settings> {
|
|||||||
trailing: Icon(Icons.wb_cloudy_outlined),
|
trailing: Icon(Icons.wb_cloudy_outlined),
|
||||||
subtitle: Text(
|
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}'),
|
'${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(
|
onTap: () async {
|
||||||
l10n: L10n.of(context),
|
if (await client.encryption.keyManager.isCached()) {
|
||||||
client: Matrix.of(context).client,
|
if (OkCancelResult.ok ==
|
||||||
).show(context),
|
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),
|
Divider(thickness: 1),
|
||||||
|
Loading…
Reference in New Issue
Block a user