fix: Bootstrap in columnview

This commit is contained in:
Christian Pauly 2021-03-06 10:03:01 +01:00
parent 3a816d13e2
commit bcd2a035d1
2 changed files with 15 additions and 10 deletions

View File

@ -3,7 +3,6 @@ import 'package:famedlysdk/encryption.dart';
import 'package:famedlysdk/encryption/utils/bootstrap.dart'; import 'package:famedlysdk/encryption/utils/bootstrap.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/adaptive_flat_button.dart'; import 'package:fluffychat/components/dialogs/adaptive_flat_button.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -14,9 +13,11 @@ import 'key_verification_dialog.dart';
class BootstrapDialog extends StatefulWidget { class BootstrapDialog extends StatefulWidget {
final bool wipe; final bool wipe;
final Client client;
const BootstrapDialog({ const BootstrapDialog({
Key key, Key key,
this.wipe = false, this.wipe = false,
@required this.client,
}) : super(key: key); }) : super(key: key);
Future<bool> show(BuildContext context) => PlatformInfos.isCupertinoStyle Future<bool> show(BuildContext context) => PlatformInfos.isCupertinoStyle
@ -56,9 +57,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
_wipe = wipe; _wipe = wipe;
titleText = null; titleText = null;
_recoveryKeyStored = false; _recoveryKeyStored = false;
bootstrap = Matrix.of(context) bootstrap = widget.client.encryption
.client
.encryption
.bootstrap(onUpdate: () => setState(() => null)); .bootstrap(onUpdate: () => setState(() => null));
}); });
} }
@ -177,9 +176,8 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
buttons.add(AdaptiveFlatButton( buttons.add(AdaptiveFlatButton(
label: L10n.of(context).transferFromAnotherDevice, label: L10n.of(context).transferFromAnotherDevice,
onPressed: () async { onPressed: () async {
final req = await Matrix.of(context) final req = await widget
.client .client.userDeviceKeys[widget.client.userID]
.userDeviceKeys[Matrix.of(context).client.userID]
.startVerification(); .startVerification();
await KeyVerificationDialog(request: req).show(context); await KeyVerificationDialog(request: req).show(context);
Navigator.of(context, rootNavigator: false).pop(); Navigator.of(context, rootNavigator: false).pop();

View File

@ -397,7 +397,9 @@ class _SettingsState extends State<Settings> {
style: TextStyle(color: Colors.red), style: TextStyle(color: Colors.red),
), ),
onPressed: () async { onPressed: () async {
await BootstrapDialog().show(context); await BootstrapDialog(
client: Matrix.of(context).client,
).show(context);
AdaptivePageLayout.of(context).popUntilIsFirst(); AdaptivePageLayout.of(context).popUntilIsFirst();
}, },
); );
@ -579,11 +581,16 @@ class _SettingsState extends State<Settings> {
cancelLabel: L10n.of(context).cancel, cancelLabel: L10n.of(context).cancel,
useRootNavigator: false, useRootNavigator: false,
)) { )) {
await BootstrapDialog(wipe: true).show(context); await BootstrapDialog(
client: Matrix.of(context).client,
wipe: true,
).show(context);
} }
return; return;
} }
await BootstrapDialog().show(context); await BootstrapDialog(
client: Matrix.of(context).client,
).show(context);
}, },
), ),
}, },