Skip to content

Commit ac20814

Browse files
authored
Merge branch 'main' into feat-Add-a-search/filter-for-collection-pane-#305-
2 parents 1451ea7 + 345f71a commit ac20814

17 files changed

+480
-136
lines changed

lib/consts.dart

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const kForegroundOpacity = 0.05;
5656
const kOverlayBackgroundOpacity = 0.5;
5757

5858
const kTextStyleButton = TextStyle(fontWeight: FontWeight.bold);
59+
const kTextStyleTab = TextStyle(fontSize: 14);
5960
const kTextStyleButtonSmall = TextStyle(fontSize: 12);
6061
const kFormDataButtonLabelTextStyle = TextStyle(
6162
fontSize: 12,
@@ -71,9 +72,13 @@ const kP5 = EdgeInsets.all(5);
7172
const kP8 = EdgeInsets.all(8);
7273
const kPs8 = EdgeInsets.only(left: 8);
7374
const kPs2 = EdgeInsets.only(left: 2);
75+
const kPe8 = EdgeInsets.only(right: 8.0);
7476
const kPh20v5 = EdgeInsets.symmetric(horizontal: 20, vertical: 5);
7577
const kPh20v10 = EdgeInsets.symmetric(horizontal: 20, vertical: 10);
7678
const kP10 = EdgeInsets.all(10);
79+
const kPv8 = EdgeInsets.symmetric(vertical: 8);
80+
const kPv2 = EdgeInsets.symmetric(vertical: 2);
81+
const kPh2 = EdgeInsets.symmetric(horizontal: 2);
7782
const kPt24o8 = EdgeInsets.only(top: 24, left: 8.0, right: 8.0, bottom: 8.0);
7883
const kPt5o10 =
7984
EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 10.0);
@@ -102,8 +107,9 @@ const kP8CollectionPane = EdgeInsets.only(
102107
const kPb10 = EdgeInsets.only(
103108
bottom: 10,
104109
);
105-
const kPr8CollectionPane = EdgeInsets.only(right: 8.0);
106-
const kpsV5 = EdgeInsets.symmetric(vertical: 2);
110+
const kPb15 = EdgeInsets.only(
111+
bottom: 15,
112+
);
107113
const kHSpacer4 = SizedBox(width: 4);
108114
const kHSpacer5 = SizedBox(width: 5);
109115
const kHSpacer10 = SizedBox(width: 10);
@@ -112,9 +118,10 @@ const kVSpacer5 = SizedBox(height: 5);
112118
const kVSpacer8 = SizedBox(height: 8);
113119
const kVSpacer10 = SizedBox(height: 10);
114120
const kVSpacer20 = SizedBox(height: 20);
121+
const kVSpacer40 = SizedBox(height: 40);
115122

116123
const kTabAnimationDuration = Duration(milliseconds: 200);
117-
const kTabHeight = 45.0;
124+
const kTabHeight = 32.0;
118125
const kHeaderHeight = 32.0;
119126
const kSegmentHeight = 24.0;
120127
const kTextButtonMinWidth = 44.0;
@@ -533,3 +540,36 @@ const kLabelSave = "Save";
533540
const kLabelDownload = "Download";
534541
const kLabelSaving = "Saving";
535542
const kLabelSaved = "Saved";
543+
// Request Pane
544+
const kLabelRequest = "Request";
545+
const kLabelHideCode = "Hide Code";
546+
const kLabelViewCode = "View Code";
547+
const kLabelURLParams = "URL Params";
548+
const kLabelHeaders = "Headers";
549+
const kLabelBody = "Body";
550+
const kNameCheckbox = "Checkbox";
551+
const kNameURLParam = "URL Parameter";
552+
const kNameHeader = "Header Name";
553+
const kNameValue = "Value";
554+
const kNameField = "Field";
555+
const kHintAddURLParam = "Add URL Parameter";
556+
const kHintAddValue = "Add Value";
557+
const kHintAddName = "Add Name";
558+
const kHintAddFieldName = "Add Field Name";
559+
const kLabelAddParam = "Add Param";
560+
const kLabelAddHeader = "Add Header";
561+
const kLabelSelectFile = "Select File";
562+
const kLabelAddFormField = "Add Form Field";
563+
// Response Pane
564+
const kLabelNotSent = "Not Sent";
565+
const kLabelResponse = "Response";
566+
const kLabelResponseBody = "Response Body";
567+
const kTooltipClearResponse = "Clear Response";
568+
const kHeaderRow = ["Header Name", "Header Value"];
569+
const kLabelRequestHeaders = "Request Headers";
570+
const kLabelResponseHeaders = "Response Headers";
571+
const kLabelItems = "items";
572+
const kMsgError = "Error: Response data does not exist.";
573+
const kMsgNullBody = "Response body is missing (null).";
574+
const kMsgNoContent = "No content";
575+
const kMsgUnknowContentType = "Unknown Response Content-Type";

lib/models/request_model.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ class RequestModel {
9595
RequestModel duplicate({
9696
required String id,
9797
String? name,
98+
int? requestTabIndex,
9899
}) {
99100
return RequestModel(
100101
id: id,
101102
method: method,
102103
url: url,
103104
name: name ?? "${this.name} (copy)",
104105
description: description,
106+
requestTabIndex: requestTabIndex ?? 0,
105107
requestHeaders: requestHeaders != null ? [...requestHeaders!] : null,
106108
requestParams: requestParams != null ? [...requestParams!] : null,
107109
isHeaderEnabledList:

lib/providers/collection_providers.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class CollectionStateNotifier
102102
final newModel = currentModel.duplicate(
103103
id: id,
104104
name: currentModel.name,
105+
requestTabIndex: currentModel.requestTabIndex,
105106
);
106107
var map = {...state!};
107108
map[id] = newModel;

lib/screens/home_page/collection_pane.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CollectionPane extends ConsumerWidget {
2626
crossAxisAlignment: CrossAxisAlignment.stretch,
2727
children: [
2828
Padding(
29-
padding: kPr8CollectionPane,
29+
padding: kPe8,
3030
child: Wrap(
3131
alignment: WrapAlignment.spaceBetween,
3232
children: [
@@ -148,10 +148,10 @@ class _RequestListState extends ConsumerState<RequestList> {
148148
radius: const Radius.circular(12),
149149
child: filterQuery.isEmpty
150150
? ReorderableListView.builder(
151-
padding: kPr8CollectionPane,
151+
padding: kPe8,
152152
scrollController: controller,
153153
buildDefaultDragHandles: false,
154-
itemCount: requestItems.length,
154+
itemCount: requestSequence.length,
155155
onReorder: (int oldIndex, int newIndex) {
156156
if (oldIndex < newIndex) {
157157
newIndex -= 1;

lib/screens/home_page/editor_pane/details_card/request_pane/request_form_data.dart

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
1818
late int seed;
1919
final random = Random.secure();
2020
late List<FormDataModel> formRows;
21+
bool isAddingRow = false;
2122

2223
@override
2324
void initState() {
@@ -45,13 +46,14 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
4546
]
4647
: rF;
4748
formRows = isFormDataEmpty ? rows : rows + [kFormDataEmptyModel];
49+
isAddingRow = false;
4850

4951
DaviModel<FormDataModel> daviModelRows = DaviModel<FormDataModel>(
5052
rows: formRows,
5153
columns: [
5254
DaviColumn(
53-
cellPadding: kpsV5,
54-
name: 'Key',
55+
cellPadding: kPv2,
56+
name: kNameField,
5557
grow: 4,
5658
cellBuilder: (_, row) {
5759
int idx = row.index;
@@ -61,10 +63,13 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
6163
child: FormDataField(
6264
keyId: "$selectedId-$idx-form-v-$seed",
6365
initialValue: formRows[idx].name,
64-
hintText: " Add Key",
66+
hintText: kHintAddFieldName,
6567
onChanged: (value) {
6668
formRows[idx] = formRows[idx].copyWith(name: value);
67-
if (isLast) formRows.add(kFormDataEmptyModel);
69+
if (isLast && !isAddingRow) {
70+
isAddingRow = true;
71+
formRows.add(kFormDataEmptyModel);
72+
}
6873
_onFieldChange(selectedId!);
6974
},
7075
colorScheme: Theme.of(context).colorScheme,
@@ -75,7 +80,7 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
7580
type: value ?? FormDataType.text,
7681
);
7782
formRows[idx] = formRows[idx].copyWith(value: "");
78-
if (idx == formRows.length - 1 && hasChanged) {
83+
if (isLast && hasChanged) {
7984
formRows.add(kFormDataEmptyModel);
8085
}
8186
setState(() {});
@@ -88,7 +93,7 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
8893
),
8994
DaviColumn(
9095
width: 40,
91-
cellPadding: kpsV5,
96+
cellPadding: kPv2,
9297
cellAlignment: Alignment.center,
9398
cellBuilder: (_, row) {
9499
return Text(
@@ -98,9 +103,9 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
98103
},
99104
),
100105
DaviColumn(
101-
name: 'Value',
106+
name: kNameValue,
102107
grow: 4,
103-
cellPadding: kpsV5,
108+
cellPadding: kPv2,
104109
cellBuilder: (_, row) {
105110
int idx = row.index;
106111
bool isLast = idx + 1 == formRows.length;
@@ -140,7 +145,7 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
140145
(formRows[idx].type == FormDataType.file &&
141146
formRows[idx].value.isNotEmpty)
142147
? formRows[idx].value.toString()
143-
: "Select File",
148+
: kLabelSelectFile,
144149
textAlign: TextAlign.center,
145150
overflow: TextOverflow.ellipsis,
146151
style: kFormDataButtonLabelTextStyle,
@@ -154,10 +159,13 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
154159
: CellField(
155160
keyId: "$selectedId-$idx-form-v-$seed",
156161
initialValue: formRows[idx].value,
157-
hintText: " Add Value",
162+
hintText: kHintAddValue,
158163
onChanged: (value) {
159164
formRows[idx] = formRows[idx].copyWith(value: value);
160-
if (isLast) formRows.add(kFormDataEmptyModel);
165+
if (isLast && !isAddingRow) {
166+
isAddingRow = true;
167+
formRows.add(kFormDataEmptyModel);
168+
}
161169
_onFieldChange(selectedId!);
162170
},
163171
colorScheme: Theme.of(context).colorScheme,
@@ -208,21 +216,22 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
208216
child: Davi<FormDataModel>(daviModelRows),
209217
),
210218
),
219+
kVSpacer20,
211220
],
212221
),
213222
),
214223
Align(
215224
alignment: Alignment.bottomCenter,
216225
child: Padding(
217-
padding: const EdgeInsets.only(bottom: 30),
226+
padding: const EdgeInsets.only(bottom: 5),
218227
child: ElevatedButton.icon(
219228
onPressed: () {
220229
formRows.add(kFormDataEmptyModel);
221230
_onFieldChange(selectedId!);
222231
},
223232
icon: const Icon(Icons.add),
224233
label: const Text(
225-
"Add Form Data",
234+
kLabelAddFormField,
226235
style: kTextStyleButton,
227236
),
228237
),

lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
1919
final random = Random.secure();
2020
late List<NameValueModel> headerRows;
2121
late List<bool> isRowEnabledList;
22+
bool isAddingRow = false;
2223

2324
@override
2425
void initState() {
@@ -52,12 +53,13 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
5253
ref.read(selectedRequestModelProvider)?.isHeaderEnabledList ??
5354
List.filled(rH?.length ?? 0, true, growable: true);
5455
isRowEnabledList.add(false);
56+
isAddingRow = false;
5557

5658
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
5759
rows: headerRows,
5860
columns: [
5961
DaviColumn(
60-
name: 'Checkbox',
62+
name: kNameCheckbox,
6163
width: 30,
6264
cellBuilder: (_, row) {
6365
int idx = row.index;
@@ -78,7 +80,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
7880
},
7981
),
8082
DaviColumn(
81-
name: 'Header Name',
83+
name: kNameHeader,
8284
width: 70,
8385
grow: 1,
8486
cellBuilder: (_, row) {
@@ -87,10 +89,11 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
8789
return HeaderField(
8890
keyId: "$selectedId-$idx-headers-k-$seed",
8991
initialValue: headerRows[idx].name,
90-
hintText: "Add Header Name",
92+
hintText: kHintAddName,
9193
onChanged: (value) {
9294
headerRows[idx] = headerRows[idx].copyWith(name: value);
93-
if (isLast) {
95+
if (isLast && !isAddingRow) {
96+
isAddingRow = true;
9497
isRowEnabledList[idx] = true;
9598
headerRows.add(kNameValueEmptyModel);
9699
isRowEnabledList.add(false);
@@ -112,18 +115,19 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
112115
},
113116
),
114117
DaviColumn(
115-
name: 'Header Value',
118+
name: kNameValue,
116119
grow: 1,
117120
cellBuilder: (_, row) {
118121
int idx = row.index;
119122
bool isLast = idx + 1 == headerRows.length;
120123
return CellField(
121124
keyId: "$selectedId-$idx-headers-v-$seed",
122125
initialValue: headerRows[idx].value,
123-
hintText: " Add Header Value",
126+
hintText: kHintAddValue,
124127
onChanged: (value) {
125128
headerRows[idx] = headerRows[idx].copyWith(value: value);
126-
if (isLast) {
129+
if (isLast && !isAddingRow) {
130+
isAddingRow = true;
127131
isRowEnabledList[idx] = true;
128132
headerRows.add(kNameValueEmptyModel);
129133
isRowEnabledList.add(false);
@@ -182,13 +186,14 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
182186
child: Davi<NameValueModel>(model),
183187
),
184188
),
189+
kVSpacer40,
185190
],
186191
),
187192
),
188193
Align(
189194
alignment: Alignment.bottomCenter,
190195
child: Padding(
191-
padding: const EdgeInsets.only(bottom: 30),
196+
padding: kPb15,
192197
child: ElevatedButton.icon(
193198
onPressed: () {
194199
headerRows.add(kNameValueEmptyModel);
@@ -197,7 +202,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
197202
},
198203
icon: const Icon(Icons.add),
199204
label: const Text(
200-
"Add Header",
205+
kLabelAddHeader,
201206
style: kTextStyleButton,
202207
),
203208
),

0 commit comments

Comments
 (0)