Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/dashbot/widgets/home_screen_task_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ class HomeScreenTaskButton extends StatelessWidget {
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(
vertical: 0,
vertical: 8, // increased padding
horizontal: 16,
),
),
child: Text(
label,
textAlign: textAlign,
child: Tooltip( // NEW
message: label,
child: Text(
label,
textAlign: textAlign,
overflow: TextOverflow.ellipsis, // NEW
maxLines: 1, // NEW
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:convert'; // NEW

import 'package:apidash_core/apidash_core.dart';
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:flutter/material.dart';
Expand All @@ -10,6 +12,16 @@ import 'request_form_data.dart';
class EditRequestBody extends ConsumerWidget {
const EditRequestBody({super.key});

// NEW FUNCTION
bool isValidJson(String input) {
try {
jsonDecode(input);
return true;
} catch (e) {
return false;
}
}

@override
Widget build(BuildContext context, WidgetRef ref) {
final selectedId = ref.watch(selectedIdStateProvider);
Expand Down Expand Up @@ -44,58 +56,83 @@ class EditRequestBody extends ConsumerWidget {
: kSizedBoxEmpty,
switch (apiType) {
APIType.rest => Expanded(
child: switch (contentType) {
ContentType.formdata => const Padding(
padding: kPh4,
child: FormDataWidget(),
),
ContentType.json => Padding(
padding: kPt5o10,
child: JsonTextFieldEditor(
key: Key("$selectedId-json-body"),
fieldKey: "$selectedId-json-body-editor-$darkMode",
isDark: darkMode,
initialValue: requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(body: value);
},
hintText: kHintJson,
),
),
_ => Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-body"),
fieldKey: "$selectedId-body-editor",
initialValue: requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(body: value);
},
hintText: kHintText,
),
child: switch (contentType) {
ContentType.formdata => const Padding(
padding: kPh4,
child: FormDataWidget(),
),
ContentType.json => Padding(
padding: kPt5o10,
child: JsonTextFieldEditor(
key: Key("$selectedId-json-body"),
fieldKey: "$selectedId-json-body-editor-$darkMode",
isDark: darkMode,
initialValue:
requestModel?.httpRequestModel?.body,


onChanged: (String value) {
if (value.isNotEmpty &&
!isValidJson(value)) {
ScaffoldMessenger.of(context)
.showSnackBar(
const SnackBar(
content:
Text("Invalid JSON format"),
backgroundColor: Colors.red,
),
);
return;
}

ref
.read(
collectionStateNotifierProvider
.notifier)
.update(body: value);
},

hintText: kHintJson,
),
),
_ => Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-body"),
fieldKey: "$selectedId-body-editor",
initialValue:
requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(
collectionStateNotifierProvider
.notifier)
.update(body: value);
},
hintText: kHintText,
),
),
},
),
},
),
APIType.graphql => Expanded(
child: Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-query"),
fieldKey: "$selectedId-query-editor",
initialValue: requestModel?.httpRequestModel?.query,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(query: value);
},
hintText: kHintQuery,
child: Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-query"),
fieldKey: "$selectedId-query-editor",
initialValue:
requestModel?.httpRequestModel?.query,
onChanged: (String value) {
ref
.read(
collectionStateNotifierProvider
.notifier)
.update(query: value);
},
hintText: kHintQuery,
),
),
),
),
),
_ => kSizedBoxEmpty,
},
],
Expand Down
16 changes: 10 additions & 6 deletions lib/widgets/tab_label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TabLabel extends StatelessWidget {
required this.text,
this.showIndicator = false,
});

final String text;
final bool showIndicator;

Expand All @@ -18,12 +19,15 @@ class TabLabel extends StatelessWidget {
child: Stack(
children: [
Center(
child: Text(
text,
textAlign: TextAlign.center,
overflow: TextOverflow.fade,
softWrap: false,
style: kTextStyleTab,
child: Tooltip( // NEW
message: text,
child: Text(
text,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis, // improved
maxLines: 1, // NEW
style: kTextStyleTab,
),
),
),
if (showIndicator)
Expand Down