forked from eatvio/eatvio_app
feat(consultations): consultations archive. feat(diary): plan and diet widget
This commit is contained in:
@@ -32,7 +32,7 @@ import 'package:eatvio_app/features/glossary/presentation/pages/glossary_screen.
|
|||||||
import 'package:eatvio_app/features/menu/presentation/pages/menu_screen.dart';
|
import 'package:eatvio_app/features/menu/presentation/pages/menu_screen.dart';
|
||||||
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
||||||
import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart';
|
import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/presentation/consultant_finance_screen.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultations_archive_screen.dart';
|
||||||
import 'package:eatvio_app/features/my_finance/presentation/pages/user_finance_screen.dart';
|
import 'package:eatvio_app/features/my_finance/presentation/pages/user_finance_screen.dart';
|
||||||
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
|
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
|
||||||
import 'package:eatvio_app/features/notifications/presentation/notifications_screen.dart';
|
import 'package:eatvio_app/features/notifications/presentation/notifications_screen.dart';
|
||||||
@@ -177,7 +177,7 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/consultant-finance-screen',
|
path: '/consultant-finance-screen',
|
||||||
name: 'consultantFinanceScreen',
|
name: 'consultantFinanceScreen',
|
||||||
builder: (context, state) => const ConsultationsArchive(),
|
builder: (context, state) => const ConsultationsArchiveScreen(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/user-finance-screen',
|
path: '/user-finance-screen',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// String baseUrl = 'https://eatvio.ru';
|
String baseUrl = 'https://eatvio.ru';
|
||||||
String baseUrl = 'https://dev2.eatvio.com';
|
// String baseUrl = 'https://dev2.eatvio.com';
|
||||||
|
|
||||||
const List<int> durationValues = [7, 14, 21];
|
const List<int> durationValues = [7, 14, 21];
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import 'package:eatvio_app/features/complaining/services/complaining_service.dar
|
|||||||
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_cubit.dart';
|
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_cubit.dart';
|
||||||
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
||||||
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/cubit/consultations_archive_cubit.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_cubit.dart';
|
||||||
import 'package:eatvio_app/features/create_diet/presentation/cubit/create_diet_cubit.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/repositories/create_diet_repository.dart';
|
||||||
import 'package:eatvio_app/features/create_diet/services/create_diet_service.dart';
|
import 'package:eatvio_app/features/create_diet/services/create_diet_service.dart';
|
||||||
@@ -122,7 +122,8 @@ Future<void> init() async {
|
|||||||
sl.registerFactory<PlansCubit>(() => PlansCubit(feedRepository: sl(), planRepository: sl()));
|
sl.registerFactory<PlansCubit>(() => PlansCubit(feedRepository: sl(), planRepository: sl()));
|
||||||
sl.registerFactory<SettingsCubit>(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl()));
|
sl.registerFactory<SettingsCubit>(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl()));
|
||||||
sl.registerFactory<RegisterConsultantCubit>(() => RegisterConsultantCubit(consultantRepository: sl()));
|
sl.registerFactory<RegisterConsultantCubit>(() => RegisterConsultantCubit(consultantRepository: sl()));
|
||||||
sl.registerFactory<DiaryCubit>(() => DiaryCubit(diaryRepository: sl(), glossaryRepository: sl(), profileRepository: sl(), dietRepository: sl()));
|
sl.registerFactory<DiaryCubit>(
|
||||||
|
() => DiaryCubit(chatRepository: sl(), diaryRepository: sl(), glossaryRepository: sl(), profileRepository: sl(), dietRepository: sl()));
|
||||||
sl.registerFactory<AboutDietCubit>(() => AboutDietCubit(dietsRepository: sl(), profileRepository: sl()));
|
sl.registerFactory<AboutDietCubit>(() => AboutDietCubit(dietsRepository: sl(), profileRepository: sl()));
|
||||||
sl.registerFactory<BlogPostCreateCubit>(() => BlogPostCreateCubit(blogPostRepository: sl()));
|
sl.registerFactory<BlogPostCreateCubit>(() => BlogPostCreateCubit(blogPostRepository: sl()));
|
||||||
sl.registerFactory<SubCubit>(() => SubCubit(profileRepository: sl()));
|
sl.registerFactory<SubCubit>(() => SubCubit(profileRepository: sl()));
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
||||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||||
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
import 'package:eatvio_app/features/consultations/services/consultation_service.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/models/statistic_model.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
|
||||||
|
|
||||||
class ConsultationsRepository {
|
class ConsultationsRepository {
|
||||||
final ConsultationService consultationService;
|
final ConsultationService consultationService;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
||||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/models/statistic_model.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
|
||||||
|
|
||||||
class ConsultationService {
|
class ConsultationService {
|
||||||
final Dio dio;
|
final Dio dio;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
import 'package:eatvio_app/core/image_compressing/image_compress_utility.dart';
|
||||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||||
|
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
|
||||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||||
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
||||||
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
|
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
|
||||||
@@ -23,8 +24,14 @@ class DiaryCubit extends Cubit<DiaryState> {
|
|||||||
final GlossaryRepository glossaryRepository;
|
final GlossaryRepository glossaryRepository;
|
||||||
final ProfileRepository profileRepository;
|
final ProfileRepository profileRepository;
|
||||||
final DietRepository dietRepository;
|
final DietRepository dietRepository;
|
||||||
|
final ChatRepository chatRepository;
|
||||||
int? diaryId;
|
int? diaryId;
|
||||||
DiaryCubit({required this.diaryRepository, required this.glossaryRepository, required this.profileRepository, required this.dietRepository})
|
DiaryCubit(
|
||||||
|
{required this.chatRepository,
|
||||||
|
required this.diaryRepository,
|
||||||
|
required this.glossaryRepository,
|
||||||
|
required this.profileRepository,
|
||||||
|
required this.dietRepository})
|
||||||
: super(const DiaryState.loading()) {
|
: super(const DiaryState.loading()) {
|
||||||
today = DateTime.now();
|
today = DateTime.now();
|
||||||
selectedDay = today;
|
selectedDay = today;
|
||||||
@@ -146,6 +153,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
|||||||
|
|
||||||
fetchDiary([bool needLoading = false, int? diaryId]) async {
|
fetchDiary([bool needLoading = false, int? diaryId]) async {
|
||||||
this.diaryId ??= diaryId;
|
this.diaryId ??= diaryId;
|
||||||
|
|
||||||
if (needLoading) {
|
if (needLoading) {
|
||||||
emit(const DiaryState.loading());
|
emit(const DiaryState.loading());
|
||||||
selectedMeal = 1;
|
selectedMeal = 1;
|
||||||
@@ -159,8 +167,15 @@ class DiaryCubit extends Cubit<DiaryState> {
|
|||||||
diaryDay = await diaryRepository.getDiaryByDate(stringDate);
|
diaryDay = await diaryRepository.getDiaryByDate(stringDate);
|
||||||
}
|
}
|
||||||
ConsultantReviewModel? consultantReview;
|
ConsultantReviewModel? consultantReview;
|
||||||
|
int? planDuration;
|
||||||
|
int? currentPlanDay;
|
||||||
|
String? planName;
|
||||||
if (diaryDay.chosenPlanId != null) {
|
if (diaryDay.chosenPlanId != null) {
|
||||||
consultantReview = await diaryRepository.getDiaryComments(planId: diaryDay.chosenPlanId!, diaryId: diaryDay.id);
|
consultantReview = await diaryRepository.getDiaryComments(planId: diaryDay.chosenPlanId!, diaryId: diaryDay.id);
|
||||||
|
final chosenPlanModel = await chatRepository.getChosenPlan(id: diaryDay.chosenPlanId!);
|
||||||
|
planDuration = chosenPlanModel.plan.duration;
|
||||||
|
planName = chosenPlanModel.plan.name;
|
||||||
|
currentPlanDay = DateTime.now().difference(chosenPlanModel.startDate).inDays + 1;
|
||||||
}
|
}
|
||||||
final nutrition = await getNutrition(diaryDay.id);
|
final nutrition = await getNutrition(diaryDay.id);
|
||||||
|
|
||||||
@@ -179,6 +194,9 @@ class DiaryCubit extends Cubit<DiaryState> {
|
|||||||
consultantReview: consultantReview,
|
consultantReview: consultantReview,
|
||||||
isDiaryFinished: isDiaryFinished,
|
isDiaryFinished: isDiaryFinished,
|
||||||
isDiaryCommented: isDiaryCommented,
|
isDiaryCommented: isDiaryCommented,
|
||||||
|
chosenPlanCurrentDay: currentPlanDay,
|
||||||
|
chosenPlanDuration: planDuration,
|
||||||
|
chosenPlanName: planName,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ abstract class DiaryState with _$DiaryState {
|
|||||||
required NutritionDataModel nutrition,
|
required NutritionDataModel nutrition,
|
||||||
required DateTime selectedDay,
|
required DateTime selectedDay,
|
||||||
required int selectedMeal,
|
required int selectedMeal,
|
||||||
@Default(false) bool isConsultantView,
|
int? chosenPlanCurrentDay,
|
||||||
|
String? chosenPlanName,
|
||||||
|
int? chosenPlanDuration,
|
||||||
ConsultantReviewModel? consultantReview,
|
ConsultantReviewModel? consultantReview,
|
||||||
|
@Default(false) bool isConsultantView,
|
||||||
@Default(false) bool isDiaryFinished,
|
@Default(false) bool isDiaryFinished,
|
||||||
@Default(false) bool isDiaryCommented,
|
@Default(false) bool isDiaryCommented,
|
||||||
}) = DiaryStateLoaded;
|
}) = DiaryStateLoaded;
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||||
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
||||||
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||||
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
class ChosenPlanWidget extends StatelessWidget {
|
||||||
|
const ChosenPlanWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<DiaryCubit, DiaryState>(builder: (context, state) {
|
||||||
|
if (state is DiaryStateLoaded) {
|
||||||
|
if (state.diary.typeOfDiary.hasChosenPlan) {
|
||||||
|
return ChosenPlanWidgetContent(
|
||||||
|
currentPlanDay: state.chosenPlanCurrentDay ?? 0,
|
||||||
|
planName: state.chosenPlanName ?? '',
|
||||||
|
planDuration: state.chosenPlanDuration ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChosenPlanWidgetContent extends StatelessWidget {
|
||||||
|
const ChosenPlanWidgetContent({
|
||||||
|
super.key,
|
||||||
|
required this.currentPlanDay,
|
||||||
|
required this.planName,
|
||||||
|
required this.planDuration,
|
||||||
|
});
|
||||||
|
final int currentPlanDay;
|
||||||
|
final String planName;
|
||||||
|
final int planDuration;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final size = MediaQuery.sizeOf(context);
|
||||||
|
final s = S.of(context);
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: size.width * 0.4,
|
||||||
|
child: Text(planName, style: TextStyles.textLMedium.copyWith(color: appTheme.black)),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(color: appTheme.dividerColor, borderRadius: BorderRadius.circular(12)),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
|
||||||
|
child: Text('${s.day} $currentPlanDay из $planDuration', style: TextStyles.textMSemibold.copyWith(color: appTheme.gray)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
|||||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||||
import 'package:eatvio_app/features/diary/presentation/widgets/add_product_button_widget.dart';
|
import 'package:eatvio_app/features/diary/presentation/widgets/add_product_button_widget.dart';
|
||||||
import 'package:eatvio_app/features/diary/presentation/widgets/chosen_diet_widget.dart';
|
import 'package:eatvio_app/features/diary/presentation/widgets/chosen_diet_widget.dart';
|
||||||
|
import 'package:eatvio_app/features/diary/presentation/widgets/chosen_plan_widget.dart';
|
||||||
import 'package:eatvio_app/features/diary/presentation/widgets/comment_container.dart';
|
import 'package:eatvio_app/features/diary/presentation/widgets/comment_container.dart';
|
||||||
import 'package:eatvio_app/features/diary/presentation/widgets/meal_button_widget.dart';
|
import 'package:eatvio_app/features/diary/presentation/widgets/meal_button_widget.dart';
|
||||||
import 'package:eatvio_app/features/diary/presentation/widgets/meal_comment_widget.dart';
|
import 'package:eatvio_app/features/diary/presentation/widgets/meal_comment_widget.dart';
|
||||||
@@ -60,6 +61,7 @@ class _MealWidgetState extends State<MealWidget> {
|
|||||||
const TimeOfMealPickerWidget(),
|
const TimeOfMealPickerWidget(),
|
||||||
|
|
||||||
const ChosenDietWidget(),
|
const ChosenDietWidget(),
|
||||||
|
const ChosenPlanWidget(),
|
||||||
const ProductsListWidget(),
|
const ProductsListWidget(),
|
||||||
if (widget.showAddButton) ...[
|
if (widget.showAddButton) ...[
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||||
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_state.dart';
|
import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_state.dart';
|
||||||
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
||||||
@@ -77,7 +79,13 @@ class FeedCubit extends Cubit<FeedState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
likePost(int id) async => await feedRepository.likeBlogPost(id: id);
|
likePost(int id) async {
|
||||||
|
try {
|
||||||
|
await feedRepository.likeBlogPost(id: id);
|
||||||
|
} catch (e, st) {
|
||||||
|
log(e.toString(), stackTrace: st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unlikedPost(int id) async => await feedRepository.unlikedBlogPost(id: id);
|
unlikedPost(int id) async => await feedRepository.unlikedBlogPost(id: id);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
import 'package:eatvio_app/core/enums/filters_comparison_enum.dart';
|
||||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
|
||||||
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/cubit/consultations_archive_state.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_state.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/models/statistic_model.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
|
||||||
|
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class ConsultationsArchiveCubit extends Cubit<ConsultationsArchiveState> {
|
class ConsultationsArchiveCubit extends Cubit<ConsultationsArchiveState> {
|
||||||
@@ -62,24 +62,6 @@ class ConsultationsArchiveCubit extends Cubit<ConsultationsArchiveState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PeriodFilterStatus {
|
|
||||||
all,
|
|
||||||
month,
|
|
||||||
week;
|
|
||||||
|
|
||||||
String get name => switch (this) {
|
|
||||||
PeriodFilterStatus.all => 'Все периоды',
|
|
||||||
PeriodFilterStatus.month => 'За месяц',
|
|
||||||
PeriodFilterStatus.week => 'За неделю',
|
|
||||||
};
|
|
||||||
|
|
||||||
String? get value => switch (this) {
|
|
||||||
PeriodFilterStatus.all => null,
|
|
||||||
PeriodFilterStatus.month => DateTime.now().subtract(const Duration(days: 30)).format('yyyy-MM-dd'),
|
|
||||||
PeriodFilterStatus.week => DateTime.now().subtract(const Duration(days: 7)).format('yyyy-MM-dd'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ConsultationFilterStatus {
|
enum ConsultationFilterStatus {
|
||||||
all,
|
all,
|
||||||
canceled,
|
canceled,
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
import 'package:eatvio_app/features/consultations/models/consultation_model.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/cubit/consultations_archive_cubit.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_cubit.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/models/statistic_model.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/models/statistic_model.dart';
|
||||||
|
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
part 'consultations_archive_state.freezed.dart';
|
part 'consultations_archive_state.freezed.dart';
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:eatvio_app/features/consultations/repositories/consultations_repository.dart';
|
||||||
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_state.dart';
|
||||||
|
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
class ConsultantFinancesCubit extends Cubit<ConsultantFinancesState> {
|
||||||
|
final ConsultationsRepository consultationsRepository;
|
||||||
|
ConsultantFinancesCubit({
|
||||||
|
required this.consultationsRepository,
|
||||||
|
}) : super(
|
||||||
|
ConsultantFinancesState(),
|
||||||
|
);
|
||||||
|
|
||||||
|
Future<void> getConsultations() async {
|
||||||
|
try {
|
||||||
|
emit(state.copyWith(isLoading: true));
|
||||||
|
} catch (e) {
|
||||||
|
emit(state.copyWith(isLoading: false));
|
||||||
|
log(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setConsultationsPeriod(PeriodFilterStatus period) async {
|
||||||
|
emit(state.copyWith(periodFilterStatus: period));
|
||||||
|
await getConsultations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'consultant_finances_state.freezed.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class ConsultantFinancesState with _$ConsultantFinancesState {
|
||||||
|
factory ConsultantFinancesState({
|
||||||
|
@Default([]) List<String> financesModels,
|
||||||
|
@Default(false) isLoading,
|
||||||
|
@Default(null) String? error,
|
||||||
|
@Default(null) PeriodFilterStatus? periodFilterStatus,
|
||||||
|
}) = _ConsultantFinancesState;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||||
|
|
||||||
|
enum PeriodFilterStatus {
|
||||||
|
all,
|
||||||
|
month,
|
||||||
|
week;
|
||||||
|
|
||||||
|
String get name => switch (this) {
|
||||||
|
PeriodFilterStatus.all => 'Все периоды',
|
||||||
|
PeriodFilterStatus.month => 'За месяц',
|
||||||
|
PeriodFilterStatus.week => 'За неделю',
|
||||||
|
};
|
||||||
|
|
||||||
|
String? get value => switch (this) {
|
||||||
|
PeriodFilterStatus.all => null,
|
||||||
|
PeriodFilterStatus.month => DateTime.now().subtract(const Duration(days: 30)).format('yyyy-MM-dd'),
|
||||||
|
PeriodFilterStatus.week => DateTime.now().subtract(const Duration(days: 7)).format('yyyy-MM-dd'),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
// import 'package:eatvio_app/core/locator_service.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/utils/date_time_utils.dart';
|
||||||
|
// import 'package:eatvio_app/core/utils/localization_utils.dart';
|
||||||
|
// import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
||||||
|
// import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
|
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_cubit.dart';
|
||||||
|
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_state.dart';
|
||||||
|
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_cubit.dart';
|
||||||
|
// import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/consultant_finances/consultant_finances_state.dart';
|
||||||
|
// import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||||
|
// import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/widgets/status_widget.dart';
|
||||||
|
// import 'package:eatvio_app/generated/l10n.dart';
|
||||||
|
// import 'package:flutter/material.dart';
|
||||||
|
// import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
// class ConsultantFinancesScreen extends StatefulWidget {
|
||||||
|
// const ConsultantFinancesScreen({super.key});
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// State<ConsultantFinancesScreen> createState() => _ConsultantFinancesScreenState();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class _ConsultantFinancesScreenState extends State<ConsultantFinancesScreen> {
|
||||||
|
// @override
|
||||||
|
// Widget build(BuildContext context) {
|
||||||
|
// final s = S.of(context);
|
||||||
|
// return BlocProvider<ConsultantFinancesCubit>(
|
||||||
|
// create: (context) => sl<ConsultantFinancesCubit>(),
|
||||||
|
// child: BlocBuilder<ConsultantFinancesCubit, ConsultantFinancesState>(
|
||||||
|
// builder: (context, state) {
|
||||||
|
// return Scaffold(
|
||||||
|
// backgroundColor: const Color(0xFFF0F2F5),
|
||||||
|
// appBar: AppBar(
|
||||||
|
// shape: const RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadiusDirectional.vertical(
|
||||||
|
// bottom: Radius.circular(12),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// title: const Text('Архив консультаций'),
|
||||||
|
// centerTitle: true,
|
||||||
|
// ),
|
||||||
|
// body: state.isLoading
|
||||||
|
// ? const Center(
|
||||||
|
// child: Loader(),
|
||||||
|
// )
|
||||||
|
// : SingleChildScrollView(
|
||||||
|
// padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// Material(
|
||||||
|
// color: Colors.white,
|
||||||
|
// borderRadius: BorderRadius.circular(12),
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
// child: Text(
|
||||||
|
// 'Всего консультаций: ${state.statisticModel.total}',
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontSize: 16,
|
||||||
|
// fontWeight: FontWeight.w500,
|
||||||
|
// color: Color(0xFF6D6F71),
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 12),
|
||||||
|
// Row(
|
||||||
|
// children: [
|
||||||
|
// const SizedBox(width: 16),
|
||||||
|
// Material(
|
||||||
|
// color: const Color(0xFF0BB450).withAlpha(11),
|
||||||
|
// borderRadius: BorderRadius.circular(8),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
// child: Text(
|
||||||
|
// 'Завершено: ${state.statisticModel.finished}',
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w400,
|
||||||
|
// color: Color(0xFF0BB450),
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(width: 8),
|
||||||
|
// Material(
|
||||||
|
// color: const Color(0xFFD01717).withAlpha(11),
|
||||||
|
// borderRadius: BorderRadius.circular(8),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
// child: Text(
|
||||||
|
// 'Отменено: ${state.statisticModel.canceled}',
|
||||||
|
// style: const TextStyle(
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w400,
|
||||||
|
// color: Color(0xFFD01717),
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Material(
|
||||||
|
// color: Colors.white,
|
||||||
|
// borderRadius: BorderRadius.circular(12),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
|
||||||
|
// child: SingleChildScrollView(
|
||||||
|
// physics: const NeverScrollableScrollPhysics(),
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// CustomDropDownButton<PeriodFilterStatus>(
|
||||||
|
// items: PeriodFilterStatus.values
|
||||||
|
// .map(
|
||||||
|
// (value) => DropdownMenuItem(
|
||||||
|
// value: value,
|
||||||
|
// child: Text(
|
||||||
|
// value.name,
|
||||||
|
// style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// .toList(),
|
||||||
|
// onChanged: (value) {
|
||||||
|
// if (value == null) return;
|
||||||
|
// context.read<ConsultationsArchiveCubit>().setConsultationsPeriod(value);
|
||||||
|
// },
|
||||||
|
// value: state.periodFilterStatus ?? PeriodFilterStatus.values.first,
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 12),
|
||||||
|
// CustomDropDownButton<ConsultationFilterStatus>(
|
||||||
|
// items: ConsultationFilterStatus.values
|
||||||
|
// .map(
|
||||||
|
// (value) => DropdownMenuItem(
|
||||||
|
// value: value,
|
||||||
|
// child: Text(
|
||||||
|
// value.name,
|
||||||
|
// style: TextStyles.textMMedium.copyWith(color: appTheme.black),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// .toList(),
|
||||||
|
// onChanged: (value) {
|
||||||
|
// if (value == null) return;
|
||||||
|
// context.read<ConsultationsArchiveCubit>().setConsultationsStatus(value);
|
||||||
|
// },
|
||||||
|
// value: state.consultationFilterStatus,
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 12),
|
||||||
|
// if (state.consultations.isNotEmpty)
|
||||||
|
// ListView.separated(
|
||||||
|
// shrinkWrap: true,
|
||||||
|
// physics: const NeverScrollableScrollPhysics(),
|
||||||
|
// itemBuilder: (context, index) {
|
||||||
|
// return Material(
|
||||||
|
// color: const Color(0xFFF6F6F6),
|
||||||
|
// borderRadius: BorderRadius.circular(20),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: const EdgeInsets.all(12),
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// state.consultations[index].id.toString(),
|
||||||
|
// style: const TextStyle(
|
||||||
|
// color: Color(0xFF323F4B),
|
||||||
|
// height: 1,
|
||||||
|
// fontWeight: FontWeight.w500,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Text(
|
||||||
|
// state.consultations[index].startDate.format('yyyy.MM.dd'),
|
||||||
|
// style: const TextStyle(
|
||||||
|
// color: Color(0xFF6D6F71),
|
||||||
|
// height: 1,
|
||||||
|
// fontWeight: FontWeight.w500,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Text(
|
||||||
|
// state.consultations[index].planTitle,
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: appTheme.blueA400,
|
||||||
|
// height: 1,
|
||||||
|
// fontSize: 18,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Text(
|
||||||
|
// 'Покупатель: ${state.consultations[index].userName}',
|
||||||
|
// style: const TextStyle(
|
||||||
|
// color: Color(0xFF323F4B),
|
||||||
|
// height: 1,
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w500,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Text(
|
||||||
|
// '${state.consultations[index].duration} ${getDayForm(state.consultations[index].duration, s)}',
|
||||||
|
// style: const TextStyle(
|
||||||
|
// color: Color(0xFF323F4B),
|
||||||
|
// height: 1,
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w500,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Container(
|
||||||
|
// height: 1,
|
||||||
|
// width: double.infinity,
|
||||||
|
// decoration: const BoxDecoration(
|
||||||
|
// color: Color(0xFFDEDEDF),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 8),
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// '${state.consultations[index].consultantPayment.toStringAsFixed(2)} ₽',
|
||||||
|
// style: const TextStyle(
|
||||||
|
// color: Color(0xFF323F4B),
|
||||||
|
// height: 1,
|
||||||
|
// fontSize: 18,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// StatusWidget(
|
||||||
|
// status: state.consultations[index].chosenPlanState,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||||
|
// itemCount: state.financesModels.length,
|
||||||
|
// )
|
||||||
|
// else
|
||||||
|
// const Padding(
|
||||||
|
// padding: EdgeInsets.symmetric(vertical: 40.0),
|
||||||
|
// child: Text(
|
||||||
|
// 'У вас нет таких консультаций',
|
||||||
|
// style: TextStyles.textMMedium,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
@@ -5,21 +5,22 @@ import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
|||||||
import 'package:eatvio_app/core/utils/localization_utils.dart';
|
import 'package:eatvio_app/core/utils/localization_utils.dart';
|
||||||
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
|
||||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/cubit/consultations_archive_cubit.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_cubit.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/cubit/consultations_archive_state.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/cubit/archive/consultations_archive_state.dart';
|
||||||
import 'package:eatvio_app/features/consultations_archive/presentation/status_widget.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/period_enum.dart';
|
||||||
|
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/widgets/status_widget.dart';
|
||||||
import 'package:eatvio_app/generated/l10n.dart';
|
import 'package:eatvio_app/generated/l10n.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class ConsultationsArchive extends StatefulWidget {
|
class ConsultationsArchiveScreen extends StatefulWidget {
|
||||||
const ConsultationsArchive({super.key});
|
const ConsultationsArchiveScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ConsultationsArchive> createState() => _ConsultationsArchiveState();
|
State<ConsultationsArchiveScreen> createState() => _ConsultationsArchiveScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ConsultationsArchiveState extends State<ConsultationsArchive> {
|
class _ConsultationsArchiveScreenState extends State<ConsultationsArchiveScreen> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final s = S.of(context);
|
final s = S.of(context);
|
||||||
@@ -46,7 +46,7 @@ class NotificationWidget extends StatelessWidget {
|
|||||||
ChosenPlanTomorrowReminderToConsultantNotification() => _ChosenPlanTomorrowReminderToConsultantWidget(
|
ChosenPlanTomorrowReminderToConsultantNotification() => _ChosenPlanTomorrowReminderToConsultantWidget(
|
||||||
notification: notification as ChosenPlanTomorrowReminderToConsultantNotification,
|
notification: notification as ChosenPlanTomorrowReminderToConsultantNotification,
|
||||||
),
|
),
|
||||||
PlanSubscriptionPaidToAuthorNotification() => throw _PlanSubscriptionPaidToAuthorWidget(
|
PlanSubscriptionPaidToAuthorNotification() => _PlanSubscriptionPaidToAuthorWidget(
|
||||||
notification: notification as PlanSubscriptionPaidToAuthorNotification,
|
notification: notification as PlanSubscriptionPaidToAuthorNotification,
|
||||||
),
|
),
|
||||||
ChosenPlanFinishedToConsultantNotification() => _ChosenPlanFinishedToConsultantWidget(
|
ChosenPlanFinishedToConsultantNotification() => _ChosenPlanFinishedToConsultantWidget(
|
||||||
|
|||||||
Reference in New Issue
Block a user