updated error handling, consultant rating layout and complaining logic

This commit is contained in:
Username1548
2025-02-28 19:18:01 +07:00
parent e5b293db79
commit 0cdd40102f
86 changed files with 3853 additions and 279 deletions

View File

@@ -12,13 +12,13 @@ import 'package:eatvio_app/features/chat/presentation/bloc/chats_cubit/chats_cub
import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart';
import 'package:eatvio_app/features/chat/presentation/pages/chats_screen.dart';
import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart';
import 'package:eatvio_app/features/complaining/presentation/complaining_screen.dart';
import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart';
import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart';
import 'package:eatvio_app/features/consultations/presentation/pages/consultations_screen.dart';
import 'package:eatvio_app/features/create_diet/presentation/create_diet_screen.dart';
import 'package:eatvio_app/features/create_diet/presentation/diet_preview_screen.dart';
import 'package:eatvio_app/features/create_plan/presentation/create_plan_screen.dart';
import 'package:eatvio_app/features/consultant_rating/presentation/consultant_rating_screen.dart';
import 'package:eatvio_app/features/dev_tools/presentation/dev_tools_screen.dart';
import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart';
import 'package:eatvio_app/features/diets/presentation/pages/about_diet_screen.dart';
@@ -66,7 +66,7 @@ class AppRouter {
name: 'authScreen',
redirect: (context, state) async {
// TokenStorage.removeTokenInStorage();
// await TokenStorage.saveTokenInStorage('1|laravel_sanctum_zaU2133RQ0wbxDYdH7IQxTpThmilWtKhzxbSt5X1065fcae3');
// await TokenStorage.saveTokenInStorage('Bearer 3|laravel_sanctum_zoubsO9NPXAqgLZEdHV9R3XbuDUHJJMJyXcd77mhbb649f04');
if (await TokenStorage.haveTokenInStorage()) {
return '/my-profile-screen';
}
@@ -224,7 +224,10 @@ class AppRouter {
final data = state.extra as Map<String, dynamic>;
final chatsCubit = data['chatsCubit'] as ChatsCubit;
final chatId = data['chatId'] as String;
return ChatScreen(chatId: chatId, chatsCubit: chatsCubit,);
return ChatScreen(
chatId: chatId,
chatsCubit: chatsCubit,
);
},
),
GoRoute(
@@ -311,11 +314,6 @@ class AppRouter {
index: int.parse(state.pathParameters['index']!),
),
),
GoRoute(
path: '/complaining-screen',
name: 'complainingScreen',
builder: (context, state) => ComplainingScreen(),
),
GoRoute(
path: CreateDietScreen.path,
name: CreateDietScreen.name,
@@ -361,6 +359,11 @@ class AppRouter {
name: DevToolsScreen.name,
builder: (context, state) => DevToolsScreen(),
),
GoRoute(
path: ConsultantRatingScreen.path,
name: ConsultantRatingScreen.name,
builder: (context, state) => ConsultantRatingScreen(),
),
],
);
}

View File

