Skip to content

Commit

Permalink
add initialAutoFocus param
Browse files Browse the repository at this point in the history
  • Loading branch information
김정태(Jeongtae Kim)/App개발팀/11ST committed Mar 17, 2021
1 parent 9d4b917 commit 0b4355e
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 52 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@

## 2.1.6

* Prevents special characters from being entered into the card number
* Prevents special characters from being entered into the card number

### v2.2.0

Add initial autofocus parameter
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
alt="Platform" />
</a>
<a href="https://pub.dev/packages/credit_card_input_form">
<img src="https://img.shields.io/badge/pub-v2.1.6-red" />
<img src="https://img.shields.io/badge/pub-v2.2.0-red" />

</a>
<a href="https://github.com/Solido/awesome-flutter">
Expand Down Expand Up @@ -42,7 +42,7 @@ This package provides visually beautiful UX through animation of credit card inf

```dart
dependencies:
credit_card_input_form: ^2.1.6
credit_card_input_form: ^2.2.0
```

2. Import the package
Expand Down Expand Up @@ -71,6 +71,8 @@ import 'package:credit_card_input_form/credit_card_input_form.dart';
prevButtonTextStyle: buttonTextStyle,
nextButtonTextStyle: buttonTextStyle,
resetButtonTextStyle: buttonTextStyle,
initialAutoFocus: true, // optional
),
```

Expand Down Expand Up @@ -184,6 +186,10 @@ CreditCardInputForm(
</tr>
</table>

### v2.2.0

Add `initialAutoFocus` parameter

## 3rd party library

### Flip card
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0ba14dd7f8290b5ee6743eaa79b50eff
1cd4485d99bf93c780f2e6fa1e8143cc
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class _MyAppState extends State<MyApp> {
print(currentState);
print(cardInfo);
},
// initialAutoFocus: false,
// customCaptions: customCaptions,
// cardCVV: '222',
// cardName: 'Jeongtae Kim',
Expand Down
40 changes: 20 additions & 20 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.3"
version: "2.5.0-nullsafety"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.5"
version: "1.1.0-nullsafety.2"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.5"
version: "1.15.0-nullsafety.2"
credit_card_input_form:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.1.6"
version: "2.2.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -63,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.1.0-nullsafety"
flip_card:
dependency: transitive
description:
Expand All @@ -87,14 +87,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.3"
version: "0.12.10-nullsafety"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.6"
version: "1.3.0-nullsafety.2"
nested:
dependency: transitive
description:
Expand All @@ -108,7 +108,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.3"
version: "1.8.0-nullsafety"
provider:
dependency: transitive
description:
Expand All @@ -127,56 +127,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.4"
version: "1.8.0-nullsafety"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.6"
version: "1.10.0-nullsafety"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.6"
version: "0.2.19-nullsafety"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.5"
version: "1.3.0-nullsafety.2"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.5"
version: "2.1.0-nullsafety.2"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.10.0-0.0.dev <2.10.0"
flutter: ">=1.16.0"
19 changes: 11 additions & 8 deletions lib/components/input_view_pager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import 'package:credit_card_input_form/provider/card_number_provider.dart';

class InputViewPager extends StatefulWidget {
final pageController;
final isAutoFoucus;

InputViewPager({this.pageController});
InputViewPager({this.pageController, this.isAutoFoucus});

@override
_InputViewPagerState createState() => _InputViewPagerState();
Expand Down Expand Up @@ -65,6 +66,7 @@ class _InputViewPagerState extends State<InputViewPager> {
return Padding(
padding: const EdgeInsets.all(8.0),
child: InputForm(
isAutoFocus: widget.isAutoFoucus,
focusNode: focusNodes[index],
title: titleMap[index],
index: index,
Expand All @@ -80,13 +82,14 @@ class InputForm extends StatefulWidget {
final int index;
final PageController pageController;
final FocusNode focusNode;
final isAutoFocus;

InputForm({
@required this.title,
this.index,
this.pageController,
this.focusNode,
});
InputForm(
{@required this.title,
this.index,
this.pageController,
this.focusNode,
this.isAutoFocus});

@override
_InputFormState createState() => _InputFormState();
Expand Down Expand Up @@ -192,7 +195,7 @@ class _InputFormState extends State<InputForm> {
),
TextField(
autocorrect: false,
autofocus: widget.index == index,
autofocus: widget.isAutoFocus && widget.index == index,
controller: textController
..value = textController.value.copyWith(
text: textValue,
Expand Down
6 changes: 6 additions & 0 deletions lib/credit_card_input_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CreditCardInputForm extends StatelessWidget {
this.cardName = '',
this.cardCVV = '',
this.cardValid = '',
this.initialAutoFocus = true,
this.intialCardState = InputState.NUMBER,
this.nextButtonTextStyle = kDefaultButtonTextStyle,
this.prevButtonTextStyle = kDefaultButtonTextStyle,
Expand All @@ -57,6 +58,7 @@ class CreditCardInputForm extends StatelessWidget {
final String cardName;
final String cardCVV;
final String cardValid;
final initialAutoFocus;
final InputState intialCardState;

@override
Expand Down Expand Up @@ -87,6 +89,7 @@ class CreditCardInputForm extends StatelessWidget {
backDecoration: backCardDecoration,
frontDecoration: frontCardDecoration,
cardHeight: cardHeight,
initialAutoFocus: initialAutoFocus,
showResetButton: showResetButton,
prevButtonDecoration: prevButtonDecoration,
nextButtonDecoration: nextButtonDecoration,
Expand All @@ -113,6 +116,7 @@ class CreditCardInputImpl extends StatefulWidget {
final TextStyle prevButtonTextStyle;
final TextStyle resetButtonTextStyle;
final InputState initialCardState;
final initialAutoFocus;

CreditCardInputImpl(
{this.onCardModelChanged,
Expand All @@ -126,6 +130,7 @@ class CreditCardInputImpl extends StatefulWidget {
this.nextButtonDecoration,
this.prevButtonDecoration,
this.initialCardState,
this.initialAutoFocus,
this.resetButtonDecoration});

@override
Expand Down Expand Up @@ -216,6 +221,7 @@ class _CreditCardInputImplState extends State<CreditCardInputImpl> {
opacity: _currentState == InputState.DONE ? 0 : 1,
duration: Duration(milliseconds: 500),
child: InputViewPager(
isAutoFoucus: widget.initialAutoFocus,
pageController: pageController,
),
),
Expand Down
Loading

0 comments on commit 0b4355e

Please sign in to comment.