Skip to content

Commit

Permalink
Release 4.0.4:
Browse files Browse the repository at this point in the history
- Upgraded smart_auth
- Updated readme
- Improved docs
  • Loading branch information
Tkko committed Feb 10, 2024
1 parent 1eb78c2 commit 5ba333a
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ linter:
unnecessary_new: true
prefer_single_quotes: true
require_trailing_commas: true
public_member_api_docs: true
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
44 changes: 44 additions & 0 deletions example/lib/test_examples.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,47 @@ class _ErrorStateExampleState extends State<ErrorStateExample> {
);
}
}

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,
),
),
);
}
}
6 changes: 6 additions & 0 deletions lib/src/models/pin_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -68,6 +71,7 @@ class PinTheme {
);
}

/// Create a new [PinTheme] from the current instance
PinTheme copyWith({
double? width,
double? height,
Expand All @@ -88,6 +92,7 @@ class PinTheme {
);
}

/// Create a new [PinTheme] from the current instance with new decoration
PinTheme copyDecorationWith({
Color? color,
DecorationImage? image,
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions lib/src/pinput.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
50 changes: 50 additions & 0 deletions lib/src/utils/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
7 changes: 4 additions & 3 deletions lib/src/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ 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);
this.text = pin;
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';
Expand Down
2 changes: 2 additions & 0 deletions lib/src/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -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<String> {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5ba333a

Please sign in to comment.