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),
child: FormDataField(
keyId: "$selectedId-$index-form-k-$seed", keyId: "$selectedId-$index-form-k-$seed",
initialValue: rows[index].name, initialValue: rows[index].name,
hintText: " Add Key", hintText: " Add Key",
onChanged: (value) { onChanged: (value) {
rows[index] = rows[index].copyWith( rows[index] =
name: value, rows[index].copyWith(name: value);
);
_onFieldChange(selectedId!); _onFieldChange(selectedId!);
}, },
colorScheme: Theme.of(context).colorScheme, 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,43 +102,43 @@ 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,
child: Row(
children: [
Expanded(
child: Theme(
data: Theme.of(context),
child: ElevatedButton.icon(
icon: const Icon( icon: const Icon(
Icons.snippet_folder_rounded, Icons.snippet_folder_rounded,
size: 20, size: 20,
), ),
style: ButtonStyle( style: ElevatedButton.styleFrom(
shape: minimumSize: const Size.fromHeight(
MaterialStatePropertyAll( kDataRowHeight),
RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius.circular(6),
6),
),
), ),
), ),
onPressed: () async { onPressed: () async {
var pickedResult = var pickedResult = await pickFile();
await pickFile();
if (pickedResult != null && if (pickedResult != null &&
pickedResult pickedResult.files.isNotEmpty &&
.files.isNotEmpty && pickedResult.files.first.path !=
pickedResult.files.first
.path !=
null) { null) {
rows[index] = rows[index] = rows[index].copyWith(
rows[index].copyWith( value:
value: pickedResult pickedResult.files.first.path!,
.files.first.path!,
); );
setState(() {}); setState(() {});
_onFieldChange(selectedId!); _onFieldChange(selectedId!);
@ -154,25 +146,12 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
}, },
label: Text( label: Text(
(rows[index].type == (rows[index].type ==
FormDataType FormDataType.file &&
.file && rows[index].value.isNotEmpty)
rows[index] ? rows[index].value.toString()
.value
.isNotEmpty)
? rows[index]
.value
.toString()
: "Select File", : "Select File",
textAlign: TextAlign.center, overflow: TextOverflow.ellipsis,
overflow: style: kFormDataButtonLabelTextStyle,
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,
), ),