Skip to content

Commit becf17f

Browse files
committed
Abstract InputDecoration for TextField
1 parent 104273e commit becf17f

File tree

4 files changed

+51
-34
lines changed

4 files changed

+51
-34
lines changed

lib/screens/common_widgets/envfield_cell.dart

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,9 @@ class EnvCellField extends StatelessWidget {
2727
style: kCodeStyle.copyWith(
2828
color: clrScheme.onSurface,
2929
),
30-
decoration: InputDecoration(
31-
hintStyle: kCodeStyle.copyWith(
32-
color: clrScheme.outlineVariant,
33-
),
30+
decoration: getTextFieldInputDecoration(
31+
clrScheme,
3432
hintText: hintText,
35-
contentPadding: const EdgeInsets.only(bottom: 12),
36-
focusedBorder: UnderlineInputBorder(
37-
borderSide: BorderSide(
38-
color: clrScheme.outlineVariant,
39-
),
40-
),
41-
enabledBorder: UnderlineInputBorder(
42-
borderSide: BorderSide(
43-
color: clrScheme.surfaceContainerHighest,
44-
),
45-
),
4633
),
4734
onChanged: onChanged,
4835
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:flutter/material.dart';
2+
import '../tokens/tokens.dart';
3+
4+
InputDecoration getTextFieldInputDecoration(
5+
ColorScheme clrScheme, {
6+
Color? fillColor,
7+
String? hintText,
8+
TextStyle? hintTextStyle,
9+
double? hintTextFontSize,
10+
Color? hintTextColor,
11+
EdgeInsetsGeometry? contentPadding,
12+
Color? focussedBorderColor,
13+
Color? enabledBorderColor,
14+
bool? isDense,
15+
}) {
16+
return InputDecoration(
17+
filled: true,
18+
fillColor: fillColor ?? clrScheme.surfaceContainerLowest,
19+
hintStyle: hintTextStyle ??
20+
kCodeStyle.copyWith(
21+
fontSize: hintTextFontSize,
22+
color: hintTextColor ?? clrScheme.outlineVariant,
23+
),
24+
hintText: hintText,
25+
contentPadding: contentPadding ?? kP10,
26+
focusedBorder: OutlineInputBorder(
27+
borderSide: BorderSide(
28+
color: focussedBorderColor ?? clrScheme.outline,
29+
),
30+
),
31+
enabledBorder: OutlineInputBorder(
32+
borderSide: BorderSide(
33+
color: enabledBorderColor ?? clrScheme.surfaceContainerHighest,
34+
),
35+
),
36+
isDense: isDense,
37+
);
38+
}

packages/apidash_design_system/lib/widgets/textfield_outlined.dart

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import '../tokens/tokens.dart';
3+
import 'decoration_input_textfield.dart';
34

45
class ADOutlinedTextField extends StatelessWidget {
56
const ADOutlinedTextField({
@@ -65,26 +66,16 @@ class ADOutlinedTextField extends StatelessWidget {
6566
fontSize: textFontSize,
6667
color: textColor ?? clrScheme.onSurface,
6768
),
68-
decoration: InputDecoration(
69-
filled: true,
70-
fillColor: fillColor ?? clrScheme.surfaceContainerLowest,
71-
hintStyle: hintTextStyle ??
72-
kCodeStyle.copyWith(
73-
fontSize: hintTextFontSize,
74-
color: hintTextColor ?? clrScheme.outlineVariant,
75-
),
69+
decoration: getTextFieldInputDecoration(
70+
clrScheme,
71+
fillColor: fillColor,
7672
hintText: hintText,
77-
contentPadding: contentPadding ?? kP10,
78-
focusedBorder: OutlineInputBorder(
79-
borderSide: BorderSide(
80-
color: focussedBorderColor ?? clrScheme.outline,
81-
),
82-
),
83-
enabledBorder: OutlineInputBorder(
84-
borderSide: BorderSide(
85-
color: enabledBorderColor ?? clrScheme.surfaceContainerHighest,
86-
),
87-
),
73+
hintTextStyle: hintTextStyle,
74+
hintTextFontSize: hintTextFontSize,
75+
hintTextColor: hintTextColor,
76+
contentPadding: contentPadding,
77+
focussedBorderColor: focussedBorderColor,
78+
enabledBorderColor: enabledBorderColor,
8879
isDense: isDense,
8980
),
9081
onChanged: onChanged,

packages/apidash_design_system/lib/widgets/widgets.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export 'button_filled.dart';
22
export 'button_icon.dart';
33
export 'button_text.dart';
44
export 'checkbox.dart';
5+
export 'decoration_input_textfield.dart';
56
export 'dropdown.dart';
67
export 'popup_menu.dart';
78
export 'snackbar.dart';

0 commit comments

Comments
 (0)