From 5ba333ab4e393a00899e4c7011769812f300e05f Mon Sep 17 00:00:00 2001 From: Tkko Date: Sat, 10 Feb 2024 07:33:03 -0800 Subject: [PATCH] Release 4.0.4: - Upgraded smart_auth - Updated readme - Improved docs --- .flutter-plugins-dependencies | 2 +- CHANGELOG.md | 5 ++ README.md | 12 +++++ analysis_options.yaml | 1 + example/ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/lib/test_examples.dart | 44 ++++++++++++++++ lib/src/models/pin_theme.dart | 6 +++ lib/src/pinput.dart | 2 + lib/src/utils/enums.dart | 50 +++++++++++++++++++ lib/src/utils/extensions.dart | 7 +-- lib/src/widgets/widgets.dart | 2 + pubspec.yaml | 2 +- 13 files changed, 130 insertions(+), 7 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index dc7de18..c8efc85 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.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-08-25 10:25:28.531908","version":"3.13.1"} \ 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/tornike/.pub-cache/hosted/pub.dev/smart_auth-2.0.0/","native_build":true,"dependencies":[]}],"android":[{"name":"smart_auth","path":"/Users/tornike/.pub-cache/hosted/pub.dev/smart_auth-2.0.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"smart_auth","path":"/Users/tornike/.pub-cache/hosted/pub.dev/smart_auth-2.0.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"smart_auth","path":"/Users/tornike/.pub-cache/hosted/pub.dev/smart_auth-2.0.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"smart_auth","path":"/Users/tornike/.pub-cache/hosted/pub.dev/smart_auth-2.0.0/","native_build":true,"dependencies":[]}],"web":[{"name":"smart_auth","path":"/Users/tornike/.pub-cache/hosted/pub.dev/smart_auth-2.0.0/","dependencies":[]}]},"dependencyGraph":[{"name":"smart_auth","dependencies":[]}],"date_created":"2024-02-10 07:31:36.266830","version":"3.16.9"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6646aad..3e02b9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +#### 4.0.0 · 10/02/2024 +- Fixed RECEIVER_EXPORTED exception in android SDK 34 PR +- Fix "Namespace not specified" error when upgrading to AGP 8.0 PR +- Updated readme + #### 3.0.1 · 25/08/2023 - Fixed contextMenuBuilder diff --git a/README.md b/README.md index 7570395..765fd60 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,18 @@ Don't forget to give it a star ⭐ ## Getting Started + +We should set project kotlin version to 1.8.0 or above because of the new requirement for sdk 34 `RECEIVER_EXPORTED`. Or we would get **duplicate class** error in different kotlin versions. + +so in the android level `build.gradle` file update the kotlin version like below: +``` +// android/build.gradle + +buildscript { + ext.kotlin_version = '1.8.0' +} +``` + The pin has 6 states `default` `focused`, `submitted`, `following`, `disabled`, `error`, you can customize each state by specifying theme parameter. Pin smoothly animates from one state to another automatically. `PinTheme Class` diff --git a/analysis_options.yaml b/analysis_options.yaml index 477fbb2..158e329 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -29,3 +29,4 @@ linter: unnecessary_new: true prefer_single_quotes: true require_trailing_commas: true + public_member_api_docs: true diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index e3861db..c6dc9a0 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a..a6b826d 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ { ); } } + +class HeightExample extends StatelessWidget { + const HeightExample({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final defaultPinTheme = PinTheme( + width: 40, + height: 105, + textStyle: const TextStyle( + fontSize: 22, + color: Color.fromRGBO(30, 60, 87, 1), + fontWeight: FontWeight.bold, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.black, + ), + ); + + return Pinput( + length: 6, + defaultPinTheme: defaultPinTheme, + focusedPinTheme: defaultPinTheme.copyWith( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.red, + ), + ), + submittedPinTheme: defaultPinTheme.copyWith( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.green, + ), + ), + followingPinTheme: defaultPinTheme.copyWith( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.blue, + ), + ), + ); + } +} diff --git a/lib/src/models/pin_theme.dart b/lib/src/models/pin_theme.dart index 88917ba..4e3fb6f 100644 --- a/lib/src/models/pin_theme.dart +++ b/lib/src/models/pin_theme.dart @@ -46,6 +46,8 @@ class PinTheme { /// The decoration of each [Pinput] submitted field final BoxDecoration? decoration; + /// Theme of the individual pin items for following states: + /// default, focused pin, submitted pin, following pin, disabled pin and error pin const PinTheme({ this.width, this.height, @@ -56,6 +58,7 @@ class PinTheme { this.constraints, }); + /// Merge two [PinTheme] into one PinTheme apply({required PinTheme theme}) { return PinTheme( width: this.width ?? theme.width, @@ -68,6 +71,7 @@ class PinTheme { ); } + /// Create a new [PinTheme] from the current instance PinTheme copyWith({ double? width, double? height, @@ -88,6 +92,7 @@ class PinTheme { ); } + /// Create a new [PinTheme] from the current instance with new decoration PinTheme copyDecorationWith({ Color? color, DecorationImage? image, @@ -113,6 +118,7 @@ class PinTheme { ); } + /// Create a new [PinTheme] from the current instance with new border PinTheme copyBorderWith({required Border border}) { assert(decoration != null); return copyWith( diff --git a/lib/src/pinput.dart b/lib/src/pinput.dart index 23d5255..3a70b51 100644 --- a/lib/src/pinput.dart +++ b/lib/src/pinput.dart @@ -46,6 +46,7 @@ part 'widgets/_pinput_selection_gesture_detector_builder.dart'; /// - Close Keyboard After Completion /// - Beautiful [Examples](https://github.com/Tkko/Flutter_PinPut/tree/master/example/lib/demo) class Pinput extends StatefulWidget { + /// Creates a PinPut widget const Pinput({ this.length = PinputConstants._defaultLength, this.defaultPinTheme, @@ -251,6 +252,7 @@ class Pinput extends StatefulWidget { /// Default cursor '|' or [cursor] final bool showCursor; + /// Whether to enable cursor animation final bool isCursorAnimationEnabled; /// Whether to enable that the IME update personalized data such as typing history and user dictionary data. diff --git a/lib/src/utils/enums.dart b/lib/src/utils/enums.dart index ccbae57..137753e 100644 --- a/lib/src/utils/enums.dart +++ b/lib/src/utils/enums.dart @@ -27,20 +27,70 @@ enum AndroidSmsAutofillMethod { /// The animation type if Pin item enum PinAnimationType { + /// No animation none, + + /// Scale animation scale, + + /// Fade animation fade, + + /// Slide animation slide, + + /// Rotation animation rotation, } /// The vibration type when user types enum HapticFeedbackType { + /// No vibration disabled, + + /// Provides a haptic feedback corresponding a collision impact with a light mass. + /// + /// On iOS versions 10 and above, this uses a `UIImpactFeedbackGenerator` with + /// `UIImpactFeedbackStyleLight`. This call has no effects on iOS versions + /// below 10. + /// + /// On Android, this uses `HapticFeedbackConstants.VIRTUAL_KEY`. lightImpact, + + /// Provides a haptic feedback corresponding a collision impact with a medium mass. + /// + /// On iOS versions 10 and above, this uses a `UIImpactFeedbackGenerator` with + /// `UIImpactFeedbackStyleMedium`. This call has no effects on iOS versions + /// below 10. + /// + /// On Android, this uses `HapticFeedbackConstants.KEYBOARD_TAP`. mediumImpact, + + /// Provides a haptic feedback corresponding a collision impact with a heavy mass. + /// + /// On iOS versions 10 and above, this uses a `UIImpactFeedbackGenerator` with + /// `UIImpactFeedbackStyleHeavy`. This call has no effects on iOS versions + /// below 10. + /// + /// On Android, this uses `HapticFeedbackConstants.CONTEXT_CLICK` on API levels + /// 23 and above. This call has no effects on Android API levels below 23. heavyImpact, + + /// Provides a haptic feedback indication selection changing through discrete values. + /// + /// On iOS versions 10 and above, this uses a `UISelectionFeedbackGenerator`. + /// This call has no effects on iOS versions below 10. + /// + /// On Android, this uses `HapticFeedbackConstants.CLOCK_TICK`. selectionClick, + + /// Provides vibration haptic feedback to the user for a short duration. + /// + /// On iOS devices that support haptic feedback, this uses the default system + /// vibration value (`kSystemSoundID_Vibrate`). + /// + /// On Android, this uses the platform haptic feedback API to simulate a + /// response to a long press (`HapticFeedbackConstants.LONG_PRESS`). vibrate, } diff --git a/lib/src/utils/extensions.dart b/lib/src/utils/extensions.dart index 6e955cf..ed8eeda 100644 --- a/lib/src/utils/extensions.dart +++ b/lib/src/utils/extensions.dart @@ -12,15 +12,16 @@ part of '../pinput.dart'; /// ``` /// extension PinputControllerExt on TextEditingController { + /// The length of the Pinput value int get length => this.text.length; - // Sets Pinput value + /// Sets Pinput value void setText(String pin) { this.text = pin; this.moveCursorToEnd(); } - // Deletes the last character of Pinput value + /// Deletes the last character of Pinput value void delete() { if (text.isEmpty) return; final pin = this.text.substring(0, this.length - 1); @@ -28,7 +29,7 @@ extension PinputControllerExt on TextEditingController { this.moveCursorToEnd(); } - // Appends character at the end of the Pinput + /// Appends character at the end of the Pinput void append(String s, int maxLength) { if (this.length == maxLength) return; this.text = '${this.text}$s'; diff --git a/lib/src/widgets/widgets.dart b/lib/src/widgets/widgets.dart index f0d24d5..9566901 100644 --- a/lib/src/widgets/widgets.dart +++ b/lib/src/widgets/widgets.dart @@ -1,5 +1,7 @@ part of '../pinput.dart'; +/// Signature for a function that creates a widget for a given index, e.g., in a +/// list. typedef JustIndexedWidgetBuilder = Widget Function(int index); class _PinputFormField extends FormField { diff --git a/pubspec.yaml b/pubspec.yaml index a90cff5..c22c840 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: pinput -version: 3.0.1 +version: 4.0.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