Skip to content

Commit

Permalink
Merge pull request #314 from woltapp/select-bottom-nav-bar-on-browser…
Browse files Browse the repository at this point in the history
…-address-bar

[Coffee Maker App] Update bottom nav bar tab from the browser address bar
  • Loading branch information
ulusoyca authored Aug 25, 2024
2 parents ab8ae51 + 4d9177a commit 90cf214
Show file tree
Hide file tree
Showing 20 changed files with 657 additions and 369 deletions.
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

0 comments on commit 90cf214

Please sign in to comment.