fix: form data columns

This commit is contained in:
DenserMeerkat
2024-03-17 04:06:17 +05:30
parent ad4df3d44b
commit 6724db3be6
7 changed files with 69 additions and 96 deletions

View File

@ -34,13 +34,19 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
List<DataColumn> columns = const [ List<DataColumn> columns = const [
DataColumn2( DataColumn2(
label: Text('Key'), label: Text('Key'),
size: ColumnSize.M,
), ),
DataColumn2( DataColumn2(
label: Text('='), label: Text('='),
fixedWidth: 30, fixedWidth: 20,
),
DataColumn2(
label: Text('Type'),
fixedWidth: 70,
), ),
DataColumn2( DataColumn2(
label: Text('Value'), label: Text('Value'),
size: ColumnSize.L,
), ),
DataColumn2( DataColumn2(
label: Text('Remove'), label: Text('Remove'),
@ -78,30 +84,16 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
key: ValueKey("$selectedId-$index-form-row-$seed"), key: ValueKey("$selectedId-$index-form-row-$seed"),
cells: <DataCell>[ cells: <DataCell>[
DataCell( DataCell(
Theme( CellField(
data: Theme.of(context), keyId: "$selectedId-$index-form-k-$seed",
child: FormDataField( initialValue: rows[index].name,
keyId: "$selectedId-$index-form-k-$seed", hintText: " Add Key",
initialValue: rows[index].name, onChanged: (value) {
hintText: " Add Key", rows[index] =
onChanged: (value) { rows[index].copyWith(name: value);
rows[index] = rows[index].copyWith( _onFieldChange(selectedId!);
name: value, },
); colorScheme: Theme.of(context).colorScheme,
_onFieldChange(selectedId!);
},
colorScheme: Theme.of(context).colorScheme,
formDataType: rows[index].type,
onFormDataTypeChanged: (value) {
rows[index] = rows[index].copyWith(
type: value ?? FormDataType.text,
);
rows[index] =
rows[index].copyWith(value: "");
setState(() {});
_onFieldChange(selectedId!);
},
),
), ),
), ),
DataCell( DataCell(
@ -110,69 +102,56 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
style: kCodeStyle, style: kCodeStyle,
), ),
), ),
DataCell(
DropdownButtonFormData(
formDataType: rows[index].type,
onChanged: (value) {
rows[index] = rows[index].copyWith(
type: value ?? FormDataType.text,
);
rows[index] = rows[index].copyWith(value: "");
setState(() {});
_onFieldChange(selectedId!);
},
),
),
DataCell( DataCell(
rows[index].type == FormDataType.file rows[index].type == FormDataType.file
? Align( ? ElevatedButton.icon(
alignment: Alignment.centerLeft, icon: const Icon(
child: Row( Icons.snippet_folder_rounded,
children: [ size: 20,
Expanded( ),
child: Theme( style: ElevatedButton.styleFrom(
data: Theme.of(context), minimumSize: const Size.fromHeight(
child: ElevatedButton.icon( kDataRowHeight),
icon: const Icon( shape: RoundedRectangleBorder(
Icons.snippet_folder_rounded, borderRadius:
size: 20, BorderRadius.circular(6),
), ),
style: ButtonStyle( ),
shape: onPressed: () async {
MaterialStatePropertyAll( var pickedResult = await pickFile();
RoundedRectangleBorder( if (pickedResult != null &&
borderRadius: pickedResult.files.isNotEmpty &&
BorderRadius.circular( pickedResult.files.first.path !=
6), null) {
), rows[index] = rows[index].copyWith(
), value:
), pickedResult.files.first.path!,
onPressed: () async { );
var pickedResult = setState(() {});
await pickFile(); _onFieldChange(selectedId!);
if (pickedResult != null && }
pickedResult },
.files.isNotEmpty && label: Text(
pickedResult.files.first (rows[index].type ==
.path != FormDataType.file &&
null) { rows[index].value.isNotEmpty)
rows[index] = ? rows[index].value.toString()
rows[index].copyWith( : "Select File",
value: pickedResult overflow: TextOverflow.ellipsis,
.files.first.path!, style: kFormDataButtonLabelTextStyle,
);
setState(() {});
_onFieldChange(selectedId!);
}
},
label: Text(
(rows[index].type ==
FormDataType
.file &&
rows[index]
.value
.isNotEmpty)
? rows[index]
.value
.toString()
: "Select File",
textAlign: TextAlign.center,
overflow:
TextOverflow.ellipsis,
style:
kFormDataButtonLabelTextStyle,
),
),
),
),
],
), ),
) )
: CellField( : CellField(

View File

@ -59,7 +59,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
), ),
DataColumn2( DataColumn2(
label: Text('='), label: Text('='),
fixedWidth: 30, fixedWidth: 22,
), ),
DataColumn2( DataColumn2(
label: Text('Header Value'), label: Text('Header Value'),

View File

@ -60,7 +60,7 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
), ),
DataColumn2( DataColumn2(
label: Text('='), label: Text('='),
fixedWidth: 30, fixedWidth: 22,
), ),
DataColumn2( DataColumn2(
label: Text('Parameter Value'), label: Text('Parameter Value'),

View File

@ -43,12 +43,10 @@ class _FormDataFieldState extends State<FormDataField> {
initialValue: widget.initialValue, initialValue: widget.initialValue,
key: Key(widget.keyId), key: Key(widget.keyId),
style: kCodeStyle.copyWith( style: kCodeStyle.copyWith(
height: 1.8,
color: colorScheme.onSurface, color: colorScheme.onSurface,
), ),
decoration: InputDecoration( decoration: InputDecoration(
hintStyle: kCodeStyle.copyWith( hintStyle: kCodeStyle.copyWith(
height: 1.8,
color: colorScheme.outline.withOpacity( color: colorScheme.outline.withOpacity(
kHintOpacity, kHintOpacity,
), ),

View File

@ -77,12 +77,10 @@ class _HeaderFieldState extends State<HeaderField> {
controller: controller, controller: controller,
focusNode: focusNode, focusNode: focusNode,
style: kCodeStyle.copyWith( style: kCodeStyle.copyWith(
height: 1.6,
color: colorScheme.onSurface, color: colorScheme.onSurface,
), ),
decoration: InputDecoration( decoration: InputDecoration(
hintStyle: kCodeStyle.copyWith( hintStyle: kCodeStyle.copyWith(
height: 1.6,
color: colorScheme.outline.withOpacity(kHintOpacity)), color: colorScheme.outline.withOpacity(kHintOpacity)),
hintText: widget.hintText, hintText: widget.hintText,
contentPadding: const EdgeInsets.only(bottom: 12), contentPadding: const EdgeInsets.only(bottom: 12),

View File

@ -59,12 +59,10 @@ class CellField extends StatelessWidget {
key: Key(keyId), key: Key(keyId),
initialValue: initialValue, initialValue: initialValue,
style: kCodeStyle.copyWith( style: kCodeStyle.copyWith(
height: 1.6,
color: clrScheme.onSurface, color: clrScheme.onSurface,
), ),
decoration: InputDecoration( decoration: InputDecoration(
hintStyle: kCodeStyle.copyWith( hintStyle: kCodeStyle.copyWith(
height: 1.6,
color: clrScheme.outline.withOpacity( color: clrScheme.outline.withOpacity(
kHintOpacity, kHintOpacity,
), ),