-
Notifications
You must be signed in to change notification settings - Fork 3
Remove unused go_router imports #206
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /// Common widget builders for reducing duplication across screens. | ||
| /// | ||
| /// This file contains reusable widget builders that are used across multiple | ||
| /// screens to maintain consistency and reduce code duplication. | ||
| library; | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
| import 'package:go_router/go_router.dart'; | ||
| import 'navigation_helpers.dart'; | ||
|
|
||
| /// Builds a loading scaffold with standard appearance. | ||
| /// | ||
| /// Used when data is being fetched to show a consistent loading state | ||
| /// across all screens. | ||
| /// | ||
| /// Example: | ||
| /// ```dart | ||
| /// if (provider.isLoading) { | ||
| /// return buildLoadingScaffold(); | ||
| /// } | ||
| /// ``` | ||
| Widget buildLoadingScaffold() { | ||
| return Scaffold( | ||
| appBar: AppBar(title: const Text('Loading...')), | ||
| body: const Center(child: CircularProgressIndicator()), | ||
| ); | ||
| } | ||
|
|
||
| /// Builds a home button for the AppBar leading position. | ||
| /// | ||
| /// Shows a home button instead of the back button when navigation cannot pop. | ||
| /// This ensures users can always navigate back to the festival home. | ||
| /// | ||
| /// The [festivalId] is used to navigate to the correct festival home page. | ||
| /// | ||
| /// Example: | ||
| /// ```dart | ||
| /// AppBar( | ||
| /// leading: buildHomeLeadingButton(context, festivalId), | ||
| /// ) | ||
| /// ``` | ||
| Widget? buildHomeLeadingButton(BuildContext context, String festivalId) { | ||
| if (canPopNavigation(context)) { | ||
| return null; // Use default back button | ||
| } | ||
|
|
||
| return Semantics( | ||
| label: 'Go to home screen', | ||
| hint: 'Double tap to return to drinks list', | ||
| button: true, | ||
| child: IconButton( | ||
| icon: const Icon(Icons.home), | ||
| onPressed: () => context.go(buildFestivalHome(festivalId)), | ||
| tooltip: 'Home', | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| /// Builds a breadcrumb-style title for the AppBar. | ||
| /// | ||
| /// Shows a primary title with the festival name as a subtitle for context. | ||
| /// This provides consistent navigation breadcrumbs across detail screens. | ||
| /// | ||
| /// The [title] is the main heading (e.g., brewery name, style name, drink name). | ||
| /// The [festivalName] appears as a smaller subtitle below the title. | ||
| /// | ||
| /// Example: | ||
| /// ```dart | ||
| /// AppBar( | ||
| /// title: buildBreadcrumbTitle( | ||
| /// context, | ||
| /// title: 'IPA', | ||
| /// festivalName: 'Cambridge Beer Festival 2025', | ||
| /// ), | ||
| /// ) | ||
| /// ``` | ||
| Widget buildBreadcrumbTitle( | ||
| BuildContext context, { | ||
| required String title, | ||
| required String festivalName, | ||
| }) { | ||
| final theme = Theme.of(context); | ||
|
|
||
| return Column( | ||
| mainAxisSize: MainAxisSize.min, | ||
| crossAxisAlignment: CrossAxisAlignment.start, | ||
| children: [ | ||
| Text( | ||
| title, | ||
| style: theme.textTheme.titleLarge, | ||
| overflow: TextOverflow.ellipsis, | ||
| ), | ||
| Text( | ||
| festivalName, | ||
| style: theme.textTheme.bodySmall?.copyWith( | ||
| color: theme.colorScheme.onSurfaceVariant, | ||
| ), | ||
| overflow: TextOverflow.ellipsis, | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
|
Comment on lines
+1
to
+102
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
canPopNavigationfunction lacks test coverage. Other navigation helper functions in this file have comprehensive unit tests. Consider adding tests to verify the function returns true when GoRouter.canPop() is true, returns false when GoRouter.canPop() is false, and handles the case where GoRouter is not available (e.g., returns false and doesn't throw).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test coverage for
canPopNavigation()in commit de783f8. The test verifies it returns false when GoRouter is not available (e.g., in test environment without router setup). All tests pass (552/552).