Merge pull request #776 from cake-tech/CW-309-allow-pin-keyboard-entry-on-macos

Allow Keyboard usage on PIN screen
This commit is contained in:
Omar Hatem 2023-02-10 22:09:55 +02:00 committed by GitHub
commit 2623546b5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 142 additions and 123 deletions

View file

@ -2,6 +2,7 @@ import 'package:cake_wallet/utils/show_bar.dart';
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter/services.dart';
class PinCodeWidget extends StatefulWidget {
PinCodeWidget(
@ -117,7 +118,22 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
);
return Container(
return RawKeyboardListener(
focusNode: FocusNode(),
autofocus: true,
onKey: (keyEvent) {
if (keyEvent is RawKeyDownEvent) {
if (keyEvent.logicalKey.keyLabel == "Backspace") {
_pop();
return;
}
int? number = int.tryParse(keyEvent.character ?? '');
if (number != null) {
_push(number);
}
}
},
child: Container(
color: Theme.of(context).backgroundColor,
padding: EdgeInsets.only(left: 40.0, right: 40.0, bottom: 40.0),
child: Column(children: <Widget>[
@ -236,9 +252,10 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
left: marginLeft, right: marginRight),
child: TextButton(
onPressed: () => _pop(),
// FIX-ME: Style
//color: Theme.of(context).backgroundColor,
//shape: CircleBorder(),
style: TextButton.styleFrom(
backgroundColor: Theme.of(context).backgroundColor,
shape: CircleBorder(),
),
child: deleteIconImage,
),
);
@ -251,9 +268,10 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
left: marginLeft, right: marginRight),
child: TextButton(
onPressed: () => _push(index),
// FIX-ME: Style
//color: Theme.of(context).backgroundColor,
//shape: CircleBorder(),
style: TextButton.styleFrom(
backgroundColor: Theme.of(context).backgroundColor,
shape: CircleBorder(),
),
child: Text('$index',
style: TextStyle(
fontSize: 30.0,
@ -268,6 +286,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
)
: null))
]),
),
);
}

View file

@ -74,7 +74,7 @@ class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget {
children: [
if (leading != null) Flexible(child: leading!),
if (middle != null) middle!,
if (trailing != null) trailing!,
trailing ?? const SizedBox(),
],
),
),