From 5ba9c15dd25448975cd41ddfc358e65db812be16 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Mon, 15 Apr 2024 15:14:15 +0300 Subject: [PATCH] feat(app): Auth token is now saved after app close --- .../diary/diary_edit_screen/diary_edit_screen.dart | 2 +- .../profile/my_profile_screen/bloc/my_profile_bloc.dart | 6 ++++++ .../registration/splash_screen/bloc/splash_bloc.dart | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart index d03631be..6f37061c 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -13,7 +13,7 @@ import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart'; import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/widgets/custom_scale_element.dart'; -import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; +//import 'package:eatvio_app/widgets/custom_bottom_bar.dart'; import 'package:carousel_slider/carousel_slider.dart'; // ignore: must_be_immutable diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart index 8aac9e06..95f3227a 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import '/core/app_export.dart'; @@ -23,6 +24,11 @@ class MyProfileBloc extends Bloc { try { final box = await Hive.openBox('token'); final token = box.get('token'); + if (token == null) { + NavigatorService.popAndPushNamed( + AppRoutes.authScreen, + ); // Если токен есть, запускаем приложение + } //final token = // "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a"; final response = await http.get( diff --git a/lib/presentation/registration/splash_screen/bloc/splash_bloc.dart b/lib/presentation/registration/splash_screen/bloc/splash_bloc.dart index a767f763..9491b451 100644 --- a/lib/presentation/registration/splash_screen/bloc/splash_bloc.dart +++ b/lib/presentation/registration/splash_screen/bloc/splash_bloc.dart @@ -17,7 +17,7 @@ class SplashBloc extends Bloc { ) async { Future.delayed(const Duration(milliseconds: 3000), () { NavigatorService.popAndPushNamed( - AppRoutes.authScreen, + AppRoutes.myProfile, ); }); }