From ce5278f02b659662c801cb0f0634f5bb4a0327b5 Mon Sep 17 00:00:00 2001 From: Mrudul-2 <147049798+Mrudul-2@users.noreply.github.com> Date: Sat, 22 Feb 2025 13:49:02 +0530 Subject: [PATCH 01/11] integrated a beautify button in JSON codegen and also highlighted the key and string text. --- .../history_widgets/his_request_pane.dart | 3 +- .../request_pane/request_body.dart | 3 +- lib/widgets/editor_json.dart | 132 ++++++++++-------- .../lib/tokens/colors.dart | 3 + 4 files changed, 79 insertions(+), 62 deletions(-) diff --git a/lib/screens/history/history_widgets/his_request_pane.dart b/lib/screens/history/history_widgets/his_request_pane.dart index dc618e77..f9d38300 100644 --- a/lib/screens/history/history_widgets/his_request_pane.dart +++ b/lib/screens/history/history_widgets/his_request_pane.dart @@ -140,12 +140,11 @@ class HisRequestBody extends ConsumerWidget { // TODO: Fix JsonTextFieldEditor & plug it here ContentType.json => Padding( padding: kPt5o10, - child: TextFieldEditor( + child: JsonTextFieldEditor( key: Key("${selectedHistoryModel?.historyId}-json-body"), fieldKey: "${selectedHistoryModel?.historyId}-json-body-viewer", initialValue: requestModel?.body, - readOnly: true, ), ), _ => Padding( diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart index 26686e67..7e42c309 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart @@ -64,7 +64,7 @@ class EditRequestBody extends ConsumerWidget { // TODO: Fix JsonTextFieldEditor & plug it here ContentType.json => Padding( padding: kPt5o10, - child: TextFieldEditor( + child: JsonTextFieldEditor( key: Key("$selectedId-json-body"), fieldKey: "$selectedId-json-body-editor", initialValue: requestModel?.httpRequestModel?.body, @@ -74,7 +74,6 @@ class EditRequestBody extends ConsumerWidget { .read(collectionStateNotifierProvider.notifier) .update(body: value); }, - hintText: kHintJson, ), ), _ => Padding( diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index 3c0c2abf..8cc2b78f 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -1,5 +1,8 @@ +import 'package:apidash/widgets/widgets.dart'; import 'dart:math' as math; import 'package:apidash/consts.dart'; +import 'package:apidash/utils/utils.dart'; +import 'dart:convert'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -59,71 +62,84 @@ class _JsonTextFieldEditorState extends State { if (widget.initialValue != null) { controller.text = widget.initialValue!; } - return CallbackShortcuts( - bindings: { - const SingleActivator(LogicalKeyboardKey.tab): () { - insertTab(); - }, - }, - child: JsonTextField( - stringHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).colorScheme.secondary, + return Column( + mainAxisSize: MainAxisSize.max, + children: [ + Align( + alignment: Alignment.topRight, + child: IconButton( + icon: const Icon(Icons.format_align_left), + onPressed: () { + controller.formatJson(sortJson: false); + }, + ), ), - keyHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).colorScheme.primary, - fontWeight: FontWeight.bold, - ), - errorContainerDecoration: BoxDecoration( - color: Theme.of(context).colorScheme.error.withOpacity( - kForegroundOpacity, + Expanded( + child: CallbackShortcuts( + bindings: { + const SingleActivator(LogicalKeyboardKey.tab): () { + insertTab(); + }, + }, + child: JsonTextField( + stringHighlightStyle: kCodeStyle.copyWith( + color: kColorJSONString, ), - borderRadius: kBorderRadius8, - ), - showErrorMessage: true, - isFormatting: true, - key: Key(widget.fieldKey), - controller: controller, - focusNode: editorFocusNode, - keyboardType: TextInputType.multiline, - expands: true, - maxLines: null, - style: kCodeStyle, - textAlignVertical: TextAlignVertical.top, - onChanged: (value) { - controller.formatJson(sortJson: false); - widget.onChanged?.call(value); - }, - decoration: InputDecoration( - hintText: kHintJson, - hintStyle: TextStyle( - color: Theme.of(context).colorScheme.outline.withOpacity( - kHintOpacity, + keyHighlightStyle: kCodeStyle.copyWith( + color: kColorJSONKey, + fontWeight: FontWeight.bold, + ), + errorContainerDecoration: BoxDecoration( + color: Theme.of(context).colorScheme.error.withOpacity( + kForegroundOpacity, + ), + borderRadius: kBorderRadius8, + ), + showErrorMessage: true, + isFormatting: true, + key: Key(widget.fieldKey), + controller: controller, + focusNode: editorFocusNode, + keyboardType: TextInputType.multiline, + expands: true, + maxLines: null, + style: kCodeStyle, + textAlignVertical: TextAlignVertical.top, + decoration: InputDecoration( + hintText: kHintJson, + hintStyle: TextStyle( + color: Theme.of(context).colorScheme.outline.withOpacity( + kHintOpacity, + ), ), - ), - focusedBorder: OutlineInputBorder( - borderRadius: kBorderRadius8, - borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity( - kHintOpacity, + focusedBorder: OutlineInputBorder( + borderRadius: kBorderRadius8, + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primary.withOpacity( + kHintOpacity, + ), ), + ), + enabledBorder: OutlineInputBorder( + borderRadius: kBorderRadius8, + borderSide: BorderSide( + color: + Theme.of(context).colorScheme.surfaceContainerHighest, + ), + ), + filled: true, + hoverColor: kColorTransparent, + fillColor: Color.alphaBlend( + (Theme.of(context).brightness == Brightness.dark + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.primaryContainer) + .withOpacity(kForegroundOpacity), + Theme.of(context).colorScheme.surface), + ), ), ), - enabledBorder: OutlineInputBorder( - borderRadius: kBorderRadius8, - borderSide: BorderSide( - color: Theme.of(context).colorScheme.surfaceContainerHighest, - ), - ), - filled: true, - hoverColor: kColorTransparent, - fillColor: Color.alphaBlend( - (Theme.of(context).brightness == Brightness.dark - ? Theme.of(context).colorScheme.onPrimaryContainer - : Theme.of(context).colorScheme.primaryContainer) - .withOpacity(kForegroundOpacity), - Theme.of(context).colorScheme.surface), ), - ), + ], ); } } diff --git a/packages/apidash_design_system/lib/tokens/colors.dart b/packages/apidash_design_system/lib/tokens/colors.dart index 7d873fcd..e6f99707 100644 --- a/packages/apidash_design_system/lib/tokens/colors.dart +++ b/packages/apidash_design_system/lib/tokens/colors.dart @@ -9,6 +9,9 @@ const kColorRed = Colors.red; final kColorLightDanger = Colors.red.withOpacity(0.9); const kColorDarkDanger = Color(0xffcf6679); +const kColorJSONKey = Color(0xFF1757BA); +const kColorJSONString = Color(0xFFA82323); + const kColorSchemeSeed = Colors.blue; final kColorStatusCodeDefault = Colors.grey.shade700; From c078a11c56c11d9c0ec39b98342f67f20201d327 Mon Sep 17 00:00:00 2001 From: Mrudul-2 <147049798+Mrudul-2@users.noreply.github.com> Date: Sat, 22 Feb 2025 22:43:01 +0530 Subject: [PATCH 02/11] used themes.dart file based colors --- lib/widgets/editor_json.dart | 9 +++++++-- packages/apidash_design_system/lib/tokens/colors.dart | 3 --- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index 8cc2b78f..3d13e439 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -83,10 +83,15 @@ class _JsonTextFieldEditorState extends State { }, child: JsonTextField( stringHighlightStyle: kCodeStyle.copyWith( - color: kColorJSONString, + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['string']?.color + : kLightCodeTheme['string']?.color, ), + keyHighlightStyle: kCodeStyle.copyWith( - color: kColorJSONKey, + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['attr']?.color + : kLightCodeTheme['attr']?.color, fontWeight: FontWeight.bold, ), errorContainerDecoration: BoxDecoration( diff --git a/packages/apidash_design_system/lib/tokens/colors.dart b/packages/apidash_design_system/lib/tokens/colors.dart index e6f99707..7d873fcd 100644 --- a/packages/apidash_design_system/lib/tokens/colors.dart +++ b/packages/apidash_design_system/lib/tokens/colors.dart @@ -9,9 +9,6 @@ const kColorRed = Colors.red; final kColorLightDanger = Colors.red.withOpacity(0.9); const kColorDarkDanger = Color(0xffcf6679); -const kColorJSONKey = Color(0xFF1757BA); -const kColorJSONString = Color(0xFFA82323); - const kColorSchemeSeed = Colors.blue; final kColorStatusCodeDefault = Colors.grey.shade700; From 26554e2476202ea412d143139954eafff417dcfb Mon Sep 17 00:00:00 2001 From: Mrudul-2 <147049798+Mrudul-2@users.noreply.github.com> Date: Sat, 22 Feb 2025 23:36:27 +0530 Subject: [PATCH 03/11] readOnly implementation in widget as well as history page --- lib/screens/history/history_widgets/his_request_pane.dart | 1 + lib/widgets/editor_json.dart | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/screens/history/history_widgets/his_request_pane.dart b/lib/screens/history/history_widgets/his_request_pane.dart index f9d38300..a64b96f8 100644 --- a/lib/screens/history/history_widgets/his_request_pane.dart +++ b/lib/screens/history/history_widgets/his_request_pane.dart @@ -145,6 +145,7 @@ class HisRequestBody extends ConsumerWidget { fieldKey: "${selectedHistoryModel?.historyId}-json-body-viewer", initialValue: requestModel?.body, + readOnly: true, ), ), _ => Padding( diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index 3d13e439..b7e24dbe 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -14,11 +14,13 @@ class JsonTextFieldEditor extends StatefulWidget { required this.fieldKey, this.onChanged, this.initialValue, + this.readOnly = false, }); final String fieldKey; final Function(String)? onChanged; final String? initialValue; + final bool readOnly; @override State createState() => _JsonTextFieldEditorState(); } @@ -101,6 +103,7 @@ class _JsonTextFieldEditorState extends State { borderRadius: kBorderRadius8, ), showErrorMessage: true, + readOnly: widget.readOnly, isFormatting: true, key: Key(widget.fieldKey), controller: controller, From 8a996f76198f6cadb1a02b216d32c7e084e398a5 Mon Sep 17 00:00:00 2001 From: Mrudul-2 <147049798+Mrudul-2@users.noreply.github.com> Date: Sun, 23 Feb 2025 13:55:22 +0530 Subject: [PATCH 04/11] implementation of bool,null and number styles --- lib/widgets/editor_json.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index b7e24dbe..5dafaeb8 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -89,7 +89,21 @@ class _JsonTextFieldEditorState extends State { ? kDarkCodeTheme['string']?.color : kLightCodeTheme['string']?.color, ), - + numberHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['number']?.color + : kLightCodeTheme['number']?.color, + ), + boolHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['literal']?.color + : kLightCodeTheme['literal']?.color, + ), + nullHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['variable']?.color + : kLightCodeTheme['variable']?.color, + ), keyHighlightStyle: kCodeStyle.copyWith( color: Theme.of(context).brightness == Brightness.dark ? kDarkCodeTheme['attr']?.color @@ -105,6 +119,7 @@ class _JsonTextFieldEditorState extends State { showErrorMessage: true, readOnly: widget.readOnly, isFormatting: true, + key: Key(widget.fieldKey), controller: controller, focusNode: editorFocusNode, From a562fc71a13eda2ee49b94adcf99323d31bfeaf4 Mon Sep 17 00:00:00 2001 From: WannaCry016 <166608111+WannaCry016@users.noreply.github.com> Date: Sat, 29 Mar 2025 19:12:09 +0530 Subject: [PATCH 05/11] Update request_pane.dart --- lib/widgets/request_pane.dart | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/widgets/request_pane.dart b/lib/widgets/request_pane.dart index 95871d53..2ff82fb0 100644 --- a/lib/widgets/request_pane.dart +++ b/lib/widgets/request_pane.dart @@ -57,20 +57,19 @@ class _RequestPaneState extends State style: FilledButton.styleFrom( padding: kPh12, minimumSize: const Size(44, 44), + visualDensity: VisualDensity.compact, + alignment: Alignment.center, ), onPressed: widget.onPressedCodeButton, icon: Icon( - widget.codePaneVisible - ? Icons.code_off_rounded - : Icons.code_rounded, + widget.codePaneVisible ? Icons.code_off_rounded : Icons.code_rounded, + size: 20, ), - label: SizedBox( - width: 75, - child: Text( - widget.codePaneVisible - ? kLabelHideCode - : kLabelViewCode, - ), + label: Text( + widget.codePaneVisible ? kLabelHideCode : kLabelViewCode, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + maxLines: 1, ), ), ], From d03eb12e5a9862e2b0aea95e7e8fad9a39d0ff1a Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sat, 29 Mar 2025 19:23:19 +0530 Subject: [PATCH 06/11] JsonTextFieldEditor fixes --- .../request_pane/request_body.dart | 5 +- lib/widgets/editor_json.dart | 214 ++++++++++-------- 2 files changed, 120 insertions(+), 99 deletions(-) diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart index 7e42c309..1113a1f0 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart @@ -20,6 +20,9 @@ class EditRequestBody extends ConsumerWidget { .select((value) => value?.httpRequestModel?.bodyContentType)); final apiType = ref .watch(selectedRequestModelProvider.select((value) => value?.apiType)); + final mode = ref.watch(settingsProvider.select( + (value) => value.isDark, + )); // TODO: #178 GET->POST Currently switches to POST everytime user edits body even if the user intentionally chooses GET // final sm = ScaffoldMessenger.of(context); @@ -66,7 +69,7 @@ class EditRequestBody extends ConsumerWidget { padding: kPt5o10, child: JsonTextFieldEditor( key: Key("$selectedId-json-body"), - fieldKey: "$selectedId-json-body-editor", + fieldKey: "$selectedId-json-body-editor-$mode", initialValue: requestModel?.httpRequestModel?.body, onChanged: (String value) { // changeToPostMethod(); diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index 5dafaeb8..161c4dae 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -1,12 +1,9 @@ -import 'package:apidash/widgets/widgets.dart'; import 'dart:math' as math; -import 'package:apidash/consts.dart'; -import 'package:apidash/utils/utils.dart'; -import 'dart:convert'; import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:json_text_field/json_text_field.dart'; +import 'package:apidash/consts.dart'; class JsonTextFieldEditor extends StatefulWidget { const JsonTextFieldEditor({ @@ -49,6 +46,9 @@ class _JsonTextFieldEditorState extends State { @override void initState() { super.initState(); + if (widget.initialValue != null) { + controller.text = widget.initialValue!; + } controller.formatJson(sortJson: false); editorFocusNode = FocusNode(debugLabel: "Editor Focus Node"); } @@ -60,106 +60,124 @@ class _JsonTextFieldEditorState extends State { } @override - Widget build(BuildContext context) { - if (widget.initialValue != null) { - controller.text = widget.initialValue!; + void didUpdateWidget(JsonTextFieldEditor oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.initialValue != widget.initialValue) { + controller.text = widget.initialValue ?? ""; + controller.selection = + TextSelection.collapsed(offset: controller.text.length); } - return Column( - mainAxisSize: MainAxisSize.max, + if (oldWidget.fieldKey != widget.fieldKey) { + // TODO: JsonTextField uses ExtendedTextField which does + // not rebuild because no key is provided + // so light mode to dark mode switching leads to incorrect color. + setState(() {}); + } + } + + @override + Widget build(BuildContext context) { + return Stack( children: [ - Align( - alignment: Alignment.topRight, - child: IconButton( - icon: const Icon(Icons.format_align_left), - onPressed: () { - controller.formatJson(sortJson: false); + CallbackShortcuts( + bindings: { + const SingleActivator(LogicalKeyboardKey.tab): () { + insertTab(); }, + }, + child: JsonTextField( + key: Key(widget.fieldKey), + commonTextStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['root']?.color + : kLightCodeTheme['root']?.color, + ), + specialCharHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['root']?.color + : kLightCodeTheme['root']?.color, + ), + stringHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['string']?.color + : kLightCodeTheme['string']?.color, + ), + numberHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['number']?.color + : kLightCodeTheme['number']?.color, + ), + boolHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['literal']?.color + : kLightCodeTheme['literal']?.color, + ), + nullHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['variable']?.color + : kLightCodeTheme['variable']?.color, + ), + keyHighlightStyle: kCodeStyle.copyWith( + color: Theme.of(context).brightness == Brightness.dark + ? kDarkCodeTheme['attr']?.color + : kLightCodeTheme['attr']?.color, + fontWeight: FontWeight.bold, + ), + // errorContainerDecoration: BoxDecoration( + // color: Theme.of(context).colorScheme.error.withOpacity( + // kForegroundOpacity, + // ), + // borderRadius: kBorderRadius8, + // ), + // TODO: Show error message in Global Status bar + // showErrorMessage: true, + isFormatting: true, + controller: controller, + focusNode: editorFocusNode, + keyboardType: TextInputType.multiline, + expands: true, + maxLines: null, + readOnly: widget.readOnly, + style: kCodeStyle.copyWith( + fontSize: Theme.of(context).textTheme.bodyMedium?.fontSize, + ), + textAlignVertical: TextAlignVertical.top, + onChanged: widget.onChanged, + onTapOutside: (PointerDownEvent event) { + editorFocusNode.unfocus(); + }, + decoration: InputDecoration( + hintText: kHintJson, + hintStyle: TextStyle( + color: Theme.of(context).colorScheme.outlineVariant, + ), + focusedBorder: OutlineInputBorder( + borderRadius: kBorderRadius8, + borderSide: BorderSide( + color: Theme.of(context).colorScheme.outlineVariant, + ), + ), + enabledBorder: OutlineInputBorder( + borderRadius: kBorderRadius8, + borderSide: BorderSide( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + ), + ), + filled: true, + hoverColor: kColorTransparent, + fillColor: Theme.of(context).colorScheme.surfaceContainerLow, + ), ), ), - Expanded( - child: CallbackShortcuts( - bindings: { - const SingleActivator(LogicalKeyboardKey.tab): () { - insertTab(); - }, + Align( + alignment: Alignment.topRight, + child: ADIconButton( + icon: Icons.format_align_left, + tooltip: "Format JSON", + onPressed: () { + controller.formatJson(sortJson: false); + widget.onChanged?.call(controller.text); }, - child: JsonTextField( - stringHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? kDarkCodeTheme['string']?.color - : kLightCodeTheme['string']?.color, - ), - numberHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? kDarkCodeTheme['number']?.color - : kLightCodeTheme['number']?.color, - ), - boolHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? kDarkCodeTheme['literal']?.color - : kLightCodeTheme['literal']?.color, - ), - nullHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? kDarkCodeTheme['variable']?.color - : kLightCodeTheme['variable']?.color, - ), - keyHighlightStyle: kCodeStyle.copyWith( - color: Theme.of(context).brightness == Brightness.dark - ? kDarkCodeTheme['attr']?.color - : kLightCodeTheme['attr']?.color, - fontWeight: FontWeight.bold, - ), - errorContainerDecoration: BoxDecoration( - color: Theme.of(context).colorScheme.error.withOpacity( - kForegroundOpacity, - ), - borderRadius: kBorderRadius8, - ), - showErrorMessage: true, - readOnly: widget.readOnly, - isFormatting: true, - - key: Key(widget.fieldKey), - controller: controller, - focusNode: editorFocusNode, - keyboardType: TextInputType.multiline, - expands: true, - maxLines: null, - style: kCodeStyle, - textAlignVertical: TextAlignVertical.top, - decoration: InputDecoration( - hintText: kHintJson, - hintStyle: TextStyle( - color: Theme.of(context).colorScheme.outline.withOpacity( - kHintOpacity, - ), - ), - focusedBorder: OutlineInputBorder( - borderRadius: kBorderRadius8, - borderSide: BorderSide( - color: Theme.of(context).colorScheme.primary.withOpacity( - kHintOpacity, - ), - ), - ), - enabledBorder: OutlineInputBorder( - borderRadius: kBorderRadius8, - borderSide: BorderSide( - color: - Theme.of(context).colorScheme.surfaceContainerHighest, - ), - ), - filled: true, - hoverColor: kColorTransparent, - fillColor: Color.alphaBlend( - (Theme.of(context).brightness == Brightness.dark - ? Theme.of(context).colorScheme.onPrimaryContainer - : Theme.of(context).colorScheme.primaryContainer) - .withOpacity(kForegroundOpacity), - Theme.of(context).colorScheme.surface), - ), - ), ), ), ], From b9cd3e56847fa9fe14acc45129f7cb7280b696a2 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sat, 29 Mar 2025 19:29:29 +0530 Subject: [PATCH 07/11] Add hintText --- .../editor_pane/details_card/request_pane/request_body.dart | 1 + lib/widgets/editor_json.dart | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart index 1113a1f0..651e527e 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart @@ -77,6 +77,7 @@ class EditRequestBody extends ConsumerWidget { .read(collectionStateNotifierProvider.notifier) .update(body: value); }, + hintText: kHintJson, ), ), _ => Padding( diff --git a/lib/widgets/editor_json.dart b/lib/widgets/editor_json.dart index 161c4dae..33f026c5 100644 --- a/lib/widgets/editor_json.dart +++ b/lib/widgets/editor_json.dart @@ -11,12 +11,14 @@ class JsonTextFieldEditor extends StatefulWidget { required this.fieldKey, this.onChanged, this.initialValue, + this.hintText, this.readOnly = false, }); final String fieldKey; final Function(String)? onChanged; final String? initialValue; + final String? hintText; final bool readOnly; @override State createState() => _JsonTextFieldEditorState(); @@ -147,7 +149,7 @@ class _JsonTextFieldEditorState extends State { editorFocusNode.unfocus(); }, decoration: InputDecoration( - hintText: kHintJson, + hintText: widget.hintText ?? kHintContent, hintStyle: TextStyle( color: Theme.of(context).colorScheme.outlineVariant, ), From b0c0dd0646ef3d6ffbc4b31e0441e33151167db5 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sat, 29 Mar 2025 20:32:29 +0530 Subject: [PATCH 08/11] Update request_body.dart --- .../editor_pane/details_card/request_pane/request_body.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart index f6165122..8c5a805d 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart @@ -45,7 +45,6 @@ class EditRequestBody extends ConsumerWidget { child: switch (contentType) { ContentType.formdata => const Padding(padding: kPh4, child: FormDataWidget()), - // TODO: Fix JsonTextFieldEditor & plug it here ContentType.json => Padding( padding: kPt5o10, child: JsonTextFieldEditor( From c4905a24902ff44138679db1bf1fd257b6c18ce6 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sat, 29 Mar 2025 20:33:42 +0530 Subject: [PATCH 09/11] Update request_pane.dart --- lib/widgets/request_pane.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/widgets/request_pane.dart b/lib/widgets/request_pane.dart index 2ff82fb0..9cd08996 100644 --- a/lib/widgets/request_pane.dart +++ b/lib/widgets/request_pane.dart @@ -57,19 +57,23 @@ class _RequestPaneState extends State style: FilledButton.styleFrom( padding: kPh12, minimumSize: const Size(44, 44), - visualDensity: VisualDensity.compact, - alignment: Alignment.center, + visualDensity: VisualDensity.compact, + alignment: Alignment.center, ), onPressed: widget.onPressedCodeButton, icon: Icon( - widget.codePaneVisible ? Icons.code_off_rounded : Icons.code_rounded, - size: 20, + widget.codePaneVisible + ? Icons.code_off_rounded + : Icons.code_rounded, + size: 20, ), label: Text( - widget.codePaneVisible ? kLabelHideCode : kLabelViewCode, + widget.codePaneVisible + ? kLabelHideCode + : kLabelViewCode, textAlign: TextAlign.center, - overflow: TextOverflow.ellipsis, - maxLines: 1, + overflow: TextOverflow.ellipsis, + maxLines: 1, ), ), ], From db4a5314ab7291a5393ae2c0e6c057f5370cd148 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sat, 29 Mar 2025 20:36:50 +0530 Subject: [PATCH 10/11] Update request_pane.dart --- lib/widgets/request_pane.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/widgets/request_pane.dart b/lib/widgets/request_pane.dart index 9cd08996..a9dfbeef 100644 --- a/lib/widgets/request_pane.dart +++ b/lib/widgets/request_pane.dart @@ -57,8 +57,6 @@ class _RequestPaneState extends State style: FilledButton.styleFrom( padding: kPh12, minimumSize: const Size(44, 44), - visualDensity: VisualDensity.compact, - alignment: Alignment.center, ), onPressed: widget.onPressedCodeButton, icon: Icon( From ea0034e31eaaa11f6d08df522674a4b2c76b5ad9 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sat, 29 Mar 2025 20:40:59 +0530 Subject: [PATCH 11/11] Update request_pane.dart --- lib/widgets/request_pane.dart | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/widgets/request_pane.dart b/lib/widgets/request_pane.dart index a9dfbeef..09ebd0a3 100644 --- a/lib/widgets/request_pane.dart +++ b/lib/widgets/request_pane.dart @@ -63,15 +63,17 @@ class _RequestPaneState extends State widget.codePaneVisible ? Icons.code_off_rounded : Icons.code_rounded, - size: 20, + size: 18, ), - label: Text( - widget.codePaneVisible - ? kLabelHideCode - : kLabelViewCode, - textAlign: TextAlign.center, - overflow: TextOverflow.ellipsis, - maxLines: 1, + label: SizedBox( + width: 80, + child: Text( + widget.codePaneVisible + ? kLabelHideCode + : kLabelViewCode, + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), ), ), ],