refactor: Switch to TextButton
This commit is contained in:
parent
ad2b523e3b
commit
e0716f643c
13 changed files with 45 additions and 67 deletions
|
|
@ -3,13 +3,13 @@ import 'package:flutter/cupertino.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class AdaptiveFlatButton extends StatelessWidget {
|
||||
final Widget child;
|
||||
final String label;
|
||||
final Color textColor;
|
||||
final Function onPressed;
|
||||
|
||||
const AdaptiveFlatButton({
|
||||
Key key,
|
||||
this.child,
|
||||
@required this.label,
|
||||
this.textColor,
|
||||
this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
|
@ -18,14 +18,16 @@ class AdaptiveFlatButton extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
if (PlatformInfos.isCupertinoStyle) {
|
||||
return CupertinoDialogAction(
|
||||
child: child,
|
||||
child: Text(label),
|
||||
onPressed: onPressed,
|
||||
textStyle: textColor != null ? TextStyle(color: textColor) : null,
|
||||
);
|
||||
}
|
||||
return FlatButton(
|
||||
child: child,
|
||||
textColor: textColor,
|
||||
return TextButton(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(color: textColor),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
titleText = L10n.of(context).chatBackup;
|
||||
body = Text(L10n.of(context).chatBackupDescription);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).next),
|
||||
label: L10n.of(context).next,
|
||||
onPressed: () => _createBootstrap(false),
|
||||
));
|
||||
} else if (bootstrap.newSsssKey?.recoveryKey != null &&
|
||||
|
|
@ -95,11 +95,11 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).copyToClipboard),
|
||||
label: L10n.of(context).copyToClipboard,
|
||||
onPressed: () => Clipboard.setData(ClipboardData(text: key)),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).next),
|
||||
label: L10n.of(context).next,
|
||||
onPressed: () => setState(() => _recoveryKeyStored = true),
|
||||
));
|
||||
} else {
|
||||
|
|
@ -150,7 +150,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
textColor: Colors.red,
|
||||
child: Text('Lost security key'),
|
||||
label: 'Lost security key',
|
||||
onPressed: () async {
|
||||
if (OkCancelResult.ok ==
|
||||
await showOkCancelAlertDialog(
|
||||
|
|
@ -167,7 +167,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
},
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).transferFromAnotherDevice),
|
||||
label: L10n.of(context).transferFromAnotherDevice,
|
||||
onPressed: () async {
|
||||
final req = await Matrix.of(context)
|
||||
.client
|
||||
|
|
@ -178,7 +178,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
},
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).next),
|
||||
label: L10n.of(context).next,
|
||||
onPressed: () async {
|
||||
setState(() {
|
||||
_recoveryKeyInputError = null;
|
||||
|
|
@ -232,7 +232,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
title: Text(L10n.of(context).oopsSomethingWentWrong),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).close),
|
||||
label: L10n.of(context).close,
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false),
|
||||
));
|
||||
|
|
@ -245,7 +245,7 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
|
|||
title: Text(L10n.of(context).keysCached),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).close),
|
||||
label: L10n.of(context).close,
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<bool>(false),
|
||||
));
|
||||
|
|
|
|||
|
|
@ -132,14 +132,14 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).submit),
|
||||
label: L10n.of(context).submit,
|
||||
onPressed: () {
|
||||
input = textEditingController.text;
|
||||
checkInput();
|
||||
},
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).skip),
|
||||
label: L10n.of(context).skip,
|
||||
onPressed: () => widget.request.openSSSS(skip: true),
|
||||
));
|
||||
break;
|
||||
|
|
@ -151,11 +151,11 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
margin: EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).accept),
|
||||
label: L10n.of(context).accept,
|
||||
onPressed: () => widget.request.acceptVerification(),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).reject),
|
||||
label: L10n.of(context).reject,
|
||||
onPressed: () {
|
||||
widget.request.rejectVerification().then((_) {
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
|
|
@ -181,7 +181,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
.deviceKeys[widget.request.deviceId];
|
||||
if (key != null) {
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).verifyManual),
|
||||
label: L10n.of(context).verifyManual,
|
||||
onPressed: () async {
|
||||
final result = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
|
|
@ -237,11 +237,11 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
textColor: Colors.red,
|
||||
child: Text(L10n.of(context).theyDontMatch),
|
||||
label: L10n.of(context).theyDontMatch,
|
||||
onPressed: () => widget.request.rejectSas(),
|
||||
));
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).theyMatch),
|
||||
label: L10n.of(context).theyMatch,
|
||||
onPressed: () => widget.request.acceptSas(),
|
||||
));
|
||||
break;
|
||||
|
|
@ -276,7 +276,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
);
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).close),
|
||||
label: L10n.of(context).close,
|
||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
||||
));
|
||||
break;
|
||||
|
|
@ -292,8 +292,8 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
],
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
);
|
||||
buttons.add(FlatButton(
|
||||
child: Text(L10n.of(context).close),
|
||||
buttons.add(AdaptiveFlatButton(
|
||||
label: L10n.of(context).close,
|
||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
||||
));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ class _PermissionSliderDialogState extends State<PermissionSliderDialog> {
|
|||
);
|
||||
final buttons = [
|
||||
AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).cancel),
|
||||
label: L10n.of(context).cancel,
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<int>(null),
|
||||
),
|
||||
AdaptiveFlatButton(
|
||||
child: Text(L10n.of(context).confirm),
|
||||
label: L10n.of(context).confirm,
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop<int>(_permission),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(
|
||||
L10n.of(context).cancel.toUpperCase(),
|
||||
style: TextStyle(
|
||||
|
|
@ -116,7 +116,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
),
|
||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(L10n.of(context).send.toUpperCase()),
|
||||
|
|
|
|||
|
|
@ -77,14 +77,14 @@ class _SendFileDialogState extends State<SendFileDialog> {
|
|||
title: Text(sendStr),
|
||||
content: contentWidget,
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(L10n.of(context).cancel),
|
||||
onPressed: () {
|
||||
// just close the dialog
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text(L10n.of(context).send),
|
||||
onPressed: _isSending
|
||||
? null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue