feat: add indicator for request scripts

Shows an indicator on the 'Scripts' tab when pre-request or post-request scripts exist for the selected request.
Updates the selected tab text color in the scripts pane for better visibility.
This commit is contained in:
Udhay-Adithya
2025-05-01 17:11:10 +05:30
parent 36061f660a
commit 6344e8df21
2 changed files with 12 additions and 1 deletions

View File

@@ -28,6 +28,12 @@ class EditRestRequestPane extends ConsumerWidget {
.select((value) => value?.httpRequestModel?.hasBody)) ?? .select((value) => value?.httpRequestModel?.hasBody)) ??
false; false;
final scriptsLength = ref.watch(selectedRequestModelProvider
.select((value) => value?.preRequestScript.length)) ??
ref.watch(selectedRequestModelProvider
.select((value) => value?.postRequestScript.length)) ??
0;
return RequestPane( return RequestPane(
selectedId: selectedId, selectedId: selectedId,
codePaneVisible: codePaneVisible, codePaneVisible: codePaneVisible,
@@ -45,7 +51,7 @@ class EditRestRequestPane extends ConsumerWidget {
paramLength > 0, paramLength > 0,
headerLength > 0, headerLength > 0,
hasBody, hasBody,
false, // TODO: Add indicator condition once it is added to [selectedRequestModelProvider] scriptsLength > 0,
], ],
tabLabels: const [ tabLabels: const [
kLabelURLParams, kLabelURLParams,

View File

@@ -73,6 +73,11 @@ class _ScriptsCodePaneState extends ConsumerState<ScriptsCodePane> {
tabs[i], tabs[i],
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: _selectedTabIndex == i
? Theme.of(context)
.colorScheme
.onSecondaryFixedVariant
: Theme.of(context).colorScheme.onSurface,
), ),
), ),
selected: _selectedTabIndex == i, selected: _selectedTabIndex == i,