Update CellField

This commit is contained in:
Ankit Mahato
2023-04-21 13:59:33 +05:30
parent 56ac8cc0c0
commit aab5d13255
3 changed files with 19 additions and 17 deletions

View File

@ -47,7 +47,6 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
cellBuilder: (_, row) {
int idx = row.index;
return CellField(
colorScheme: Theme.of(context).colorScheme,
keyId: "$activeId-$idx-headers-k-$seed",
initialValue: rows[idx].k,
hintText: "Add Header Name",
@ -55,6 +54,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
rows[idx] = rows[idx].copyWith(k: value);
_onFieldChange(activeId!);
},
colorScheme: Theme.of(context).colorScheme,
);
},
sortable: false,
@ -74,7 +74,6 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
cellBuilder: (_, row) {
int idx = row.index;
return CellField(
colorScheme: Theme.of(context).colorScheme,
keyId: "$activeId-$idx-headers-v-$seed",
initialValue: rows[idx].v,
hintText: " Add Header Value",
@ -82,6 +81,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
rows[idx] = rows[idx].copyWith(v: value);
_onFieldChange(activeId!);
},
colorScheme: Theme.of(context).colorScheme,
);
},
sortable: false,

View File

@ -49,7 +49,6 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
cellBuilder: (_, row) {
int idx = row.index;
return CellField(
colorScheme: Theme.of(context).colorScheme,
keyId: "$activeId-$idx-params-k-$seed",
initialValue: rows[idx].k,
hintText: "Add URL Parameter",
@ -57,6 +56,7 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
rows[idx] = rows[idx].copyWith(k: value);
_onFieldChange(activeId!);
},
colorScheme: Theme.of(context).colorScheme,
);
},
sortable: false,
@ -76,7 +76,6 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
cellBuilder: (_, row) {
int idx = row.index;
return CellField(
colorScheme: Theme.of(context).colorScheme,
keyId: "$activeId-$idx-params-v-$seed",
initialValue: rows[idx].v,
hintText: "Add Value",
@ -84,6 +83,7 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
rows[idx] = rows[idx].copyWith(v: value);
_onFieldChange(activeId!);
},
colorScheme: Theme.of(context).colorScheme,
);
},
sortable: false,

View File

@ -44,19 +44,20 @@ class _URLFieldState extends State<URLField> {
}
class CellField extends StatefulWidget {
const CellField(
{super.key,
required this.colorScheme,
required this.keyId,
required this.initialValue,
this.hintText,
this.onChanged});
const CellField({
super.key,
required this.keyId,
this.initialValue,
this.hintText,
this.onChanged,
this.colorScheme,
});
final ColorScheme colorScheme;
final String keyId;
final String initialValue;
final String? initialValue;
final String? hintText;
final void Function(String)? onChanged;
final ColorScheme? colorScheme;
@override
State<CellField> createState() => _CellFieldState();
@ -65,29 +66,30 @@ class CellField extends StatefulWidget {
class _CellFieldState extends State<CellField> {
@override
Widget build(BuildContext context) {
var colorScheme = widget.colorScheme ?? Theme.of(context).colorScheme;
return TextFormField(
key: Key(widget.keyId),
initialValue: widget.initialValue,
style: kCodeStyle.copyWith(
color: widget.colorScheme.onSurface,
color: colorScheme.onSurface,
),
decoration: InputDecoration(
hintStyle: kCodeStyle.copyWith(
color: widget.colorScheme.outline.withOpacity(
color: colorScheme.outline.withOpacity(
kHintOpacity,
),
),
hintText: widget.hintText,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: widget.colorScheme.primary.withOpacity(
color: colorScheme.primary.withOpacity(
kHintOpacity,
),
),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: widget.colorScheme.surfaceVariant,
color: colorScheme.surfaceVariant,
),
),
),