fix
This commit is contained in:
@@ -260,8 +260,11 @@ class AppRouter {
|
||||
type: MaterialType.transparency,
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
PaymentMethodSheetBloc(getIt<GetPaymentCardsUsecase>(),
|
||||
getIt<SetMainPaymentCardUsecase>()),
|
||||
PaymentMethodSheetBloc(
|
||||
getIt<GetPaymentCardsUsecase>(),
|
||||
getIt<SetMainPaymentCardUsecase>(),
|
||||
getIt<GetProfileUseCase>(),
|
||||
),
|
||||
child: PaymentMethodSheet(),
|
||||
),
|
||||
),
|
||||
@@ -323,10 +326,16 @@ class AppRouter {
|
||||
GoRoute(
|
||||
path: 'scooter/:id',
|
||||
builder: (context, state) {
|
||||
String address = state.extra as String;
|
||||
List<dynamic> extras = [];
|
||||
if (state.extra != null) {
|
||||
extras = state.extra as List<dynamic>;
|
||||
}
|
||||
String address = extras[0];
|
||||
double distance = extras[1];
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => getIt<ScooterDetailBloc>(),
|
||||
child: ScooterDetailScreen(address: address),
|
||||
child: ScooterDetailScreen(address: address, distance: distance),
|
||||
);
|
||||
}
|
||||
),
|
||||
@@ -444,19 +453,21 @@ class AppRouter {
|
||||
),
|
||||
GoRoute(
|
||||
path: 'payment-methods',
|
||||
builder: (context, state) =>
|
||||
BlocProvider(
|
||||
create: (context) =>
|
||||
PaymentMethodsBloc(
|
||||
getIt<GetPaymentCardsUsecase>(),
|
||||
getIt<RemovePaymentCardUsecase>(),
|
||||
getIt<SetMainPaymentCardUsecase>(),
|
||||
getIt<GetProfileUseCase>(),
|
||||
getIt<AddPaymentCardUsecase>(),
|
||||
)
|
||||
..add(PaymentMethodsStarted()),
|
||||
child: PaymentMethodsScreen(),
|
||||
),
|
||||
builder: (context, state) {
|
||||
final refreshId = state.uri.queryParameters['refreshId'];
|
||||
|
||||
return BlocProvider(
|
||||
key: refreshId != null ? ValueKey(refreshId) : null,
|
||||
create: (context) => PaymentMethodsBloc(
|
||||
getIt<GetPaymentCardsUsecase>(),
|
||||
getIt<RemovePaymentCardUsecase>(),
|
||||
getIt<SetMainPaymentCardUsecase>(),
|
||||
getIt<GetProfileUseCase>(),
|
||||
getIt<AddPaymentCardUsecase>(),
|
||||
)..add(PaymentMethodsStarted()),
|
||||
child: const PaymentMethodsScreen(),
|
||||
);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'add-card',
|
||||
@@ -480,6 +491,28 @@ class AppRouter {
|
||||
..add(LoadTopUpData()),
|
||||
child: TopUpScreen(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'result/:status',
|
||||
builder: (context, state) {
|
||||
final modeParam = state.pathParameters['status'];
|
||||
|
||||
CardBindingStatus status = CardBindingStatus.success;
|
||||
String title = 'Успешно!';
|
||||
|
||||
if (modeParam == 'failed') {
|
||||
status = CardBindingStatus.failed;
|
||||
title = 'Извините, что-то\nпошло не так';
|
||||
}
|
||||
|
||||
return CardBindingResultScreen(
|
||||
status: status,
|
||||
title: title,
|
||||
cardImagePath: 'assets/icons/card_result_screen.png',
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -524,45 +557,59 @@ class AppRouter {
|
||||
print(splashBloc.state);
|
||||
print(state.uri.toString());
|
||||
|
||||
if (authState is AuthInitial && currentLocation != '/splash') {
|
||||
print("splash");
|
||||
return '/splash';
|
||||
if (authState is AuthInitial) {
|
||||
if (currentLocation != '/splash') return '/splash';
|
||||
return null;
|
||||
}
|
||||
|
||||
if (authState is AuthFirstLaunch &&
|
||||
currentLocation != '/login' &&
|
||||
currentLocation != '/privacy-policy' &&
|
||||
currentLocation != '/license-agreement') {
|
||||
print("login");
|
||||
return '/login';
|
||||
// 2. Первый запуск или пользователь не авторизован
|
||||
if (authState is AuthFirstLaunch || authState is AuthUnauthenticated) {
|
||||
final isAllowed = currentLocation == '/login' ||
|
||||
currentLocation.startsWith('/verify') ||
|
||||
currentLocation == '/privacy-policy' ||
|
||||
currentLocation == '/license-agreement';
|
||||
|
||||
if (!isAllowed) return '/login';
|
||||
return null;
|
||||
}
|
||||
|
||||
if (authState is AuthUnauthenticated &&
|
||||
currentLocation != '/login' &&
|
||||
currentLocation != '/privacy-policy' &&
|
||||
currentLocation != '/license-agreement') {
|
||||
print("login2");
|
||||
return '/login';
|
||||
// 3. Авторизация в процессе (переход от ввода телефона/SMS к PIN-коду)
|
||||
if (authState is AuthInProgress) {
|
||||
final isAllowed = currentLocation == '/login' ||
|
||||
currentLocation.startsWith('/verify') ||
|
||||
currentLocation == '/pin' || // ← Теперь роутер пустит сюда!
|
||||
currentLocation == '/privacy-policy' ||
|
||||
currentLocation == '/license-agreement';
|
||||
|
||||
if (!isAllowed) return '/login';
|
||||
return null;
|
||||
}
|
||||
|
||||
// 4. Пользователь авторизован, но PIN еще не проверен
|
||||
if (authState is AuthAuthenticated) {
|
||||
final isComingFromStart =
|
||||
currentLocation == '/splash' ||
|
||||
currentLocation == '/login' ||
|
||||
currentLocation == '/phone';
|
||||
final isComingFromStart = currentLocation == '/splash' ||
|
||||
currentLocation == '/login' ||
|
||||
currentLocation.startsWith('/verify') ||
|
||||
currentLocation == '/phone';
|
||||
|
||||
if (isComingFromStart) {
|
||||
print("redirecting to pin check");
|
||||
return '/pin';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 5. Пользователь полностью авторизован и PIN успешно верифицирован
|
||||
if (authState is AuthPinVerified) {
|
||||
if (currentLocation == '/splash' ||
|
||||
final isComingFromAuth = currentLocation == '/splash' ||
|
||||
currentLocation == '/login' ||
|
||||
currentLocation == '/pin') {
|
||||
currentLocation.startsWith('/verify') ||
|
||||
currentLocation == '/pin';
|
||||
|
||||
if (isComingFromAuth) {
|
||||
return '/home';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user