Skip to content

Commit

Permalink
refactor(UX-1099): ZetaPhoneInput now uses ZetaTextInput (#137)
Browse files Browse the repository at this point in the history
feat: Added focus node and keyboard type properties to ZetaTextInput
fix: Dropdown menus now scroll
  • Loading branch information
mikecoomber committed Jul 22, 2024
1 parent 074e11a commit d99d40c
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 664 deletions.
31 changes: 27 additions & 4 deletions example/lib/pages/components/phone_input_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,26 @@ class _PhoneInputExampleState extends State<PhoneInputExample> {
padding: const EdgeInsets.all(20),
child: ZetaPhoneInput(
label: 'Phone number',
hint: 'Enter your phone number',
hintText: 'Enter your phone number',
hasError: _errorText != null,
errorText: _errorText,
onChanged: (value) {
onChange: (value) {
if (value?.isEmpty ?? true) setState(() => _errorText = null);
print(value);
},
initialCountry: 'GB',
countries: ['US', 'GB', 'DE', 'AT', 'FR', 'IT', 'BG'],
),
),
Padding(
padding: const EdgeInsets.all(20),
child: ZetaPhoneInput(
label: 'Phone number',
hintText: 'Enter your phone number',
hasError: _errorText != null,
size: ZetaWidgetSize.large,
errorText: 'Error',
onChange: (value) {
if (value?.isEmpty ?? true) setState(() => _errorText = null);
print(value);
},
Expand All @@ -45,8 +61,15 @@ class _PhoneInputExampleState extends State<PhoneInputExample> {
padding: const EdgeInsets.all(20),
child: ZetaPhoneInput(
label: 'Phone number',
hint: 'Enter your phone number',
enabled: false,
hintText: 'Enter your phone number',
disabled: true,
),
),
Padding(
padding: const EdgeInsets.all(20),
child: ZetaPhoneInput(
label: 'Phone number',
hintText: 'Enter your phone number',
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ Widget phoneInputUseCase(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(ZetaSpacing.xl_1),
child: ZetaPhoneInput(
enabled: enabled,
disabled: !enabled,
label: 'Phone number',
hint: 'Enter your phone number',
hintText: 'Enter your phone number',
countries: countries.isEmpty ? null : countries.toUpperCase().split(','),
useRootNavigator: false,
),
);
},
Expand Down
48 changes: 26 additions & 22 deletions lib/src/components/dropdown/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,19 @@ class _DropdownItemState<T> extends State<_DropdownItem<T>> {
statesController: controller,
style: _getStyle(colors),
child: Padding(
padding: widget.menuType == ZetaDropdownMenuType.radio
? const EdgeInsets.only(right: ZetaSpacing.medium)
: const EdgeInsets.symmetric(
vertical: ZetaSpacingBase.x2_5,
horizontal: ZetaSpacing.medium,
),
padding: const EdgeInsets.symmetric(
vertical: ZetaSpacingBase.x2_5,
horizontal: ZetaSpacing.medium,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (leading != null) leading,
Expanded(child: Text(widget.value.label)),
Expanded(
child: Text(
widget.value.label,
),
),
],
),
),
Expand Down Expand Up @@ -639,21 +641,23 @@ class _ZetaDropDownMenuState<T> extends State<_ZetaDropDownMenu<T>> {
)
: null,
child: IntrinsicWidth(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: widget.items
.map((item) {
return _DropdownItem(
value: item,
onPress: () => widget.onSelected(item),
selected: item.value == widget.selected,
allocateLeadingSpace: widget.allocateLeadingSpace,
menuType: widget.menuType,
);
})
.divide(const SizedBox(height: ZetaSpacing.minimum))
.toList(),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: widget.items
.map((item) {
return _DropdownItem(
value: item,
onPress: () => widget.onSelected(item),
selected: item.value == widget.selected,
allocateLeadingSpace: widget.allocateLeadingSpace,
menuType: widget.menuType,
);
})
.divide(const SizedBox(height: ZetaSpacing.minimum))
.toList(),
),
),
),
);
Expand Down
217 changes: 0 additions & 217 deletions lib/src/components/phone_input/countries_dialog.dart

This file was deleted.

Loading

0 comments on commit d99d40c

Please sign in to comment.