forked from eatvio/eatvio_app
go router 2
This commit is contained in:
@@ -12,12 +12,16 @@ import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_sc
|
||||
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart';
|
||||
import 'package:eatvio_app/widgets/bottom_navigation_bar_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
|
||||
class AppRouter {
|
||||
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
static GoRouter appRouter = GoRouter(
|
||||
initialLocation: '/auth-screen',
|
||||
navigatorKey: navigatorKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/auth-screen',
|
||||
|
||||
@@ -143,33 +143,23 @@ class AuthScreen extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
onTapOk(BuildContext context) {
|
||||
return () {
|
||||
Navigator.pop(context);
|
||||
};
|
||||
}
|
||||
onTapOk(BuildContext context) => GoRouter.of(context).pop(context);
|
||||
|
||||
onTapDiaryTest(BuildContext context) {
|
||||
return () {
|
||||
Navigator.pushNamed(context, AppRoutes.diaryEdit);
|
||||
};
|
||||
}
|
||||
onTapDiaryTest(BuildContext context) => GoRouter.of(context).goNamed('diaryScreen');
|
||||
|
||||
onTapProfileTest(BuildContext context) {
|
||||
return () {
|
||||
Navigator.pushNamed(context, AppRoutes.mySettings);
|
||||
};
|
||||
}
|
||||
onTapProfileTest(BuildContext context) => GoRouter.of(context).goNamed('mySettingsScreen');
|
||||
|
||||
onTapNoAccount(BuildContext context) {
|
||||
return () {
|
||||
GoRouter.of(context).goNamed('languageSelectScreen');
|
||||
};
|
||||
}
|
||||
onTapNoAccount(BuildContext context) => GoRouter.of(context).goNamed('languageSelectScreen');
|
||||
|
||||
/// Section Widget
|
||||
_buildAppBar(BuildContext context) {
|
||||
return CustomAppBar(leadingWidth: 29.h, centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio));
|
||||
return CustomAppBar(
|
||||
leadingWidth: 29.h,
|
||||
centerTitle: true,
|
||||
title: AppbarTitleImage(
|
||||
imagePath: ImageConstant.imgLogoEatvio,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<String> validateFields(String email, String password) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
@@ -24,9 +25,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? chatID = state.chatModelObj?.chatID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -47,9 +47,7 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/index'),
|
||||
|
||||
@@ -28,23 +28,23 @@ class ChatEntryWidget extends StatelessWidget {
|
||||
borderRadius: BorderRadiusStyle.circleBorder8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!,
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!,
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
/*CustomImageView(
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
),
|
||||
/*CustomImageView(
|
||||
imagePath:
|
||||
dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!,
|
||||
height: 60.adaptSize,
|
||||
@@ -53,57 +53,55 @@ class ChatEntryWidget extends StatelessWidget {
|
||||
30.h,
|
||||
),
|
||||
),*/
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12.h,
|
||||
top: 2.v,
|
||||
bottom: 11.v,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 227.h,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
chatEntryObj.username!.length <= 15
|
||||
? chatEntryObj.username!
|
||||
: chatEntryObj.username!.substring(0, 15) +
|
||||
'...',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
Spacer(),
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imageNotFound,
|
||||
height: 9.v,
|
||||
width: 16.h,
|
||||
margin: EdgeInsets.only(
|
||||
top: 4.v,
|
||||
bottom: 6.v,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 6.h),
|
||||
child: Text(
|
||||
chatEntryObj.dateText!,
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6.v),
|
||||
Text(
|
||||
chatEntryObj.greetingText!,
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
)
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12.h,
|
||||
top: 2.v,
|
||||
bottom: 11.v,
|
||||
),
|
||||
)
|
||||
]),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 227.h,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
chatEntryObj.username!.length <= 15 ? chatEntryObj.username! : chatEntryObj.username!.substring(0, 15) + '...',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
Spacer(),
|
||||
CustomImageView(
|
||||
imagePath: ImageConstant.imageNotFound,
|
||||
height: 9.v,
|
||||
width: 16.h,
|
||||
margin: EdgeInsets.only(
|
||||
top: 4.v,
|
||||
bottom: 6.v,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 6.h),
|
||||
child: Text(
|
||||
chatEntryObj.dateText!,
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6.v),
|
||||
Text(
|
||||
chatEntryObj.greetingText!,
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_create_screen/models/diet_create_model.dart';
|
||||
|
||||
part 'diet_create_event.dart';
|
||||
part 'diet_create_state.dart';
|
||||
|
||||
@@ -25,9 +28,7 @@ class DietCreateBloc extends Bloc<DietCreateEvent, DietCreateState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
if (state is DietCreateLoadedState) {
|
||||
var currentState = state as DietCreateLoadedState;
|
||||
@@ -55,7 +56,7 @@ class DietCreateBloc extends Bloc<DietCreateEvent, DietCreateState> {
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
NavigatorService.pushNamed(AppRoutes.dietSelectScreen);
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('dietSelectScreen');
|
||||
} else {
|
||||
print(
|
||||
'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}');
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:eatvio_app/app_router.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/diets/diet_edit_screen/models/diet_edit_model.dart';
|
||||
|
||||
part 'diet_edit_event.dart';
|
||||
|
||||
part 'diet_edit_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a DietEdit according to the event that is dispatched to it.
|
||||
@@ -26,9 +30,7 @@ class DietEditBloc extends Bloc<DietEditEvent, DietEditState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
AppRouter.navigatorKey.currentContext?.goNamed('authScreen');
|
||||
}
|
||||
final String? dietID = state.dietModelObj?.dietID;
|
||||
final response = await http.get(
|
||||
@@ -74,15 +76,15 @@ class DietEditBloc extends Bloc<DietEditEvent, DietEditState> {
|
||||
var currentState = state as DietEditLoadedState;
|
||||
int duration = int.parse(currentState.duration!.text) * 7;
|
||||
print(duration);
|
||||
var response = await sendDiet(currentState.diet, currentState.name?.text,
|
||||
currentState.details?.text, duration.toString());
|
||||
var response = await sendDiet(currentState.diet, currentState.name?.text, currentState.details?.text, duration.toString());
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
NavigatorService.pushNamed(AppRoutes.dietScreen,
|
||||
arguments: currentState.diet?['id'].toString());
|
||||
AppRouter.navigatorKey.currentContext?.goNamed(
|
||||
'dietScreen',
|
||||
extra: currentState.diet?['id'].toString(),
|
||||
);
|
||||
} else {
|
||||
print(
|
||||
'Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
|
||||
print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ class DietSelectBloc extends Bloc<DietSelectEvent, DietSelectState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
); // Если токен есть, запускаем приложение
|
||||
// go to auth screen
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/diets/index'),
|
||||
|
||||
@@ -26,9 +26,7 @@ class DietBloc extends Bloc<DietEvent, DietState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? dietID = state.dietModelObj?.dietID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -26,9 +26,7 @@ class BlogPostCreateBloc
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
if (state is BlogPostCreateLoadedState) {
|
||||
var currentState = state as BlogPostCreateLoadedState;
|
||||
|
||||
@@ -26,9 +26,7 @@ class BlogPostEditBloc extends Bloc<BlogPostEditEvent, BlogPostEditState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? blog_postID = state.blog_postModelObj?.blog_postID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -29,9 +29,7 @@ class BlogPostBloc extends Bloc<BlogPostEvent, BlogPostState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? blog_postID = state.blog_postModelObj?.blog_postID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -28,9 +28,7 @@ class FeedBloc extends Bloc<FeedEvent, FeedState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
); // Если токен есть, запускаем приложение
|
||||
// go to auth screen
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/feed/index'),
|
||||
|
||||
@@ -26,9 +26,7 @@ class GlossaryBloc extends Bloc<GlossaryEvent, GlossaryState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final responseProductGroups = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/glossary/getProductGroups'),
|
||||
|
||||
@@ -25,9 +25,7 @@ class PlanCreateBloc extends Bloc<PlanCreateEvent, PlanCreateState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
if (state is PlanCreateLoadedState) {
|
||||
var currentState = state as PlanCreateLoadedState;
|
||||
|
||||
@@ -26,9 +26,7 @@ class PlanEditBloc extends Bloc<PlanEditEvent, PlanEditState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? planID = state.planModelObj?.planID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -28,9 +28,7 @@ class PlanSelectBloc extends Bloc<PlanSelectEvent, PlanSelectState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
); // Если токен есть, запускаем приложение
|
||||
// go to auth screen
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/plans/index'),
|
||||
|
||||
@@ -26,9 +26,7 @@ class PlanBloc extends Bloc<PlanEvent, PlanState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? planID = state.planModelObj?.planID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'bloc/my_profile_bloc.dart';
|
||||
import 'models/my_profile_model.dart';
|
||||
@@ -34,9 +34,10 @@ class MyProfileScreen extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
if (state is MyProfileInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is MyProfileLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
@@ -46,7 +47,11 @@ class MyProfileScreen extends StatelessWidget {
|
||||
return Center(child: Text(state.errorMessage));
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -55,8 +60,9 @@ class MyProfileScreen extends StatelessWidget {
|
||||
_buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
height: 0,
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
backgroundColor: Colors.grey[200],
|
||||
resizeToAvoidBottomInset: true,
|
||||
@@ -811,10 +817,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.myProfile,
|
||||
);
|
||||
GoRouter.of(context).go('/my-profile-screen');
|
||||
} else {
|
||||
// Ошибка от сервера
|
||||
print("Ошибка при отправке данных. Код ответа: ${response.statusCode}");
|
||||
@@ -903,10 +906,7 @@ class MyProfileScreen extends StatelessWidget {
|
||||
);
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.myProfile,
|
||||
);
|
||||
GoRouter.of(context).go('/my-profile-screen');
|
||||
} else {
|
||||
// Ошибка от сервера
|
||||
print("Ошибка при отправке данных. Код ответа: ${response.statusCode}");
|
||||
|
||||
@@ -24,16 +24,21 @@ class MySettingsScreen extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
if (state is MyProfileInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is MyProfileLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildSetingsScreen(context, state);
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -28,9 +28,7 @@ class RecipeCreateBloc extends Bloc<RecipeCreateEvent, RecipeCreateState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
if (state is RecipeCreateLoadedState) {
|
||||
var currentState = state as RecipeCreateLoadedState;
|
||||
|
||||
@@ -29,9 +29,7 @@ class RecipeEditBloc extends Bloc<RecipeEditEvent, RecipeEditState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -28,9 +28,7 @@ class RecipeSelectBloc extends Bloc<RecipeSelectEvent, RecipeSelectState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
); // Если токен есть, запускаем приложение
|
||||
// go to auth screen
|
||||
}
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipe/index'),
|
||||
|
||||
@@ -13,9 +13,7 @@ import 'package:flutter/material.dart';
|
||||
class RecipeSelectScreen extends StatelessWidget {
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<RecipeSelectBloc>(
|
||||
create: (context) => RecipeSelectBloc(
|
||||
RecipeSelectState(myProfileModelObj: RecipeSelectModel()))
|
||||
..add(RecipeSelectInitialEvent()),
|
||||
create: (context) => RecipeSelectBloc(RecipeSelectState(myProfileModelObj: RecipeSelectModel()))..add(RecipeSelectInitialEvent()),
|
||||
child: RecipeSelectScreen());
|
||||
}
|
||||
|
||||
@@ -23,17 +21,20 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
return BlocBuilder<RecipeSelectBloc, RecipeSelectState>(
|
||||
builder: (context, state) {
|
||||
if (state is RecipeSelectInitialState) {
|
||||
// Это начальное состояние, данные ещё не загружены.
|
||||
return CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
} else if (state is RecipeSelectLoadedState) {
|
||||
// Данные загружены, можно строить экран.
|
||||
return _buildRecipeScreen(context, state);
|
||||
} else {
|
||||
// Другие состояния, если они есть.
|
||||
return Container(); // Пустой контейнер для необработанных состояний.
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -75,8 +76,7 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
leadingWidth: 28.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, top: 15.v, bottom: 15.v),
|
||||
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () => GoRouter.of(context).pop(),
|
||||
),
|
||||
title: Padding(
|
||||
@@ -85,8 +85,7 @@ class RecipeSelectScreen extends StatelessWidget {
|
||||
children: [
|
||||
AppbarSubtitle(
|
||||
text: "Рецепты",
|
||||
margin: EdgeInsets.only(
|
||||
left: 80.h, top: 12.v, bottom: 9.v),
|
||||
margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
|
||||
@@ -29,9 +29,7 @@ class RecipeBloc extends Bloc<RecipeEvent, RecipeState> {
|
||||
final box = await Hive.openBox('token');
|
||||
final token = box.get('token');
|
||||
if (token == null) {
|
||||
NavigatorService.popAndPushNamed(
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
// go to auth screen
|
||||
}
|
||||
final String? recipeID = state.recipeModelObj?.recipeID;
|
||||
final response = await http.get(
|
||||
|
||||
@@ -68,8 +68,7 @@ class AppRoutes {
|
||||
|
||||
static const String scheduleScreen = '/schedule_screen';
|
||||
|
||||
static const String additionalInformationScreen =
|
||||
'/additional_information_screen';
|
||||
static const String additionalInformationScreen = '/additional_information_screen';
|
||||
|
||||
static const String languageSelectScreen = '/language_select_screen';
|
||||
|
||||
@@ -129,82 +128,45 @@ class AppRoutes {
|
||||
static const String glossaryScreen = '/glossary';
|
||||
|
||||
static Map<String, WidgetBuilder> get routes => {
|
||||
dateOfBirthScreen: (context) =>
|
||||
_buildFadeRoute(context, DateOfBirthScreen.builder),
|
||||
cityOfLivingScreen: (context) =>
|
||||
_buildFadeRoute(context, CityOfLivingScreen.builder),
|
||||
bodyCircumferencesScreen: (context) =>
|
||||
_buildFadeRoute(context, BodyCircumferencesScreen.builder),
|
||||
weightScreen: (context) =>
|
||||
_buildFadeRoute(context, WeightScreen.builder),
|
||||
heightScreen: (context) =>
|
||||
_buildFadeRoute(context, HeightScreen.builder),
|
||||
dateOfBirthScreen: (context) => _buildFadeRoute(context, DateOfBirthScreen.builder),
|
||||
cityOfLivingScreen: (context) => _buildFadeRoute(context, CityOfLivingScreen.builder),
|
||||
bodyCircumferencesScreen: (context) => _buildFadeRoute(context, BodyCircumferencesScreen.builder),
|
||||
weightScreen: (context) => _buildFadeRoute(context, WeightScreen.builder),
|
||||
heightScreen: (context) => _buildFadeRoute(context, HeightScreen.builder),
|
||||
nameScreen: (context) => _buildFadeRoute(context, NameScreen.builder),
|
||||
credentialsScreen: (context) =>
|
||||
_buildFadeRoute(context, CredentialsScreen.builder),
|
||||
allergiesScreen: (context) =>
|
||||
_buildFadeRoute(context, AllergiesScreen.builder),
|
||||
medicineIntakeScreen: (context) =>
|
||||
_buildFadeRoute(context, MedicineIntakeScreen.builder),
|
||||
splashScreen: (context) =>
|
||||
_buildFadeRoute(context, SplashScreen.builder),
|
||||
authScreen: (context) => _buildFadeRoute(context, AuthScreen.builder),
|
||||
genderScreen: (context) =>
|
||||
_buildFadeRoute(context, GenderScreen.builder),
|
||||
bloodPressureScreen: (context) =>
|
||||
_buildFadeRoute(context, BloodPressureScreen.builder),
|
||||
favoriteSportsScreen: (context) =>
|
||||
_buildFadeRoute(context, FavoriteSportsScreen.builder),
|
||||
favoriteFoodsScreen: (context) =>
|
||||
_buildFadeRoute(context, FavoriteFoodsScreen.builder),
|
||||
additionalInformationScreen: (context) =>
|
||||
_buildFadeRoute(context, AdditionalInformationScreen.builder),
|
||||
languageSelectScreen: (context) =>
|
||||
_buildFadeRoute(context, LanguageSelectScreen.builder),
|
||||
appNavigationScreen: (context) =>
|
||||
_buildFadeRoute(context, AppNavigationScreen.builder),
|
||||
initialRoute: (context) =>
|
||||
_buildFadeRoute(context, SplashScreen.builder),
|
||||
myProfile: (context) =>
|
||||
_buildFadeRoute(context, MyProfileScreen.builder),
|
||||
mySettings: (context) =>
|
||||
_buildFadeRoute(context, MySettingsScreen.builder),
|
||||
diaryEdit: (context) =>
|
||||
_buildFadeRoute(context, DiaryEditScreen.builder),
|
||||
credentialsScreen: (context) => _buildFadeRoute(context, CredentialsScreen.builder),
|
||||
allergiesScreen: (context) => _buildFadeRoute(context, AllergiesScreen.builder),
|
||||
medicineIntakeScreen: (context) => _buildFadeRoute(context, MedicineIntakeScreen.builder),
|
||||
splashScreen: (context) => _buildFadeRoute(context, SplashScreen.builder),
|
||||
genderScreen: (context) => _buildFadeRoute(context, GenderScreen.builder),
|
||||
bloodPressureScreen: (context) => _buildFadeRoute(context, BloodPressureScreen.builder),
|
||||
favoriteSportsScreen: (context) => _buildFadeRoute(context, FavoriteSportsScreen.builder),
|
||||
favoriteFoodsScreen: (context) => _buildFadeRoute(context, FavoriteFoodsScreen.builder),
|
||||
additionalInformationScreen: (context) => _buildFadeRoute(context, AdditionalInformationScreen.builder),
|
||||
languageSelectScreen: (context) => _buildFadeRoute(context, LanguageSelectScreen.builder),
|
||||
appNavigationScreen: (context) => _buildFadeRoute(context, AppNavigationScreen.builder),
|
||||
initialRoute: (context) => _buildFadeRoute(context, SplashScreen.builder),
|
||||
myProfile: (context) => _buildFadeRoute(context, MyProfileScreen.builder),
|
||||
mySettings: (context) => _buildFadeRoute(context, MySettingsScreen.builder),
|
||||
diaryEdit: (context) => _buildFadeRoute(context, DiaryEditScreen.builder),
|
||||
chatScreen: (context) => _buildFadeRoute(context, ChatScreen.builder),
|
||||
chatSelectScreen: (context) =>
|
||||
_buildFadeRoute(context, ChatSelectScreen.builder),
|
||||
recipeSelectScreen: (context) =>
|
||||
_buildFadeRoute(context, RecipeSelectScreen.builder),
|
||||
recipeScreen: (context) =>
|
||||
_buildFadeRoute(context, RecipeScreen.builder),
|
||||
recipeEditScreen: (context) =>
|
||||
_buildFadeRoute(context, RecipeEditScreen.builder),
|
||||
recipeCreateScreen: (context) =>
|
||||
_buildFadeRoute(context, RecipeCreateScreen.builder),
|
||||
dietSelectScreen: (context) =>
|
||||
_buildFadeRoute(context, DietSelectScreen.builder),
|
||||
chatSelectScreen: (context) => _buildFadeRoute(context, ChatSelectScreen.builder),
|
||||
recipeSelectScreen: (context) => _buildFadeRoute(context, RecipeSelectScreen.builder),
|
||||
recipeScreen: (context) => _buildFadeRoute(context, RecipeScreen.builder),
|
||||
recipeEditScreen: (context) => _buildFadeRoute(context, RecipeEditScreen.builder),
|
||||
recipeCreateScreen: (context) => _buildFadeRoute(context, RecipeCreateScreen.builder),
|
||||
dietSelectScreen: (context) => _buildFadeRoute(context, DietSelectScreen.builder),
|
||||
dietScreen: (context) => _buildFadeRoute(context, DietScreen.builder),
|
||||
dietEditScreen: (context) =>
|
||||
_buildFadeRoute(context, DietEditScreen.builder),
|
||||
dietCreateScreen: (context) =>
|
||||
_buildFadeRoute(context, DietCreateScreen.builder),
|
||||
planSelectScreen: (context) =>
|
||||
_buildFadeRoute(context, PlanSelectScreen.builder),
|
||||
dietEditScreen: (context) => _buildFadeRoute(context, DietEditScreen.builder),
|
||||
dietCreateScreen: (context) => _buildFadeRoute(context, DietCreateScreen.builder),
|
||||
planSelectScreen: (context) => _buildFadeRoute(context, PlanSelectScreen.builder),
|
||||
planScreen: (context) => _buildFadeRoute(context, PlanScreen.builder),
|
||||
planEditScreen: (context) =>
|
||||
_buildFadeRoute(context, PlanEditScreen.builder),
|
||||
planCreateScreen: (context) =>
|
||||
_buildFadeRoute(context, PlanCreateScreen.builder),
|
||||
planEditScreen: (context) => _buildFadeRoute(context, PlanEditScreen.builder),
|
||||
planCreateScreen: (context) => _buildFadeRoute(context, PlanCreateScreen.builder),
|
||||
feedScreen: (context) => _buildFadeRoute(context, FeedScreen.builder),
|
||||
// blogPostScreen: (context) =>
|
||||
// _buildFadeRoute(context, BlogPostScreen.builder),
|
||||
blogPostEditScreen: (context) =>
|
||||
_buildFadeRoute(context, BlogPostEditScreen.builder),
|
||||
blogPostCreateScreen: (context) =>
|
||||
_buildFadeRoute(context, BlogPostCreateScreen.builder),
|
||||
glossaryScreen: (context) =>
|
||||
_buildFadeRoute(context, GlossaryScreen.builder),
|
||||
blogPostEditScreen: (context) => _buildFadeRoute(context, BlogPostEditScreen.builder),
|
||||
blogPostCreateScreen: (context) => _buildFadeRoute(context, BlogPostCreateScreen.builder),
|
||||
glossaryScreen: (context) => _buildFadeRoute(context, GlossaryScreen.builder),
|
||||
};
|
||||
|
||||
static Widget _buildFadeRoute(BuildContext context, WidgetBuilder builder) {
|
||||
@@ -220,14 +182,10 @@ class FadeTransitionPage extends PageRouteBuilder {
|
||||
|
||||
FadeTransitionPage({required this.builder})
|
||||
: super(
|
||||
pageBuilder: (BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||
return builder(context);
|
||||
},
|
||||
transitionsBuilder: (BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
||||
return FadeTransition(opacity: animation, child: child);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -73,13 +73,21 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgLogo),
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgLogo,
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Лента',
|
||||
icon: SvgPicture.asset(ImageConstant.imgFeed),
|
||||
icon: SvgPicture.asset(
|
||||
width: 24,
|
||||
height: 24,
|
||||
ImageConstant.imgFeed,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgFeed,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
@@ -88,9 +96,15 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "diary".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgDiary),
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgDiary,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgDiary,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
@@ -99,9 +113,15 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "chat".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgChat),
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
@@ -110,9 +130,15 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgBell),
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
|
||||
import 'package:eatvio_app/widgets/custom_hyper_switch.dart';
|
||||
import 'package:eatvio_app/widgets/custom_hypo_switch.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:eatvio_app/widgets/next_step_button.dart';
|
||||
import 'dart:convert';
|
||||
@@ -395,10 +396,7 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
}
|
||||
|
||||
void _navigateToProfilePage() {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.myProfile,
|
||||
);
|
||||
GoRouter.of(context).go('/my-profile-screen');
|
||||
}
|
||||
|
||||
String _getErrorMessage(http.Response response) {
|
||||
|
||||
Reference in New Issue
Block a user