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

View File

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

View File

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