fix: Dialog using wrong Navigator
This commit is contained in:
parent
57f81a3aa3
commit
1a167bebe7
30 changed files with 240 additions and 193 deletions
|
|
@ -3,6 +3,7 @@ import 'package:famedlysdk/encryption.dart';
|
|||
import 'package:famedlysdk/encryption/utils/bootstrap.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/adaptive_flat_button.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
|
@ -15,17 +16,20 @@ 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
|
||||
? showCupertinoDialog(context: context, builder: (context) => this)
|
||||
: showDialog(context: context, builder: (context) => this);
|
||||
|
||||
final L10n l10n;
|
||||
final Client client;
|
||||
? showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
useRootNavigator: false,
|
||||
)
|
||||
: showDialog(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
useRootNavigator: false,
|
||||
);
|
||||
|
||||
@override
|
||||
_BootstrapDialogState createState() => _BootstrapDialogState();
|
||||
|
|
@ -52,7 +56,9 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
_wipe = wipe;
|
||||
titleText = null;
|
||||
_recoveryKeyStored = false;
|
||||
bootstrap = widget.client.encryption
|
||||
bootstrap = Matrix.of(context)
|
||||
.client
|
||||
.encryption
|
||||
.bootstrap(onUpdate: () => setState(() => null));
|
||||
});
|
||||
}
|
||||
|
|
@ -62,19 +68,19 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
_wipe ??= widget.wipe;
|
||||
final buttons = <AdaptiveFlatButton>[];
|
||||
Widget body = LinearProgressIndicator();
|
||||
titleText = widget.l10n.loadingPleaseWait;
|
||||
titleText = L10n.of(context).loadingPleaseWait;
|
||||
|
||||
if (bootstrap == null) {
|
||||
titleText = widget.l10n.chatBackup;
|
||||
body = Text(widget.l10n.chatBackupDescription);
|
||||
titleText = L10n.of(context).chatBackup;
|
||||
body = Text(L10n.of(context).chatBackupDescription);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.next),
|
||||
child: Text(L10n.of(context).next),
|
||||
onPressed: () => _createBootstrap(false),
|
||||
));
|
||||
} else if (bootstrap.newSsssKey?.recoveryKey != null &&
|
||||
_recoveryKeyStored == false) {
|
||||
final key = bootstrap.newSsssKey.recoveryKey;
|
||||
titleText = widget.l10n.securityKey;
|
||||
titleText = L10n.of(context).securityKey;
|
||||
body = Container(
|
||||
alignment: Alignment.center,
|
||||
width: 200,
|
||||
|
|
@ -89,11 +95,11 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.copyToClipboard),
|
||||
child: Text(L10n.of(context).copyToClipboard),
|
||||
onPressed: () => Clipboard.setData(ClipboardData(text: key)),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.next),
|
||||
child: Text(L10n.of(context).next),
|
||||
onPressed: () => setState(() => _recoveryKeyStored = true),
|
||||
));
|
||||
} else {
|
||||
|
|
@ -120,7 +126,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
case BootstrapState.openExistingSsss:
|
||||
_recoveryKeyStored = true;
|
||||
titleText =
|
||||
_recoveryKeyInputError ?? widget.l10n.pleaseEnterSecurityKey;
|
||||
_recoveryKeyInputError ?? L10n.of(context).pleaseEnterSecurityKey;
|
||||
body = PlatformInfos.isCupertinoStyle
|
||||
? CupertinoTextField(
|
||||
minLines: 2,
|
||||
|
|
@ -149,10 +155,11 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
if (OkCancelResult.ok ==
|
||||
await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: widget.l10n.securityKeyLost,
|
||||
message: widget.l10n.wipeChatBackup,
|
||||
okLabel: widget.l10n.ok,
|
||||
cancelLabel: widget.l10n.cancel,
|
||||
useRootNavigator: false,
|
||||
title: L10n.of(context).securityKeyLost,
|
||||
message: L10n.of(context).wipeChatBackup,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
isDestructiveAction: true,
|
||||
)) {
|
||||
_createBootstrap(true);
|
||||
|
|
@ -160,20 +167,18 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
},
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.transferFromAnotherDevice),
|
||||
child: Text(L10n.of(context).transferFromAnotherDevice),
|
||||
onPressed: () async {
|
||||
final req = await widget
|
||||
.client.userDeviceKeys[widget.client.userID]
|
||||
final req = await Matrix.of(context)
|
||||
.client
|
||||
.userDeviceKeys[Matrix.of(context).client.userID]
|
||||
.startVerification();
|
||||
await KeyVerificationDialog(
|
||||
request: req,
|
||||
l10n: widget.l10n,
|
||||
).show(context);
|
||||
Navigator.of(context).pop();
|
||||
await KeyVerificationDialog(request: req).show(context);
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
},
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.next),
|
||||
child: Text(L10n.of(context).next),
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
_recoveryKeyInputError = null;
|
||||
|
|
@ -187,7 +192,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
} catch (e, s) {
|
||||
Logs().w('Unable to unlock SSSS', e, s);
|
||||
setState(() => _recoveryKeyInputError =
|
||||
widget.l10n.oopsSomethingWentWrong);
|
||||
L10n.of(context).oopsSomethingWentWrong);
|
||||
} finally {
|
||||
setState(() => _recoveryKeyInputLoading = false);
|
||||
}
|
||||
|
|
@ -220,27 +225,29 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
break;
|
||||
case BootstrapState.askBadSsss:
|
||||
case BootstrapState.error:
|
||||
titleText = widget.l10n.oopsSomethingWentWrong;
|
||||
titleText = L10n.of(context).oopsSomethingWentWrong;
|
||||
body = ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(Icons.error_outline, color: Colors.red),
|
||||
title: Text(widget.l10n.oopsSomethingWentWrong),
|
||||
title: Text(L10n.of(context).oopsSomethingWentWrong),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.close),
|
||||
onPressed: () => Navigator.of(context).pop<bool>(false),
|
||||
child: Text(L10n.of(context).close),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false),
|
||||
));
|
||||
break;
|
||||
case BootstrapState.done:
|
||||
titleText = widget.l10n.everythingReady;
|
||||
titleText = L10n.of(context).everythingReady;
|
||||
body = ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(Icons.check_circle, color: Colors.green),
|
||||
title: Text(widget.l10n.keysCached),
|
||||
title: Text(L10n.of(context).keysCached),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.close),
|
||||
onPressed: () => Navigator.of(context).pop<bool>(false),
|
||||
child: Text(L10n.of(context).close),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false),
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,16 +12,21 @@ import '../../utils/beautify_string_extension.dart';
|
|||
|
||||
class KeyVerificationDialog extends StatefulWidget {
|
||||
Future<void> show(BuildContext context) => PlatformInfos.isCupertinoStyle
|
||||
? showCupertinoDialog(context: context, builder: (context) => this)
|
||||
: showDialog(context: context, builder: (context) => this);
|
||||
? showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
useRootNavigator: false,
|
||||
)
|
||||
: showDialog(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
useRootNavigator: false,
|
||||
);
|
||||
|
||||
final KeyVerification request;
|
||||
|
||||
final L10n l10n;
|
||||
|
||||
KeyVerificationDialog({
|
||||
this.request,
|
||||
@required this.l10n,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -92,7 +97,8 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
if (valid.error != null) {
|
||||
await showOkAlertDialog(
|
||||
context: context,
|
||||
message: widget.l10n.incorrectPassphraseOrKey,
|
||||
message: L10n.of(context).incorrectPassphraseOrKey,
|
||||
useRootNavigator: false,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
@ -100,7 +106,8 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
margin: EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(widget.l10n.askSSSSSign, style: TextStyle(fontSize: 20)),
|
||||
Text(L10n.of(context).askSSSSSign,
|
||||
style: TextStyle(fontSize: 20)),
|
||||
Container(height: 10),
|
||||
TextField(
|
||||
controller: textEditingController,
|
||||
|
|
@ -114,7 +121,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
maxLines: 1,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
hintText: widget.l10n.passphraseOrKey,
|
||||
hintText: L10n.of(context).passphraseOrKey,
|
||||
prefixStyle: TextStyle(color: Theme.of(context).primaryColor),
|
||||
suffixStyle: TextStyle(color: Theme.of(context).primaryColor),
|
||||
border: OutlineInputBorder(),
|
||||
|
|
@ -125,32 +132,33 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.submit),
|
||||
child: Text(L10n.of(context).submit),
|
||||
onPressed: () {
|
||||
input = textEditingController.text;
|
||||
checkInput();
|
||||
},
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.skip),
|
||||
child: Text(L10n.of(context).skip),
|
||||
onPressed: () => widget.request.openSSSS(skip: true),
|
||||
));
|
||||
break;
|
||||
case KeyVerificationState.askAccept:
|
||||
body = Container(
|
||||
child: Text(widget.l10n.askVerificationRequest(widget.request.userId),
|
||||
child: Text(
|
||||
L10n.of(context).askVerificationRequest(widget.request.userId),
|
||||
style: TextStyle(fontSize: 20)),
|
||||
margin: EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.accept),
|
||||
child: Text(L10n.of(context).accept),
|
||||
onPressed: () => widget.request.acceptVerification(),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.reject),
|
||||
child: Text(L10n.of(context).reject),
|
||||
onPressed: () {
|
||||
widget.request.rejectVerification().then((_) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
});
|
||||
},
|
||||
));
|
||||
|
|
@ -163,7 +171,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
: CircularProgressIndicator(),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
widget.l10n.waitingPartnerAcceptRequest,
|
||||
L10n.of(context).waitingPartnerAcceptRequest,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
|
|
@ -173,18 +181,19 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
.deviceKeys[widget.request.deviceId];
|
||||
if (key != null) {
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.verifyManual),
|
||||
child: Text(L10n.of(context).verifyManual),
|
||||
onPressed: () async {
|
||||
final result = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: widget.l10n.verifyManual,
|
||||
useRootNavigator: false,
|
||||
title: L10n.of(context).verifyManual,
|
||||
message: key.ed25519Key.beautified,
|
||||
);
|
||||
if (result == OkCancelResult.ok) {
|
||||
await key.setVerified(true);
|
||||
}
|
||||
await widget.request.cancel();
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
},
|
||||
));
|
||||
}
|
||||
|
|
@ -196,14 +205,14 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
// view for if "emoji" is a present sasType or not?
|
||||
String compareText;
|
||||
if (widget.request.sasTypes.contains('emoji')) {
|
||||
compareText = widget.l10n.compareEmojiMatch;
|
||||
compareText = L10n.of(context).compareEmojiMatch;
|
||||
compareWidget = TextSpan(
|
||||
children: widget.request.sasEmojis
|
||||
.map((e) => WidgetSpan(child: _Emoji(e)))
|
||||
.toList(),
|
||||
);
|
||||
} else {
|
||||
compareText = widget.l10n.compareNumbersMatch;
|
||||
compareText = L10n.of(context).compareNumbersMatch;
|
||||
final numbers = widget.request.sasNumbers;
|
||||
final numbstr = '${numbers[0]}-${numbers[1]}-${numbers[2]}';
|
||||
compareWidget =
|
||||
|
|
@ -228,18 +237,18 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
textColor: Colors.red,
|
||||
child: Text(widget.l10n.theyDontMatch),
|
||||
child: Text(L10n.of(context).theyDontMatch),
|
||||
onPressed: () => widget.request.rejectSas(),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.theyMatch),
|
||||
child: Text(L10n.of(context).theyMatch),
|
||||
onPressed: () => widget.request.acceptSas(),
|
||||
));
|
||||
break;
|
||||
case KeyVerificationState.waitingSas:
|
||||
var acceptText = widget.request.sasTypes.contains('emoji')
|
||||
? widget.l10n.waitingPartnerEmoji
|
||||
: widget.l10n.waitingPartnerNumbers;
|
||||
? L10n.of(context).waitingPartnerEmoji
|
||||
: L10n.of(context).waitingPartnerNumbers;
|
||||
body = Column(
|
||||
children: <Widget>[
|
||||
PlatformInfos.isCupertinoStyle
|
||||
|
|
@ -260,15 +269,15 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
Icon(Icons.check_circle_outlined, color: Colors.green, size: 200.0),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
widget.l10n.verifySuccess,
|
||||
L10n.of(context).verifySuccess,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.close),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(L10n.of(context).close),
|
||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
||||
));
|
||||
break;
|
||||
case KeyVerificationState.error:
|
||||
|
|
@ -284,8 +293,8 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
);
|
||||
buttons.add(FlatButton(
|
||||
child: Text(widget.l10n.close),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(L10n.of(context).close),
|
||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
|
@ -329,7 +338,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
);
|
||||
final title = Text(widget.l10n.verifyTitle);
|
||||
final title = Text(L10n.of(context).verifyTitle);
|
||||
final content = Scrollbar(
|
||||
isAlwaysShown: true,
|
||||
controller: _scrollController,
|
||||
|
|
|
|||
|
|
@ -8,14 +8,19 @@ class PermissionSliderDialog extends StatefulWidget {
|
|||
const PermissionSliderDialog({
|
||||
Key key,
|
||||
this.initialPermission = 0,
|
||||
@required this.l10n,
|
||||
}) : super(key: key);
|
||||
|
||||
final L10n l10n;
|
||||
|
||||
Future<int> show(BuildContext context) => PlatformInfos.isCupertinoStyle
|
||||
? showCupertinoDialog<int>(context: context, builder: (context) => this)
|
||||
: showDialog<int>(context: context, builder: (context) => this);
|
||||
? showCupertinoDialog<int>(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
useRootNavigator: false,
|
||||
)
|
||||
: showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
useRootNavigator: false,
|
||||
);
|
||||
|
||||
final int initialPermission;
|
||||
@override
|
||||
|
|
@ -46,7 +51,7 @@ class _PermissionSliderDialogState extends State<PermissionSliderDialog> {
|
|||
min: 0.0,
|
||||
);
|
||||
final title = Text(
|
||||
widget.l10n.setPermissionsLevel,
|
||||
L10n.of(context).setPermissionsLevel,
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
final content = Column(
|
||||
|
|
@ -54,9 +59,9 @@ class _PermissionSliderDialogState extends State<PermissionSliderDialog> {
|
|||
children: [
|
||||
Text('Level: ' +
|
||||
(_permission == 100
|
||||
? '$_permission (${widget.l10n.admin})'
|
||||
? '$_permission (${L10n.of(context).admin})'
|
||||
: _permission >= 50
|
||||
? '$_permission (${widget.l10n.moderator})'
|
||||
? '$_permission (${L10n.of(context).moderator})'
|
||||
: _permission.toString())),
|
||||
Container(
|
||||
height: 56,
|
||||
|
|
@ -66,12 +71,14 @@ class _PermissionSliderDialogState extends State<PermissionSliderDialog> {
|
|||
);
|
||||
final buttons = [
|
||||
AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.cancel),
|
||||
onPressed: () => Navigator.of(context).pop<int>(null),
|
||||
child: Text(L10n.of(context).cancel),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<int>(null),
|
||||
),
|
||||
AdaptiveFlatButton(
|
||||
child: Text(widget.l10n.confirm),
|
||||
onPressed: () => Navigator.of(context).pop<int>(_permission),
|
||||
child: Text(L10n.of(context).confirm),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<int>(_permission),
|
||||
),
|
||||
];
|
||||
if (PlatformInfos.isCupertinoStyle) {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,7 @@ import 'package:flutter_sound_lite/flutter_sound.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class RecordingDialog extends StatefulWidget {
|
||||
final L10n l10n;
|
||||
|
||||
const RecordingDialog({
|
||||
@required this.l10n,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
|
|
@ -76,7 +73,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
Widget build(BuildContext context) {
|
||||
if (error) {
|
||||
Timer(Duration(seconds: 1), () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
});
|
||||
}
|
||||
const maxDecibalWidth = 64.0;
|
||||
|
|
@ -101,7 +98,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${widget.l10n.recording}: $time',
|
||||
'${L10n.of(context).recording}: $time',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
|
|
@ -112,17 +109,17 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(
|
||||
widget.l10n.cancel.toUpperCase(),
|
||||
L10n.of(context).cancel.toUpperCase(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).textTheme.bodyText2.color.withAlpha(150),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(widget.l10n.send.toUpperCase()),
|
||||
Text(L10n.of(context).send.toUpperCase()),
|
||||
SizedBox(width: 4),
|
||||
Icon(Icons.send_outlined, size: 15),
|
||||
],
|
||||
|
|
@ -130,7 +127,8 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
onPressed: () async {
|
||||
await _recorderSubscription?.cancel();
|
||||
await flutterSound.stopRecorder();
|
||||
Navigator.of(context).pop<String>(_recordedPath);
|
||||
Navigator.of(context, rootNavigator: false)
|
||||
.pop<String>(_recordedPath);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ import '../../utils/resize_image.dart';
|
|||
class SendFileDialog extends StatefulWidget {
|
||||
final Room room;
|
||||
final MatrixFile file;
|
||||
final L10n l10n;
|
||||
|
||||
const SendFileDialog({
|
||||
this.room,
|
||||
@required this.l10n,
|
||||
this.file,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
|
@ -40,13 +38,13 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var sendStr = widget.l10n.sendFile;
|
||||
var sendStr = L10n.of(context).sendFile;
|
||||
if (widget.file is MatrixImageFile) {
|
||||
sendStr = widget.l10n.sendImage;
|
||||
sendStr = L10n.of(context).sendImage;
|
||||
} else if (widget.file is MatrixAudioFile) {
|
||||
sendStr = widget.l10n.sendAudio;
|
||||
sendStr = L10n.of(context).sendAudio;
|
||||
} else if (widget.file is MatrixVideoFile) {
|
||||
sendStr = widget.l10n.sendVideo;
|
||||
sendStr = L10n.of(context).sendVideo;
|
||||
}
|
||||
Widget contentWidget;
|
||||
if (widget.file is MatrixImageFile) {
|
||||
|
|
@ -66,8 +64,8 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||
),
|
||||
InkWell(
|
||||
onTap: () => setState(() => origImage = !origImage),
|
||||
child: Text(
|
||||
widget.l10n.sendOriginal + ' (${widget.file.sizeString})'),
|
||||
child: Text(L10n.of(context).sendOriginal +
|
||||
' (${widget.file.sizeString})'),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
@ -80,14 +78,14 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||
content: contentWidget,
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(widget.l10n.cancel),
|
||||
child: Text(L10n.of(context).cancel),
|
||||
onPressed: () {
|
||||
// just close the dialog
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(widget.l10n.send),
|
||||
child: Text(L10n.of(context).send),
|
||||
onPressed: _isSending
|
||||
? null
|
||||
: () async {
|
||||
|
|
@ -96,7 +94,7 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||
});
|
||||
await showFutureLoadingDialog(
|
||||
context: context, future: () => _send());
|
||||
await Navigator.of(context).pop();
|
||||
await Navigator.of(context, rootNavigator: false).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue