Skip to content

Commit b7b8dc6

Browse files
theamiriabdelghafour amiriAhmedAmineZrnouha06
authored
feat(pinCodeInput): add optional keyboardType (numeric/alphanumeric) (#733)(#734)
* feat(pinCodeInput): add optional keyboardType (numeric/alphanumeric) # Conflicts: # ouds_core/lib/components/pin_code_input/digit_input/ouds_digit_input.dart * chore(pinCodeInput): update changelog for #733 * no message * review(pin-code-input): delete the translations for customization in demo app --------- Co-authored-by: abdelghafour amiri <abdelghafour.amiri@sofrecom.com> Co-authored-by: Ahmed Amine Zribi <ahmedamine.zribi@sofrecom.com> Co-authored-by: nhammami <nouha.hammami@sofrecom.com>
1 parent 22d7c13 commit b7b8dc6

14 files changed

Lines changed: 161 additions & 2 deletions

app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- [Library] `Filter chip` Apply high contrast theme to filter chip (selected) ([#494](https://github.com/Orange-OpenSource/ouds-flutter/issues/494))
1212

1313
### Changed
14+
- [DemoApp][Library] `Pin code input` Add optional `keyboardType` parameter (numeric/alphanumeric) ([#733](https://github.com/Orange-OpenSource/ouds-flutter/issues/733))
1415
- [Library] update tokens 1.9.0 - Component Bullet List ([#710](https://github.com/Orange-OpenSource/ouds-flutter/issues/710))
1516
- [Library] update tokens 1.9.0 - Component Alert ([#672](https://github.com/Orange-OpenSource/ouds-flutter/issues/672))
1617

app/lib/l10n/gen/ouds_flutter_app_localizations.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,24 @@ abstract class AppLocalizations {
12721272
/// **'Hidden Password'**
12731273
String get app_components_pinCodeInput_hidden_password_label;
12741274

1275+
/// No description provided for @app_components_pinCodeInput_keyboardType_label.
1276+
///
1277+
/// In en, this message translates to:
1278+
/// **'Keyboard type'**
1279+
String get app_components_pinCodeInput_keyboardType_label;
1280+
1281+
/// No description provided for @app_components_pinCodeInput_keyboardType_numeric_label.
1282+
///
1283+
/// In en, this message translates to:
1284+
/// **'Numeric'**
1285+
String get app_components_pinCodeInput_keyboardType_numeric_label;
1286+
1287+
/// No description provided for @app_components_pinCodeInput_keyboardType_alphanumeric_label.
1288+
///
1289+
/// In en, this message translates to:
1290+
/// **'Alphanumeric'**
1291+
String get app_components_pinCodeInput_keyboardType_alphanumeric_label;
1292+
12751293
/// No description provided for @app_components_navigationBar_label.
12761294
///
12771295
/// In en, this message translates to:

app/lib/l10n/gen/ouds_flutter_app_localizations_ar.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,17 @@ class AppLocalizationsAr extends AppLocalizations {
664664
String get app_components_pinCodeInput_hidden_password_label =>
665665
'Hidden Password';
666666

667+
@override
668+
String get app_components_pinCodeInput_keyboardType_label => 'Keyboard type';
669+
670+
@override
671+
String get app_components_pinCodeInput_keyboardType_numeric_label =>
672+
'Numeric';
673+
674+
@override
675+
String get app_components_pinCodeInput_keyboardType_alphanumeric_label =>
676+
'Alphanumeric';
677+
667678
@override
668679
String get app_components_navigationBar_label => 'Bottom Bar';
669680

app/lib/l10n/gen/ouds_flutter_app_localizations_en.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,17 @@ class AppLocalizationsEn extends AppLocalizations {
664664
String get app_components_pinCodeInput_hidden_password_label =>
665665
'Hidden Password';
666666

667+
@override
668+
String get app_components_pinCodeInput_keyboardType_label => 'Keyboard type';
669+
670+
@override
671+
String get app_components_pinCodeInput_keyboardType_numeric_label =>
672+
'Numeric';
673+
674+
@override
675+
String get app_components_pinCodeInput_keyboardType_alphanumeric_label =>
676+
'Alphanumeric';
677+
667678
@override
668679
String get app_components_navigationBar_label => 'Bottom Bar';
669680

app/lib/l10n/gen/ouds_flutter_app_localizations_fr.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,17 @@ class AppLocalizationsFr extends AppLocalizations {
668668
String get app_components_pinCodeInput_hidden_password_label =>
669669
'Hidden Password';
670670

671+
@override
672+
String get app_components_pinCodeInput_keyboardType_label => 'Keyboard type';
673+
674+
@override
675+
String get app_components_pinCodeInput_keyboardType_numeric_label =>
676+
'Numeric';
677+
678+
@override
679+
String get app_components_pinCodeInput_keyboardType_alphanumeric_label =>
680+
'Alphanumeric';
681+
671682
@override
672683
String get app_components_navigationBar_label => 'Bottom Bar';
673684

app/lib/l10n/ouds_flutter_en.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@
285285
"app_components_pinCodeInput_error_label": "Please enter the verification code.",
286286
"app_components_pinCodeInput_verification_error_label": "Verification failed. Check and enter the correct code.",
287287
"app_components_pinCodeInput_hidden_password_label": "Hidden Password",
288+
"app_components_pinCodeInput_keyboardType_label": "Keyboard type",
289+
"app_components_pinCodeInput_keyboardType_numeric_label": "Numeric",
290+
"app_components_pinCodeInput_keyboardType_alphanumeric_label": "Alphanumeric",
288291

289292
"@_components_navigation_bar": {},
290293
"app_components_navigationBar_label": "Bottom Bar",

app/lib/ui/components/pin_code_input/pin_code_input_code_generator.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import 'package:flutter/material.dart';
1414
import 'package:ouds_flutter_demo/ui/components/pin_code_input/pin_code_input_customization.dart';
1515
import 'package:ouds_flutter_demo/ui/components/pin_code_input/pin_code_input_customization_utils.dart';
16+
import 'package:ouds_flutter_demo/ui/components/pin_code_input/pin_code_input_enum.dart';
1617

1718
class PinCodeInputCodeGenerator {
1819
static String updateCode(BuildContext context) {
@@ -60,6 +61,10 @@ class PinCodeInputCodeGenerator {
6061
props.add(' isOutlined: ${state.hasOutlined},');
6162
}
6263

64+
if (state.selectedKeyboardType != PinCodeKeyboardTypeEnum.numeric) {
65+
props.add(' keyboardType: OudsPinCodeInputKeyboardType.${state.selectedKeyboardType.name},');
66+
}
67+
6368
if (props.isEmpty) {
6469
return "digitInputDecoration: OudsDigitInputDecoration(),";
6570
}

app/lib/ui/components/pin_code_input/pin_code_input_customization.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class PinCodeInputCustomizationState extends CustomizationWidgetState<PinCodeInp
4242
late final PinCodePlaceholderTextState pinCodePlaceholderTextState = PinCodePlaceholderTextState(setState);
4343
late final OutlinedState outlinedState = OutlinedState(setState);
4444
late final ConstrainedMaxWidthState constrainedMaxWidthState = ConstrainedMaxWidthState(setState);
45+
late final PinCodeKeyboardTypeState pinCodeKeyboardTypeState = PinCodeKeyboardTypeState(setState);
4546

4647
// These need context, so they stay as late fields
4748
late final PinCodeHelperTextState pinCodeHelperTextState;
@@ -102,6 +103,10 @@ class PinCodeInputCustomizationState extends CustomizationWidgetState<PinCodeInp
102103
bool get hasOutlined => outlinedState.value;
103104
set hasOutlined(bool value) => outlinedState.value = value;
104105

106+
// Proxy getters and setters to expose the keyboard type selection.
107+
PinCodeKeyboardTypeEnum get selectedKeyboardType => pinCodeKeyboardTypeState.selected;
108+
set selectedKeyboardType(PinCodeKeyboardTypeEnum value) => pinCodeKeyboardTypeState.selected = value;
109+
105110
@override
106111
Widget build(BuildContext context) {
107112
return _PinCodeInputCustomization(
@@ -261,3 +266,25 @@ class OutlinedState {
261266
});
262267
}
263268
}
269+
270+
/// Keyboard Type State Management
271+
class PinCodeKeyboardTypeState {
272+
PinCodeKeyboardTypeState(this._setState);
273+
274+
final void Function(void Function()) _setState;
275+
276+
final List<PinCodeKeyboardTypeEnum> _list = [
277+
PinCodeKeyboardTypeEnum.numeric,
278+
PinCodeKeyboardTypeEnum.alphanumeric,
279+
];
280+
281+
List<PinCodeKeyboardTypeEnum> get list => _list;
282+
283+
PinCodeKeyboardTypeEnum _selected = PinCodeKeyboardTypeEnum.numeric;
284+
PinCodeKeyboardTypeEnum get selected => _selected;
285+
set selected(PinCodeKeyboardTypeEnum newValue) {
286+
_setState(() {
287+
_selected = newValue;
288+
});
289+
}
290+
}

app/lib/ui/components/pin_code_input/pin_code_input_customization_utils.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@ class PinCodeInputCustomizationUtils {
5050
final label = customizationState.pinCodeErrorText;
5151
return label.isEmpty ? null : label;
5252
}
53+
54+
/// Maps the demo keyboard-type enum to the public [OudsPinCodeInputKeyboardType].
55+
static OudsPinCodeInputKeyboardType getKeyboardType(PinCodeKeyboardTypeEnum value) {
56+
switch (value) {
57+
case PinCodeKeyboardTypeEnum.numeric:
58+
return OudsPinCodeInputKeyboardType.numeric;
59+
case PinCodeKeyboardTypeEnum.alphanumeric:
60+
return OudsPinCodeInputKeyboardType.alphanumeric;
61+
}
62+
}
5363
}

app/lib/ui/components/pin_code_input/pin_code_input_demo_screen.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class _PinCodeInputDemoState extends State<_PinCodeInputDemo> {
149149
hiddenPassword: customizationState.hasHiddenPassword,
150150
isOutlined: customizationState.hasOutlined,
151151
constrainedMaxWidth: customizationState.hasConstrainedMaxWidth ? true : false,
152+
keyboardType: PinCodeInputCustomizationUtils.getKeyboardType(customizationState.selectedKeyboardType),
152153
),
153154
onEditingComplete: (value) async {
154155
final errorLabel = context.l10n.app_components_pinCodeInput_error_label;
@@ -280,6 +281,17 @@ class _CustomizationContentState extends State<_CustomizationContent> {
280281
customizationState.hasOutlined = value;
281282
},
282283
),
284+
CustomizableChips<PinCodeKeyboardTypeEnum>(
285+
title: PinCodeKeyboardTypeEnum.enumName(context),
286+
options: customizationState.pinCodeKeyboardTypeState.list,
287+
selectedOption: customizationState.selectedKeyboardType,
288+
getText: (option) => option.stringValue(context),
289+
onSelected: (selectedOption) {
290+
setState(() {
291+
customizationState.selectedKeyboardType = selectedOption;
292+
});
293+
},
294+
),
283295
CustomizableTextField(
284296
title: context.l10n.app_components_common_placeholder_label,
285297
text: customizationState.pinCodePlaceholderText,

0 commit comments

Comments
 (0)