From 8a0236e57cb1f06c54289b4c46e42bf8e05a2e6b Mon Sep 17 00:00:00 2001 From: Tkko <117541313+TornikeAt@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:13:21 +0400 Subject: [PATCH] Release 2.3.0 --- .flutter-plugins-dependencies | 2 +- CHANGELOG.md | 7 +++++++ README.md | 30 ++++++++++++++++++++++++++- example/lib/main.dart | 7 ++++--- example/lib/test_examples.dart | 24 ++++++++++++++++++++++ example/test/main_test.dart | 37 ++++++++++++++++++++++++++++++++++ pubspec.yaml | 12 ++++++++--- scripts/publish.sh | 2 +- 8 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 example/test/main_test.dart diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index bf5d69e..2065601 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.0.8/","native_build":true,"dependencies":[]}],"android":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.0.8/","native_build":true,"dependencies":[]}],"macos":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.0.8/","native_build":true,"dependencies":[]}],"linux":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.0.8/","native_build":true,"dependencies":[]}],"windows":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.0.8/","native_build":true,"dependencies":[]}],"web":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.0.8/","dependencies":[]}]},"dependencyGraph":[{"name":"smart_auth","dependencies":[]}],"date_created":"2023-05-12 11:53:42.026139","version":"3.10.0"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.1.1/","native_build":true,"dependencies":[]}],"android":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.1.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.1.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.1.1/","native_build":true,"dependencies":[]}],"windows":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.1.1/","native_build":true,"dependencies":[]}],"web":[{"name":"smart_auth","path":"/Users/dev/.pub-cache/hosted/pub.dev/smart_auth-1.1.1/","dependencies":[]}]},"dependencyGraph":[{"name":"smart_auth","dependencies":[]}],"date_created":"2023-07-24 19:06:27.432471","version":"3.10.5"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f08969..1d4fd0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +#### 2.3.0 · 24/07/2023 + +- Fixed AGP 4.2<= compatibility in smart_auth +- Updated SDK constraints +- Updated default SMS code matcher regex length to 8 digits + + #### 2.2.31 · 22/02/2023 ### Added: diff --git a/README.md b/README.md index 8aca038..f9313dc 100644 --- a/README.md +++ b/README.md @@ -300,8 +300,36 @@ return Form( ); ``` -## Properties +## FAQ + +#### autofill isn't working on iOS? + +- Make sure you are using real device, not simulator +- Temporary replace Pinput with TextField, and check if autofill works. If, not it's probably a + problem with SMS you are getting, autofill doesn't work with most of the languages +- If you are using non stable version of Flutter that might be cause because something might be + broken inside the Framework + +#### are you using firebase_auth? + +Set `androidSmsAutofillMethod` to `AndroidSmsAutofillMethod.none` and set `controller'`s value in `verificationCompleted` callback, here is an example code: +``` dart + Pinput( + androidSmsAutofillMethod: AndroidSmsAutofillMethod.none, + controller: pinController, + ); + + await FirebaseAuth.instance.verifyPhoneNumber( + verificationCompleted: (PhoneAuthCredential credential) { + pinController.setText(credential.smsCode); + }, + verificationFailed: (FirebaseAuthException e) {}, + codeSent: (String verificationId, int? resendToken) {}, + codeAutoRetrievalTimeout: (String verificationId) {}, + ); +``` +## Properties ```dart class Pinput extends StatefulWidget { const Pinput({ diff --git a/example/lib/main.dart b/example/lib/main.dart index 8c7f9d6..8ad9b33 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:pinput/pinput.dart'; void main() { @@ -17,8 +16,10 @@ void main() { color: Color.fromRGBO(30, 60, 87, 1), ), ), - body: - const FractionallySizedBox(widthFactor: 1, child: PinputExample()), + body: const FractionallySizedBox( + widthFactor: 1, + child: PinputExample(), + ), ), ), ); diff --git a/example/lib/test_examples.dart b/example/lib/test_examples.dart index 55b0196..6fd25b7 100644 --- a/example/lib/test_examples.dart +++ b/example/lib/test_examples.dart @@ -48,3 +48,27 @@ class _ExampleState extends State { ); } } + +class ErrorStateExample extends StatefulWidget { + const ErrorStateExample({Key? key}) : super(key: key); + + @override + State createState() => _ErrorStateExampleState(); +} + +class _ErrorStateExampleState extends State { + bool _hasError = false; + + Future _validate(String value) async { + await Future.delayed(const Duration(seconds: 2)); + setState(() => _hasError = value == '1111'); + } + + @override + Widget build(BuildContext context) { + return Pinput( + forceErrorState: _hasError, + onCompleted: _validate, + ); + } +} diff --git a/example/test/main_test.dart b/example/test/main_test.dart new file mode 100644 index 0000000..7bb0064 --- /dev/null +++ b/example/test/main_test.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pinput/pinput.dart'; + +void main() { + testWidgets('Can enter value', (WidgetTester tester) async { + String? fieldValue; + int called = 0; + final controller = TextEditingController(); + final focusNode = FocusNode(); + + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Pinput( + controller: controller, + onChanged: (value) { + fieldValue = value; + called++; + }, + ), + ), + ), + ); + + focusNode.requestFocus(); + await tester.pump(); + + expect(fieldValue, isNull); + expect(called, 0); + + await tester.enterText(find.byType(Pinput), '1111'); + await tester.testTextInput.receiveAction(TextInputAction.done); + expect(fieldValue, equals('1111')); + expect(called, 1); + }); +} diff --git a/pubspec.yaml b/pubspec.yaml index c6acd0b..dd36326 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,9 +1,15 @@ name: pinput -version: 2.2.31 +version: 2.3.0 description: Pin code input (OTP) text field, iOS SMS autofill, Android SMS autofill One Time Code, Password, Passcode, Captcha, Security, Coupon, Wowcher, 2FA, Two step verification homepage: https://github.com/Tkko/Flutter_PinPut repository: https://github.com/Tkko/Flutter_PinPut issue_tracker: https://github.com/Tkko/Flutter_Pinput/issues +topics: + - otp + - pin-input + - pin-code + - passcode + - sms-autofill screenshots: - description: 'Pin input example' path: example/pinput_demo_1.webp @@ -13,14 +19,14 @@ funding: - https://ko-fi.com/flutterman environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' flutter: ">=3.7.0" dependencies: flutter: sdk: flutter - smart_auth: ^1.0.8 + smart_auth: ^1.1.1 universal_platform: ^1.0.0+1 dev_dependencies: diff --git a/scripts/publish.sh b/scripts/publish.sh index 0984f58..3683d7f 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -35,4 +35,4 @@ format_and_analyze run_dart_doc #host_docs run_pana -publish +#publish