#532 use google-free dependency for pin input
This commit is contained in:
parent
f0bf70e3b1
commit
a8159f9525
5 changed files with 51 additions and 38 deletions
|
@ -266,9 +266,9 @@ class Dependencies {
|
|||
sourceUrl: 'https://github.com/diegoveloper/flutter_percent_indicator',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Pinput',
|
||||
name: 'Pin Code Fields',
|
||||
license: mit,
|
||||
sourceUrl: 'https://github.com/Tkko/Flutter_PinPut',
|
||||
sourceUrl: 'https://github.com/adar2378/pin_code_fields',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Provider',
|
||||
|
|
|
@ -44,7 +44,18 @@ class _PasswordDialogState extends State<PasswordDialog> {
|
|||
onSubmitted: (password) {
|
||||
if (widget.needConfirmation) {
|
||||
if (_confirming) {
|
||||
Navigator.maybeOf(context)?.pop<String>(_firstPassword == password ? password : null);
|
||||
final match = _firstPassword == password;
|
||||
Navigator.maybeOf(context)?.pop<String>(match ? password : null);
|
||||
if (!match) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AvesDialog(
|
||||
content: Text(context.l10n.genericFailureFeedback),
|
||||
actions: const [OkButton()],
|
||||
),
|
||||
routeSettings: const RouteSettings(name: AvesDialog.warningRouteName),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
_firstPassword = password;
|
||||
_controller.clear();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:aves/widgets/common/extensions/build_context.dart';
|
||||
import 'package:aves/widgets/dialogs/aves_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinput/pinput.dart';
|
||||
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||
|
||||
class PinDialog extends StatefulWidget {
|
||||
static const routeName = '/dialog/pin';
|
||||
|
@ -19,18 +19,12 @@ class PinDialog extends StatefulWidget {
|
|||
|
||||
class _PinDialogState extends State<PinDialog> {
|
||||
final _controller = TextEditingController();
|
||||
final _focusNode = FocusNode();
|
||||
bool _confirming = false;
|
||||
String? _firstPin;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_focusNode.requestFocus();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return AvesDialog(
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -38,24 +32,48 @@ class _PinDialogState extends State<PinDialog> {
|
|||
Text(_confirming ? context.l10n.pinDialogConfirm : context.l10n.pinDialogEnter),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Pinput(
|
||||
child: PinCodeTextField(
|
||||
appContext: context,
|
||||
length: 4,
|
||||
controller: _controller,
|
||||
obscureText: true,
|
||||
onChanged: (v) {},
|
||||
onCompleted: (pin) {
|
||||
if (widget.needConfirmation) {
|
||||
if (_confirming) {
|
||||
Navigator.maybeOf(context)?.pop<String>(_firstPin == pin ? pin : null);
|
||||
final match = _firstPin == pin;
|
||||
Navigator.maybeOf(context)?.pop<String>(match ? pin : null);
|
||||
if (!match) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AvesDialog(
|
||||
content: Text(context.l10n.genericFailureFeedback),
|
||||
actions: const [OkButton()],
|
||||
),
|
||||
routeSettings: const RouteSettings(name: AvesDialog.warningRouteName),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
_firstPin = pin;
|
||||
_controller.clear();
|
||||
setState(() => _confirming = true);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _focusNode.requestFocus());
|
||||
}
|
||||
} else {
|
||||
Navigator.maybeOf(context)?.pop<String>(pin);
|
||||
}
|
||||
},
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
obscureText: true,
|
||||
animationType: AnimationType.scale,
|
||||
keyboardType: TextInputType.number,
|
||||
autoFocus: true,
|
||||
autoDismissKeyboard: !widget.needConfirmation || _confirming,
|
||||
pinTheme: PinTheme(
|
||||
activeColor: colorScheme.onBackground,
|
||||
inactiveColor: colorScheme.onBackground,
|
||||
selectedColor: colorScheme.secondary,
|
||||
selectedFillColor: colorScheme.secondary,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
shape: PinCodeFieldShape.box,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
24
pubspec.lock
24
pubspec.lock
|
@ -917,14 +917,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
pinput:
|
||||
pin_code_fields:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: pinput
|
||||
sha256: e6aabd1571dde622f9b942f62ac2c80f84b0b50f95fa209a93e78f7d621e1f82
|
||||
name: pin_code_fields
|
||||
sha256: c8652519d14688f3fe2a8288d86910a46aa0b9046d728f292d3bf6067c31b4c7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.23"
|
||||
version: "7.4.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1162,14 +1162,6 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
smart_auth:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: smart_auth
|
||||
sha256: "8cfaec55b77d5930ed1666bb7ae70db5bade099bb1422401386853b400962113"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
smooth_page_indicator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -1339,14 +1331,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
universal_platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: universal_platform
|
||||
sha256: d315be0f6641898b280ffa34e2ddb14f3d12b1a37882557869646e0cc363d0cc
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0+1"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -83,7 +83,7 @@ dependencies:
|
|||
pdf:
|
||||
percent_indicator:
|
||||
permission_handler:
|
||||
pinput:
|
||||
pin_code_fields:
|
||||
printing:
|
||||
proj4dart:
|
||||
provider:
|
||||
|
|
Loading…
Reference in a new issue