@@ -1,9 +1,3 @@
enum ProductType {
diet,
plan,
recipe
}
enum BaseState {
loading,
error,

View File

@@ -0,0 +1,7 @@
enum ComplainedContent {
diet,
plan,
recipe,
profile,
posts
}

View File

@@ -0,0 +1,5 @@
enum ProductType {
diet,
plan,
recipe
}

View File

@@ -5,6 +5,9 @@ import 'package:eatvio_app/core/websockets/ws_service.dart';
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit.dart';
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
import 'package:eatvio_app/features/auth/services/auth_service.dart';
import 'package:eatvio_app/features/complaining/presentation/cubit/complaining_cubit.dart';
import 'package:eatvio_app/features/complaining/repositories/complaining_repository.dart';
import 'package:eatvio_app/features/complaining/services/complaining_service.dart';
import 'package:eatvio_app/features/create_diet/presentation/cubit/create_diet_cubit.dart';
import 'package:eatvio_app/features/create_diet/repositories/create_diet_repository.dart';
import 'package:eatvio_app/features/create_diet/services/create_diet_service.dart';
@@ -112,6 +115,7 @@ Future<void> init() async {
sl.registerFactory<ConsultantsCubit>(() => ConsultantsCubit(feedRepository: sl()));
sl.registerFactory<AboutRecipeCubit>(() => AboutRecipeCubit(recipeRepository: sl(), profileRepository: sl()));
sl.registerFactory<AuthCubit>(() => AuthCubit(authRepository: sl()));
sl.registerFactory<ComplainingCubit>(() => ComplainingCubit(repository: sl()));
// Repository
sl.registerLazySingleton<ChatRepository>(() => ChatRepository(chatService: sl()));
@@ -132,6 +136,7 @@ Future<void> init() async {
sl.registerLazySingleton<MyDietsRepository>(() => MyDietsRepository(myDietsService: sl()));
sl.registerLazySingleton<MyPlansRepository>(() => MyPlansRepository(myPlansService: sl()));
sl.registerLazySingleton<AboutRecipeRepository>(() => AboutRecipeRepository(recipeService: sl()));
sl.registerLazySingleton<ComplainingRepository>(() => ComplainingRepository(service: sl()));
sl.registerLazySingleton<AuthRepository>(() => AuthRepository(authService: sl()));
// Services
@@ -154,6 +159,7 @@ Future<void> init() async {
sl.registerLazySingleton<MyPlansService>(() => MyPlansService(sl()));
sl.registerLazySingleton<WsService>(() => WsService(sl()));
sl.registerLazySingleton<AboutRecipeService>(() => AboutRecipeService(sl()));
sl.registerLazySingleton<ComplainingService>(() => ComplainingService(sl()));
sl.registerLazySingleton<AuthService>(() => AuthService(sl()));
// External

View File

@@ -184,6 +184,12 @@ abstract class TextStyles {
height: 1.255,
);
static const headingFS40FW600 = TextStyle(
fontSize: 40,
fontWeight: FontWeight.w600,
height: 1.255,
);
static const textLSemibold = TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,

View File

@@ -190,6 +190,10 @@ class PrimaryColors {
Color get transparentBlack => Color(0xFF1313264).withValues(alpha: 0.3);
Color get gray60004 => Color(0xFFD4DAE2).withValues(alpha: 0.2);
Color get blueGray => Color(0xFF809CB9);
Color get dialogShadow => Color.fromARGB(125, 0, 0, 0);
}
PrimaryColors get appTheme => ThemeHelper().themeColor();

View File

@@ -0,0 +1,68 @@
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
class DataErrorWidget extends StatefulWidget {
const DataErrorWidget({super.key, required this.onReload});
final Future<void> Function() onReload;
@override
State<DataErrorWidget> createState() => _DataErrorWidgetState();
}
class _DataErrorWidgetState extends State<DataErrorWidget> {
bool isLoading = false;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset('assets/icons/cloud.svg'),
SizedBox(height: 30),
Text(
s.something_went_wrong,
style: TextStyles.textLSemibold.copyWith(color: appTheme.black),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text(
s.can_not_load_data_please_try_again,
style: TextStyles.textSMedium.copyWith(color: appTheme.black),
textAlign: TextAlign.center,
),
),
SizedBox(height: 20),
isLoading
? Loader()
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: CustomOutlinedButton(
text: s.try_again,
height: 52,
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(
side: WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
onPressed: () async {
setState(() {
isLoading = true;
});
await widget.onReload();
setState(() {
isLoading = false;
});
},
),
),
],
);
}
}

View File

@@ -1,5 +1,5 @@
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/utils/enums.dart';
import 'package:eatvio_app/core/enums/product_type.dart';
import 'package:eatvio_app/core/utils/localization_utils.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/type_badges.dart';

View File

@@ -0,0 +1,59 @@
import 'package:eatvio_app/core/app_router.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void showErrorDialog(BuildContext context, {String? title, String? description}) {
showDialog<void>(
context: context,
barrierColor: Colors.transparent,
builder: (BuildContext context) {
final s = S.of(context);
return Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Container(
decoration: BoxDecoration(
color: appTheme.whiteA700,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [BoxShadow(color: appTheme.dialogShadow, blurRadius: 32)],
),
width: MediaQuery.sizeOf(context).width,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 20),
Text(
title ?? s.some_error_occurred,
style: TextStyles.textLSemibold.copyWith(color: appTheme.black, decoration: TextDecoration.none),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.only(right: 72),
child: Text(
description ?? s.some_error_occurred_description,
style: TextStyles.textSMedium.copyWith(color: appTheme.black, decoration: TextDecoration.none),
),
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () => AppRouter.navigatorKey.currentContext?.pop(),
child: Text(s.ok, style: TextStyles.textLSemibold.copyWith(color: appTheme.blueA400)),
),
),
SizedBox(height: 12),
],
),
),
),
),
);
},
);
}

View File

@@ -3,6 +3,7 @@ import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
@@ -11,6 +12,7 @@ class SuccessPublishedDietBottomSheet extends StatelessWidget {
final String title;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
children: [
SizedBox(
@@ -37,7 +39,7 @@ class SuccessPublishedDietBottomSheet extends StatelessWidget {
onPressed: () {
AppRouter.navigatorKey.currentContext?.pop();
},
text: 'Хорошо',
text: s.ok,
height: 52,
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(

View File

@@ -0,0 +1,57 @@
import 'package:eatvio_app/core/app_router.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class SuccessPublishedRecipeBottomSheet extends StatelessWidget {
const SuccessPublishedRecipeBottomSheet({super.key, required this.title});
final String title;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
children: [
SizedBox(
height: 20,
),
BottomSheetHandlerBar(),
SizedBox(
height: 20,
),
Text(
s.recipe_publishing,
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
Text(
'"$title" ${s.successfully_published}',
style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black),
),
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: CustomOutlinedButton(
onPressed: () {
AppRouter.navigatorKey.currentContext?.pop();
},
text: s.ok,
height: 52,
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(
side: WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
),
),
SizedBox(
height: 20,
),
],
);
}
}