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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ dependencies:
multi_split_view: ^2.4.0
url_launcher: ^6.2.5
flutter_riverpod: ^2.5.1
riverpod: ^2.5.1
riverpod: ^2.5.1
uuid: ^4.3.3
http: ^1.2.1
http_parser: ^4.0.2
@ -56,7 +56,7 @@ dependencies:
json_text_field: ^1.1.0
csv: ^6.0.0
data_table_2: ^2.5.11
dependency_overrides:
web: ^0.5.0