-
Couldn't load subscription status.
- Fork 583
Adding Tabs at the top of the request pane #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+309
−41
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fe6f046
Initial commit
BalaSubramaniam12007 2c417f7
This commit the fixes all identified bugs, ensuring:
BalaSubramaniam12007 e966771
(feat)(style) Enhance the default request screen
BalaSubramaniam12007 7da87a5
(style) :Updated tab component to display the close button only when ...
BalaSubramaniam12007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
lib/screens/home_page/editor_pane/tab_pane.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import 'package:apidash_design_system/apidash_design_system.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
| import 'package:apidash/consts.dart'; | ||
| import 'package:apidash/providers/collection_providers.dart'; | ||
| import 'package:apidash/models/models.dart'; | ||
| import 'package:apidash/widgets/tab_request_card.dart'; | ||
| import 'package:apidash/utils/utils.dart'; | ||
|
|
||
| class TabPane extends ConsumerWidget { | ||
| const TabPane({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context, WidgetRef ref) { | ||
| final collection = ref.watch(collectionStateNotifierProvider); | ||
| final requestSequence = ref.watch(requestSequenceProvider); | ||
| final selectedId = ref.watch(selectedIdStateProvider); | ||
| final visibleTabs = ref.watch(visibleTabsProvider); | ||
|
|
||
| // Prevents rendering if data isn’t ready | ||
| if (collection == null || requestSequence.isEmpty) { | ||
| return const SizedBox.shrink(); | ||
| } | ||
|
|
||
| return Container( | ||
| color: Theme.of(context).colorScheme.surfaceContainerLowest, | ||
| padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), | ||
| child: SingleChildScrollView( // horizontal scrolling for the tab bar | ||
| scrollDirection: Axis.horizontal, | ||
| child: ConstrainedBox( | ||
| constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width), | ||
| child: Row( | ||
| mainAxisAlignment: MainAxisAlignment.start, | ||
| // Filters and maps only visible tabs for rendering | ||
| children: requestSequence | ||
| .where((id) => visibleTabs.contains(id)) | ||
| .map((id) { | ||
| final request = collection[id]!; | ||
| final name = request.name.isNotEmpty | ||
| ? request.name | ||
| : getRequestTitleFromUrl(request.httpRequestModel?.url) ?? 'Untitled'; | ||
|
|
||
| return TabRequestCard( | ||
| apiType: request.apiType, | ||
| method: request.httpRequestModel!.method, | ||
| name: name, | ||
| isSelected: selectedId == id, | ||
| onTap: () => ref.read(selectedIdStateProvider.notifier).state = id, | ||
| // Manages tab closure and selection adjustment | ||
| onClose: () { | ||
| ref.read(visibleTabsProvider.notifier).toggleVisibility(id); | ||
| if (selectedId == id) { | ||
| final remainingTabs = requestSequence.where((tabId) => visibleTabs.contains(tabId) && tabId != id).toList(); | ||
| if (remainingTabs.isNotEmpty) { | ||
| ref.read(selectedIdStateProvider.notifier).state = remainingTabs.first; | ||
| } else { | ||
| ref.read(selectedIdStateProvider.notifier).state = null; | ||
| } | ||
| } | ||
| }, | ||
| ); | ||
| }) | ||
| .toList(), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
lib/widgets/logo_apidash.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class LogoApidash extends StatelessWidget { | ||
| const LogoApidash({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Center( | ||
| child: Opacity( | ||
| opacity: 0.1, | ||
| child: const FlutterLogo( | ||
| size: 400, | ||
| ), | ||
| // TODO: Replace FlutterLogo with apidash_logo | ||
| // child: Image.asset( | ||
| // 'assets/apidash_logo.png', | ||
| // width: X, | ||
| // height: X, | ||
| // ), | ||
| // OR use SVG: | ||
| // child: SvgPicture.asset( | ||
| // 'assets/apidash_logo.svg', | ||
| // width: X, | ||
| // height: X, | ||
| // ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.