69 lines
2.1 KiB
Dart
69 lines
2.1 KiB
Dart
import 'package:didvan/config/design_config.dart';
|
|
import 'package:didvan/pages/authentication/authentication.dart';
|
|
import 'package:didvan/pages/authentication/authentication_state.dart';
|
|
import 'package:didvan/pages/home/home.dart';
|
|
import 'package:didvan/pages/home/home_state.dart';
|
|
import 'package:didvan/pages/home/profile/edit_profile/edit_profile.dart';
|
|
import 'package:didvan/pages/splash/splash.dart';
|
|
import 'package:didvan/pages/splash/splash_state.dart';
|
|
import 'package:didvan/routes/routes.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class RouteGenerator {
|
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
|
switch (settings.name) {
|
|
case Routes.splash:
|
|
return _createRoute(
|
|
ChangeNotifierProvider<SplashState>(
|
|
create: (context) => SplashState(),
|
|
child: const Splash(),
|
|
),
|
|
);
|
|
case Routes.authenticaion:
|
|
return _createRoute(
|
|
ChangeNotifierProvider<AuthenticationState>(
|
|
create: (context) => AuthenticationState(),
|
|
child: const Authentication(),
|
|
),
|
|
);
|
|
case Routes.home:
|
|
return _createRoute(
|
|
ChangeNotifierProvider<HomeState>(
|
|
create: (context) => HomeState(),
|
|
child: const Home(),
|
|
),
|
|
);
|
|
case Routes.editProfile:
|
|
return _createRoute(
|
|
const EditProfile(),
|
|
);
|
|
default:
|
|
return _errorRoute();
|
|
}
|
|
}
|
|
|
|
static Route<dynamic> _errorRoute() {
|
|
return MaterialPageRoute(builder: (_) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Error'),
|
|
),
|
|
body: const Center(
|
|
child: Text('ERROR'),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
static Route _createRoute(page) {
|
|
return PageRouteBuilder(
|
|
pageBuilder: (context, animation, secondaryAnimation) => page,
|
|
transitionDuration: DesignConfig.mediumAnimationDuration,
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
return FadeTransition(opacity: animation, child: child);
|
|
},
|
|
);
|
|
}
|
|
}
|