2021-09-06 16:18:34 +08:00
|
|
|
import 'package:app_flowy/startup/startup.dart';
|
2022-03-01 10:22:28 -05:00
|
|
|
import 'package:app_flowy/user/application/auth_service.dart';
|
2022-01-31 08:24:29 +08:00
|
|
|
import 'package:app_flowy/user/presentation/sign_in_screen.dart';
|
2021-09-06 16:18:34 +08:00
|
|
|
import 'package:app_flowy/user/presentation/sign_up_screen.dart';
|
2022-01-31 08:24:29 +08:00
|
|
|
import 'package:app_flowy/user/presentation/skip_log_in_screen.dart';
|
|
|
|
import 'package:app_flowy/user/presentation/welcome_screen.dart';
|
2021-11-08 19:19:02 +08:00
|
|
|
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
|
|
|
import 'package:flowy_infra/time/duration.dart';
|
2021-07-25 22:09:52 +08:00
|
|
|
import 'package:flowy_infra_ui/widget/route/animation.dart';
|
2022-07-19 14:40:56 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show UserProfilePB;
|
2022-07-04 15:00:54 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-folder/protobuf.dart';
|
2021-07-25 18:04:16 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2021-07-13 13:14:49 +08:00
|
|
|
|
2022-01-31 08:15:49 +08:00
|
|
|
class AuthRouter {
|
2022-11-09 11:07:29 +08:00
|
|
|
void pushForgetPasswordScreen(BuildContext context) {}
|
2021-07-25 18:04:16 +08:00
|
|
|
|
2022-07-19 14:40:56 +08:00
|
|
|
void pushWelcomeScreen(BuildContext context, UserProfilePB userProfile) {
|
2022-01-31 08:24:29 +08:00
|
|
|
getIt<SplashRoute>().pushWelcomeScreen(context, userProfile);
|
2021-07-25 18:04:16 +08:00
|
|
|
}
|
|
|
|
|
2021-09-06 16:18:34 +08:00
|
|
|
void pushSignUpScreen(BuildContext context) {
|
2021-09-05 22:52:20 +08:00
|
|
|
Navigator.of(context).push(
|
|
|
|
PageRoutes.fade(
|
2022-01-31 08:15:49 +08:00
|
|
|
() => SignUpScreen(router: getIt<AuthRouter>()),
|
2021-09-05 22:52:20 +08:00
|
|
|
),
|
|
|
|
);
|
2021-07-25 18:04:16 +08:00
|
|
|
}
|
2021-11-08 19:19:02 +08:00
|
|
|
|
2022-08-31 09:28:08 +08:00
|
|
|
void pushHomeScreen(BuildContext context, UserProfilePB profile,
|
2022-10-26 10:38:57 +08:00
|
|
|
WorkspaceSettingPB workspaceSetting) {
|
2021-11-08 19:19:02 +08:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
2022-08-31 09:28:08 +08:00
|
|
|
PageRoutes.fade(() => HomeScreen(profile, workspaceSetting),
|
|
|
|
RouteDurations.slow.inMilliseconds * .001),
|
2021-11-08 19:19:02 +08:00
|
|
|
);
|
|
|
|
}
|
2021-07-25 18:04:16 +08:00
|
|
|
}
|
2022-01-31 08:24:29 +08:00
|
|
|
|
|
|
|
class SplashRoute {
|
2022-08-31 09:28:08 +08:00
|
|
|
Future<void> pushWelcomeScreen(
|
|
|
|
BuildContext context, UserProfilePB userProfile) async {
|
2022-02-28 23:37:41 -05:00
|
|
|
final screen = WelcomeScreen(userProfile: userProfile);
|
2022-01-31 08:24:29 +08:00
|
|
|
final workspaceId = await Navigator.of(context).push(
|
|
|
|
PageRoutes.fade(
|
|
|
|
() => screen,
|
|
|
|
RouteDurations.slow.inMilliseconds * .001,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2022-08-31 09:28:08 +08:00
|
|
|
// ignore: use_build_context_synchronously
|
2022-02-28 23:37:41 -05:00
|
|
|
pushHomeScreen(context, userProfile, workspaceId);
|
2022-01-31 08:24:29 +08:00
|
|
|
}
|
|
|
|
|
2022-08-31 09:28:08 +08:00
|
|
|
void pushHomeScreen(BuildContext context, UserProfilePB userProfile,
|
2022-10-26 10:38:57 +08:00
|
|
|
WorkspaceSettingPB workspaceSetting) {
|
2022-01-31 08:24:29 +08:00
|
|
|
Navigator.push(
|
|
|
|
context,
|
2022-08-31 09:28:08 +08:00
|
|
|
PageRoutes.fade(() => HomeScreen(userProfile, workspaceSetting),
|
|
|
|
RouteDurations.slow.inMilliseconds * .001),
|
2022-01-31 08:24:29 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pushSignInScreen(BuildContext context) {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
2022-08-31 09:28:08 +08:00
|
|
|
PageRoutes.fade(() => SignInScreen(router: getIt<AuthRouter>()),
|
|
|
|
RouteDurations.slow.inMilliseconds * .001),
|
2022-01-31 08:24:29 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pushSkipLoginScreen(BuildContext context) {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
PageRoutes.fade(
|
|
|
|
() => SkipLogInScreen(
|
|
|
|
router: getIt<AuthRouter>(),
|
2022-03-01 10:22:28 -05:00
|
|
|
authService: getIt<AuthService>(),
|
2022-01-31 08:24:29 +08:00
|
|
|
),
|
|
|
|
RouteDurations.slow.inMilliseconds * .001),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|