router.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import 'package:app_flowy/startup/startup.dart';
  2. import 'package:app_flowy/user/application/auth_service.dart';
  3. import 'package:app_flowy/user/presentation/sign_in_screen.dart';
  4. import 'package:app_flowy/user/presentation/sign_up_screen.dart';
  5. import 'package:app_flowy/user/presentation/skip_log_in_screen.dart';
  6. import 'package:app_flowy/user/presentation/welcome_screen.dart';
  7. import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
  8. import 'package:flowy_infra/time/duration.dart';
  9. import 'package:flowy_infra_ui/widget/route/animation.dart';
  10. import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;
  11. import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
  12. import 'package:flutter/material.dart';
  13. class AuthRouter {
  14. void pushForgetPasswordScreen(BuildContext context) {
  15. // TODO: implement showForgetPasswordScreen
  16. }
  17. void pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) {
  18. getIt<SplashRoute>().pushWelcomeScreen(context, userProfile);
  19. }
  20. void pushSignUpScreen(BuildContext context) {
  21. Navigator.of(context).push(
  22. PageRoutes.fade(
  23. () => SignUpScreen(router: getIt<AuthRouter>()),
  24. ),
  25. );
  26. }
  27. void pushHomeScreen(BuildContext context, UserProfilePB profile, CurrentWorkspaceSettingPB workspaceSetting) {
  28. Navigator.push(
  29. context,
  30. PageRoutes.fade(() => HomeScreen(profile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),
  31. );
  32. }
  33. }
  34. class SplashRoute {
  35. Future<void> pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) async {
  36. final screen = WelcomeScreen(userProfile: userProfile);
  37. final workspaceId = await Navigator.of(context).push(
  38. PageRoutes.fade(
  39. () => screen,
  40. RouteDurations.slow.inMilliseconds * .001,
  41. ),
  42. );
  43. pushHomeScreen(context, userProfile, workspaceId);
  44. }
  45. void pushHomeScreen(BuildContext context, UserProfilePB userProfile, CurrentWorkspaceSettingPB workspaceSetting) {
  46. Navigator.push(
  47. context,
  48. PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting), RouteDurations.slow.inMilliseconds * .001),
  49. );
  50. }
  51. void pushSignInScreen(BuildContext context) {
  52. Navigator.push(
  53. context,
  54. PageRoutes.fade(() => SignInScreen(router: getIt<AuthRouter>()), RouteDurations.slow.inMilliseconds * .001),
  55. );
  56. }
  57. void pushSkipLoginScreen(BuildContext context) {
  58. Navigator.push(
  59. context,
  60. PageRoutes.fade(
  61. () => SkipLogInScreen(
  62. router: getIt<AuthRouter>(),
  63. authService: getIt<AuthService>(),
  64. ),
  65. RouteDurations.slow.inMilliseconds * .001),
  66. );
  67. }
  68. }