Skip to content

Commit

Permalink
Fixes/focus (#400)
Browse files Browse the repository at this point in the history
* fix: focus issue on CardFormField on Android

Refs: #392

* docs: correct AppCompat mention in README.md

Refs: #397

* chore(release): publish packages

 - [email protected]

* Fix pubspec change

* change changelog
  • Loading branch information
jonasbark authored Oct 19, 2021
1 parent 8e48dbb commit 45bd6de
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ dart pub add flutter_stripe

- Android 5.0 (API level 21) and above
- Kotlin version 1.5.0 and above: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/build.gradle#L2)
- Using a descendant of `Theme.AppCompact` for your activity: [example](https://github.com/flutter-stripe/flutter_stripe/main/example/android/app/src/main/res/values/styles.xml#L15), [example night theme](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/app/src/main/res/values-night/styles.xml#L16)
- Using a descendant of `Theme.AppCompat` for your activity: [example](https://github.com/flutter-stripe/flutter_stripe/main/example/android/app/src/main/res/values/styles.xml#L15), [example night theme](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/app/src/main/res/values-night/styles.xml#L16)
- Using an up-to-date Android gradle build tools version: [example](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/build.gradle#L9) and an up-to-date gradle version accordingly: [example](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/gradle/wrapper/gradle-wrapper.properties#L6)
- Using `FlutterFragmentActivity` instead of `FlutterActivity` in `MainActivity.kt`: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/app/src/main/kotlin/com/flutter/stripe/example/MainActivity.kt#L6)

This is caused by the Stripe SDK requires the use of the AppCompact theme for their UI components and the Support Fragment Manager for the Payment Sheets
This is caused by the Stripe SDK requires the use of the AppCompat theme for their UI components and the Support Fragment Manager for the Payment Sheets

#### iOS

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_stripe: ^2.0.0
flutter_stripe: ^2.0.1
pay: ^1.0.5
http: ^0.13.3

Expand Down
5 changes: 5 additions & 0 deletions packages/stripe/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.1

- **FIX**: focus issue on CardFormField on Android. #397
- **DOCS**: correct AppCompat mention in README.md. #392

## 2.0.0
** First stable release **

Expand Down
4 changes: 2 additions & 2 deletions packages/stripe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ dart pub add flutter_stripe

- Android 5.0 (API level 21) and above
- Kotlin version 1.5.0 and above: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/build.gradle#L2)
- Using a descendant of `Theme.AppCompact` for your activity: [example](https://github.com/flutter-stripe/flutter_stripe/blob/384d390c8a90d19dc62c73faa5226fa931fd6d44/example/android/app/src/main/res/values/styles.xml#L15)
- Using a descendant of `Theme.AppCompat` for your activity: [example](https://github.com/flutter-stripe/flutter_stripe/blob/384d390c8a90d19dc62c73faa5226fa931fd6d44/example/android/app/src/main/res/values/styles.xml#L15)
- Using `FlutterFragmentActivity` instead of `FlutterActivity` in `MainActivity.kt`: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/app/src/main/kotlin/com/flutter/stripe/example/MainActivity.kt#L6)

This is caused by the Stripe SDK requires the use of the AppCompact theme for their UI components and the Support Fragment Manager for the Payment Sheets
This is caused by the Stripe SDK requires the use of the AppCompat theme for their UI components and the Support Fragment Manager for the Payment Sheets

#### iOS

Expand Down
35 changes: 3 additions & 32 deletions packages/stripe/lib/src/widgets/card_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,9 @@ class _MethodChannelCardFormFieldState
? kCardFormFieldDefaultIOSHeight
: kCardFormFieldDefaultAndroidHeight);

return Listener(
onPointerDown: (_) {
if (!_effectiveNode.hasFocus) {
_effectiveNode.requestFocus();
}
},
child: Focus(
autofocus: true,
descendantsAreFocusable: false,
focusNode: _effectiveNode,
onFocusChange: _handleFrameworkFocusChanged,
child: ConstrainedBox(
constraints: constraints,
child: platform,
),
),
return ConstrainedBox(
constraints: constraints,
child: platform,
);
}

Expand Down Expand Up @@ -425,22 +412,6 @@ class _MethodChannelCardFormFieldState
}
}

/// Handler called when the focus changes in the node attached to the platform
/// view. This updates the correspondant platform view to keep it in sync.
void _handleFrameworkFocusChanged(bool isFocused) {
final methodChannel = _methodChannel;
if (methodChannel == null) {
return;
}
setState(() {});
if (!isFocused) {
blur();
return;
}

focus();
}

@override
void blur() {
_methodChannel?.invokeMethod('blur');
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_stripe
description: Flutter library for Stripe. Supports PaymentSheets, Apple & Google Pay, SCA, PSD2 and much more.
version: 2.0.0
version: 2.0.1
homepage: https://github.com/flutter-stripe/flutter_stripe
repository: https://github.com/flutter-stripe/flutter_stripe

Expand Down

0 comments on commit 45bd6de

Please sign in to comment.