Skip to content
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

[Coffee Maker App] Update bottom nav bar tab from the browser address bar #314

Merged
merged 1 commit into from
Aug 25, 2024
Merged
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
1 change: 0 additions & 1 deletion coffee_maker/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:coffee_maker/entities/grouped_coffee_orders.dart';
import 'package:coffee_maker/entities/mock_coffee_orders.dart';
import 'package:coffee_maker/home/home_screen.dart';
import 'package:demo_ui_components/demo_ui_components.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
import 'package:coffee_maker_navigator_2/app/router/entities/app_route_path.dart';
import 'package:coffee_maker_navigator_2/app/router/entities/app_route_uri_template.dart';

/// This class provides a structured way to manage and represent the current navigation state,
/// including both the route and any relevant parameters.
///
/// [AppRouteConfiguration] represents the configuration of a specific route in the application,
/// holding both the static structure of the route as defined by the [AppRouteUriTemplate] and
/// the dynamic aspects such as query parameters.
///
/// In the context of Flutter's Navigator 2.0, this configuration is essential for translating
/// between the application's navigation state and the URL displayed in the browser. It enables
/// deep linking, dynamic navigation, and synchronization between the app's state and the browser URL.
///
/// **Components:**
/// - [appRouteUriTemplate]: A value from the [AppRouteUriTemplate] enum, representing the static
/// template of the route. It defines the modal or screen that should be navigated to based
/// on the URI path.
/// - [queryParams]: A map of query parameters, allowing additional dynamic information to be passed
/// with the route (e.g., selected tab, order id, etc.). This supports more complex navigation
/// patterns and enables passing state information directly through the URL.
///
/// **Usage:**
/// - **URL Generation:** The `toUri()` method converts the route configuration into a full URI,
/// combining the path from [AppRouteUriTemplate] with the actual query parameter values. This URI
/// is used to update the browser's address bar, ensuring that the visible URL reflects the current
/// state of the application.
/// - **Consistency with Defined Routes:** By utilizing [AppRouteUriTemplate], this class ensures that
/// all route configurations are consistent with the predefined route templates, making navigation
/// predictable and easier to manage.
class AppRouteConfiguration {
final AppRoutePath appRoutePath;
final Map<String, String> queryParams;

static const queryParamId = 'id';
final AppRouteUriTemplate appRouteUriTemplate;
final QueryParams queryParams;

const AppRouteConfiguration({
required this.appRoutePath,
required this.appRouteUriTemplate,
this.queryParams = const {},
});

Uri toUri() => Uri(path: appRoutePath.path, queryParameters: queryParams);
/// Converts the route configuration to a URI, combining the path name from the template
/// and any provided query parameters. This is used for generating URLs that reflect
/// the application's current state, aiding in deep linking and navigation state management.
Uri toUri() =>
Uri(path: appRouteUriTemplate.path, queryParameters: queryParams);
}

typedef QueryParams = Map<String, String>;
Loading
Loading