Skip to content

Commit

Permalink
Merge pull request #312 from woltapp/coffee-maker-add-browser-address…
Browse files Browse the repository at this point in the history
…-bar-support-for-navigation

[Coffee Maker App]  Add Web support for app navigation (Update browser address bar)
  • Loading branch information
ulusoyca authored Aug 22, 2024
2 parents ac17031 + 7beca82 commit ab8ae51
Show file tree
Hide file tree
Showing 26 changed files with 759 additions and 335 deletions.
7 changes: 1 addition & 6 deletions coffee_maker/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ class _DemoAppState extends State<DemoApp> {

@override
Widget build(BuildContext context) {
return CupertinoApp(
// This is needed to make the app working with CupertinoApp.
// For more details on CupertinoApp support, see the "CupertinoApp Support" section in the README file.
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
DefaultMaterialLocalizations.delegate,
],
return MaterialApp(
scrollBehavior: const CustomScrollBehavior(),
debugShowCheckedModeBanner: false,
home: Theme(
Expand Down
2 changes: 2 additions & 0 deletions coffee_maker_navigator_2/lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class CoffeeMakerApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
theme: AppThemeData.themeData(context),
routerDelegate: appLevelDependencyContainer.appRouterDelegate,
routeInformationParser:
appLevelDependencyContainer.appRouteInformationParser,
backButtonDispatcher:
appLevelDependencyContainer.backButtonDispatcher,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:coffee_maker_navigator_2/app/app_lifecycle/domain/app_lifecyle_s
import 'package:coffee_maker_navigator_2/app/auth/data/local/auth_local_data_source.dart';
import 'package:coffee_maker_navigator_2/app/auth/data/repository/auth_repository.dart';
import 'package:coffee_maker_navigator_2/app/auth/domain/auth_service.dart';
import 'package:coffee_maker_navigator_2/app/router/view/app_route_information_parser.dart';
import 'package:coffee_maker_navigator_2/features/onboarding/data/local/onboarding_local_data_source.dart';
import 'package:coffee_maker_navigator_2/features/onboarding/data/repository/onboarding_repository.dart';
import 'package:coffee_maker_navigator_2/features/onboarding/domain/onboarding_service.dart';
Expand All @@ -28,10 +29,13 @@ class CoffeeMakerAppLevelDependencyContainer
late final _appLifeCycleService = _createAppLifeCycleService();

late final _appRouterDelegate = _createAppRouterDelegate();
late final _appRouteInformationParser = _createAppRouteInformationParser();
late final _backButtonDispatcher = _createRootBackButtonDispatcher();
late final _routerViewModel = _createRouterViewModel();

AppRouterDelegate get appRouterDelegate => _appRouterDelegate;
AppRouteInformationParser get appRouteInformationParser =>
_appRouteInformationParser;
BackButtonDispatcher get backButtonDispatcher => _backButtonDispatcher;
RouterViewModel get routerViewModel => _routerViewModel;
AuthService get authService => _authService;
Expand Down Expand Up @@ -69,7 +73,11 @@ class CoffeeMakerAppLevelDependencyContainer
}

AppRouterDelegate _createAppRouterDelegate() {
return AppRouterDelegate();
return AppRouterDelegate(routerViewModel);
}

AppRouteInformationParser _createAppRouteInformationParser() {
return const AppRouteInformationParser();
}

RootBackButtonDispatcher _createRootBackButtonDispatcher() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:coffee_maker_navigator_2/app/router/entities/app_route_page.dart';
import 'package:coffee_maker_navigator_2/features/orders/domain/entities/coffee_maker_step.dart';
import 'package:equatable/equatable.dart';

class AppNavigationStack extends Equatable {
final List<AppRoutePage> pages;

const AppNavigationStack({required this.pages});

@override
List<Object?> get props => [pages];

AppRoutePage get lastPage => pages.last;

factory AppNavigationStack.bootstrapStack() {
return const AppNavigationStack(
pages: [BootstrapRoutePage()],
);
}

factory AppNavigationStack.ordersStack({
CoffeeMakerStep? step,
String? coffeeOrderId,
bool shouldShowOnboardingModal = false,
}) {
return AppNavigationStack(
pages: [
const OrdersRoutePage(),
if (shouldShowOnboardingModal) const OnboardingModalRoutePage(),
if (step == CoffeeMakerStep.grind && coffeeOrderId != null)
GrindCoffeeModalRoutePage(
coffeeOrderId: coffeeOrderId,
),
if (step == CoffeeMakerStep.addWater && coffeeOrderId != null)
AddWaterRoutePage(coffeeOrderId),
if (step == CoffeeMakerStep.ready && coffeeOrderId != null)
ReadyCoffeeModalRoutePage(
coffeeOrderId: coffeeOrderId,
),
],
);
}

factory AppNavigationStack.loginStack() {
return const AppNavigationStack(
pages: [LoginRoutePage()],
);
}

factory AppNavigationStack.tutorialsStack([CoffeeMakerStep? step]) {
return AppNavigationStack(
pages: [
const OrdersRoutePage(),
const TutorialsRoutePage(),
if (step != null) SingleTutorialRoutePage(step),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:coffee_maker_navigator_2/app/router/entities/app_route_path.dart';

class AppRouteConfiguration {
final AppRoutePath appRoutePath;
final Map<String, String> queryParams;

static const queryParamId = 'id';

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

Uri toUri() => Uri(path: appRoutePath.path, queryParameters: queryParams);
}
Loading

0 comments on commit ab8ae51

Please sign in to comment.