@@ -7,6 +7,7 @@ import '../../../zeta_flutter.dart';
7
7
8
8
import '../text_input/hint_text.dart' ;
9
9
import '../text_input/input_label.dart' ;
10
+ import '../text_input/text_input.dart' ;
10
11
import 'countries.dart' ;
11
12
12
13
/// ZetaPhoneInput allows entering phone numbers.
@@ -175,75 +176,83 @@ class _ZetaPhoneInputState extends State<ZetaPhoneInput> {
175
176
children: [
176
177
ZetaDropdown (
177
178
offset: const Offset (0 , ZetaSpacing .medium),
178
- onChange: (value) {
179
- setState (() {
180
- _selectedCountry = _countries.firstWhere ((country) => country.dialCode == value.value);
181
- });
182
- inputFocusNode.requestFocus ();
183
- },
179
+ onChange: ! widget.disabled
180
+ ? (value) {
181
+ setState (() {
182
+ _selectedCountry = _countries.firstWhere ((country) => country.dialCode == value.value);
183
+ });
184
+ inputFocusNode.requestFocus ();
185
+ }
186
+ : null ,
184
187
value: _selectedCountry.dialCode,
185
188
onDismissed: () => setState (() {}),
186
189
items: _dropdownItems,
187
190
builder: (context, selectedItem, controller) {
188
- return DecoratedBox (
189
- decoration: BoxDecoration (
190
- border: Border (
191
- left: BorderSide (
192
- color: zeta.colors.borderDefault,
193
- ),
194
- top: BorderSide (
195
- color: zeta.colors.borderDefault,
191
+ final borderSide = BorderSide (
192
+ color: widget.disabled ? zeta.colors.borderDefault : zeta.colors.borderSubtle,
193
+ );
194
+
195
+ return GestureDetector (
196
+ onTap: ! widget.disabled ? controller.toggle : null ,
197
+ child: Container (
198
+ constraints: BoxConstraints (
199
+ maxHeight: widget.size == ZetaWidgetSize .large ? 48 : 40 ,
200
+ ),
201
+ decoration: BoxDecoration (
202
+ borderRadius: BorderRadius .only (
203
+ topLeft: rounded ? const Radius .circular (ZetaSpacing .minimum) : Radius .zero,
204
+ bottomLeft: rounded ? const Radius .circular (ZetaSpacing .minimum) : Radius .zero,
196
205
),
197
- bottom: BorderSide (
198
- color: zeta.colors.borderDefault,
206
+ border: Border (
207
+ left: borderSide,
208
+ top: borderSide,
209
+ bottom: borderSide,
199
210
),
211
+ color: widget.disabled ? zeta.colors.surfaceDisabled : zeta.colors.surfaceDefault,
200
212
),
201
- ),
202
- child: GestureDetector (
203
- onTap: controller.toggle,
204
- child: ConstrainedBox (
205
- constraints: BoxConstraints (
206
- maxHeight: widget.size == ZetaWidgetSize .large ? 48 : 40 ,
207
- ),
208
- child: Column (
209
- children: [
210
- Expanded (
211
- child: Row (
212
- mainAxisAlignment: MainAxisAlignment .spaceBetween,
213
- mainAxisSize: MainAxisSize .min,
214
- children: [
215
- Padding (
216
- padding: const EdgeInsets .only (
217
- left: ZetaSpacing .medium,
218
- right: ZetaSpacing .small,
219
- ),
220
- child: selectedItem? .icon,
213
+ child: Column (
214
+ children: [
215
+ Expanded (
216
+ child: Row (
217
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
218
+ mainAxisSize: MainAxisSize .min,
219
+ children: [
220
+ Padding (
221
+ padding: const EdgeInsets .only (
222
+ left: ZetaSpacing .medium,
223
+ right: ZetaSpacing .small,
221
224
),
222
- ZetaIcon (
223
- ! controller.isOpen ? ZetaIcons .expand_more : ZetaIcons .expand_less,
224
- color: ! widget.disabled ? zeta.colors.iconDefault : zeta.colors.iconDisabled,
225
- size: ZetaSpacing .xl_1,
226
- ),
227
- ],
228
- ),
225
+ child: selectedItem? .icon,
226
+ ),
227
+ ZetaIcon (
228
+ ! controller.isOpen ? ZetaIcons .expand_more : ZetaIcons .expand_less,
229
+ color: ! widget.disabled ? zeta.colors.iconDefault : zeta.colors.iconDisabled,
230
+ size: ZetaSpacing .xl_1,
231
+ ),
232
+ ],
229
233
),
230
- ] ,
231
- ) ,
234
+ ) ,
235
+ ] ,
232
236
),
233
237
),
234
238
);
235
239
},
236
240
),
237
241
Expanded (
238
- child: ZetaTextInput (
242
+ child: textInputWithBorder (
239
243
initialValue: widget.phoneNumber,
240
244
disabled: widget.disabled,
241
245
size: widget.size,
246
+ rounded: rounded,
242
247
focusNode: inputFocusNode,
243
248
inputFormatters: [FilteringTextInputFormatter .allow (RegExp (r'[\d\s\-]' ))],
244
249
keyboardType: TextInputType .phone,
245
250
onChange: (value) => _onChanged (phoneNumber: value),
246
251
prefixText: _selectedCountry.dialCode,
252
+ borderRadius: BorderRadius .only (
253
+ topRight: rounded ? const Radius .circular (ZetaSpacing .minimum) : Radius .zero,
254
+ bottomRight: rounded ? const Radius .circular (ZetaSpacing .minimum) : Radius .zero,
255
+ ),
247
256
),
248
257
),
249
258
],
0 commit comments