diff --git a/lib/core/const.dart b/lib/core/const.dart index 31c47e9c..51e7feff 100644 --- a/lib/core/const.dart +++ b/lib/core/const.dart @@ -1,5 +1,8 @@ -String baseUrl = 'https://eatvio.ru'; -// String baseUrl = 'https://dev2.eatvio.com'; +void qwe() { + print('change to prod url'); +} +// String baseUrl = 'https://eatvio.ru'; +String baseUrl = 'https://dev2.eatvio.com'; const List durationValues = [7, 14, 21]; diff --git a/lib/core/locator_service.dart b/lib/core/locator_service.dart index cd8731a3..cdf658ca 100644 --- a/lib/core/locator_service.dart +++ b/lib/core/locator_service.dart @@ -122,8 +122,14 @@ Future init() async { sl.registerFactory(() => PlansCubit(feedRepository: sl(), planRepository: sl())); sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl(), consultantRepository: sl())); sl.registerFactory(() => RegisterConsultantCubit(consultantRepository: sl())); - sl.registerFactory( - () => DiaryCubit(chatRepository: sl(), diaryRepository: sl(), glossaryRepository: sl(), profileRepository: sl(), dietRepository: sl())); + sl.registerFactory(() => DiaryCubit( + chatRepository: sl(), + diaryRepository: sl(), + glossaryRepository: sl(), + profileRepository: sl(), + dietRepository: sl(), + settingsRepository: sl(), + )); sl.registerFactory(() => AboutDietCubit(dietsRepository: sl(), profileRepository: sl())); sl.registerFactory(() => BlogPostCreateCubit(blogPostRepository: sl())); sl.registerFactory(() => SubCubit(profileRepository: sl())); diff --git a/lib/features/diary/presentation/bloc/diary_cubit.dart b/lib/features/diary/presentation/bloc/diary_cubit.dart index afe81398..7216ed1c 100644 --- a/lib/features/diary/presentation/bloc/diary_cubit.dart +++ b/lib/features/diary/presentation/bloc/diary_cubit.dart @@ -14,6 +14,7 @@ import 'package:eatvio_app/features/diets/repositories/diet_repository.dart'; import 'package:eatvio_app/features/glossary/models/glossary_model.dart'; import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart'; import 'package:eatvio_app/features/profile/repositories/profile_repository.dart'; +import 'package:eatvio_app/features/settings/repositories/service_repository.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class DiaryCubit extends Cubit { @@ -25,14 +26,16 @@ class DiaryCubit extends Cubit { final ProfileRepository profileRepository; final DietRepository dietRepository; final ChatRepository chatRepository; + final SettingsRepository settingsRepository; int? diaryId; - DiaryCubit( - {required this.chatRepository, - required this.diaryRepository, - required this.glossaryRepository, - required this.profileRepository, - required this.dietRepository}) - : super(const DiaryState.loading()) { + DiaryCubit({ + required this.chatRepository, + required this.diaryRepository, + required this.glossaryRepository, + required this.profileRepository, + required this.dietRepository, + required this.settingsRepository, + }) : super(const DiaryState.loading()) { today = DateTime.now(); selectedDay = today; diaryRepository.forceFetchStream.listen((_) { @@ -160,11 +163,16 @@ class DiaryCubit extends Cubit { } try { final DiaryDayModel diaryDay; + bool isMoodEnabled = false; + bool isWakeUpAndRetireTimeEnabled = false; if (diaryId != null) { diaryDay = await diaryRepository.getDiaryDay(diaryId); } else { final stringDate = selectedDay.format('yyyy-MM-dd'); diaryDay = await diaryRepository.getDiaryByDate(stringDate); + final profileSettings = await settingsRepository.getProfileSettings(); + isMoodEnabled = profileSettings.isMoodFillable; + isWakeUpAndRetireTimeEnabled = profileSettings.isBedtimeFillable; } ConsultantReviewModel? consultantReview; int? planDuration; @@ -197,6 +205,8 @@ class DiaryCubit extends Cubit { chosenPlanCurrentDay: currentPlanDay, chosenPlanDuration: planDuration, chosenPlanName: planName, + isMoodEnabled: isMoodEnabled, + isWakeUpAndRetireEnabled: isWakeUpAndRetireTimeEnabled ), ); } catch (e, st) { diff --git a/lib/features/diary/presentation/bloc/diary_state.dart b/lib/features/diary/presentation/bloc/diary_state.dart index 828831d3..d5e8e39d 100644 --- a/lib/features/diary/presentation/bloc/diary_state.dart +++ b/lib/features/diary/presentation/bloc/diary_state.dart @@ -27,6 +27,8 @@ abstract class DiaryState with _$DiaryState { @Default(false) bool isConsultantView, @Default(false) bool isDiaryFinished, @Default(false) bool isDiaryCommented, + @Default(false) bool isWakeUpAndRetireEnabled, + @Default(false) bool isMoodEnabled, }) = DiaryStateLoaded; const factory DiaryState.loadedTomorrowWithDiet({ diff --git a/lib/features/diary/presentation/pages/diary_screen.dart b/lib/features/diary/presentation/pages/diary_screen.dart index 2f80c22e..fb1987ef 100644 --- a/lib/features/diary/presentation/pages/diary_screen.dart +++ b/lib/features/diary/presentation/pages/diary_screen.dart @@ -80,13 +80,17 @@ class DiaryScreenContent extends StatelessWidget { return Scaffold( backgroundColor: Colors.grey.shade200, - appBar: AppBar( - title: Text( - state is DiaryStateLoaded ? DateTime.parse(state.diary.date).toLocal().format('d MMMM') : '', - style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), - ), - centerTitle: true, - ), + appBar: diaryId == null + ? AppBar( + toolbarHeight: 0, + ) + : AppBar( + title: Text( + state is DiaryStateLoaded ? DateTime.parse(state.diary.date).toLocal().format('d MMMM') : '', + style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), + ), + centerTitle: true, + ), body: SingleChildScrollView( padding: const EdgeInsets.only(bottom: 16, top: 8), physics: const BouncingScrollPhysics(), @@ -101,13 +105,13 @@ class DiaryScreenContent extends StatelessWidget { ], if (state is DiaryStateLoaded) WakeupAndRetireWidget( - showRetire: state.diary.typeOfDiary.hasChosenPlan, + isEnabled: state.diary.typeOfDiary.hasChosenPlan || state.isConsultantView || state.isWakeUpAndRetireEnabled, disable: state.isConsultantView || state.isDiaryFinished || state.isDiaryCommented, ), const SizedBox(height: 12), if (state is DiaryStateLoaded) MealWidget( - showMood: state.diary.typeOfDiary.hasChosenPlan, + showMood: state.diary.typeOfDiary.hasChosenPlan || state.isConsultantView || state.isMoodEnabled, showAddButton: !state.isConsultantView && !state.isDiaryFinished && !state.isDiaryCommented, ), if (state is DiaryStateLoadedTomorrowWithDiet) diff --git a/lib/features/diary/presentation/widgets/calories_chart_widget.dart b/lib/features/diary/presentation/widgets/calories_chart_widget.dart index 6cdc6e86..817508af 100644 --- a/lib/features/diary/presentation/widgets/calories_chart_widget.dart +++ b/lib/features/diary/presentation/widgets/calories_chart_widget.dart @@ -30,7 +30,7 @@ class CaloriesChartWidget extends StatelessWidget { context: context, builder: (context) => const AlertDialog( content: Text( - 'График отображает сколько калорий вам нужно ежедневно для похуденияи поддержания веса, согласно формуле Харриса-Бенедикта.\nИзменить коэффициент физической нагрузки можно в настройках.', + 'График отображает сколько калорий Вам нужно ежедневно для поддержания веса, согласно формуле Харриса-Бенедикта. Изменить коэффициент физической нагрузки можно в настройках', style: TextStyle( fontWeight: FontWeight.w500, color: Color(0xFF323F4B), diff --git a/lib/features/diary/presentation/widgets/meal_widget.dart b/lib/features/diary/presentation/widgets/meal_widget.dart index b5bd196a..ce71ef66 100644 --- a/lib/features/diary/presentation/widgets/meal_widget.dart +++ b/lib/features/diary/presentation/widgets/meal_widget.dart @@ -59,7 +59,6 @@ class _MealWidgetState extends State { ), const SizedBox(height: 12), const TimeOfMealPickerWidget(), - const ChosenDietWidget(), const ChosenPlanWidget(), const ProductsListWidget(), diff --git a/lib/features/diary/presentation/widgets/wakeup_and_retire_widget.dart b/lib/features/diary/presentation/widgets/wakeup_and_retire_widget.dart index 8c9f6028..1dbe9925 100644 --- a/lib/features/diary/presentation/widgets/wakeup_and_retire_widget.dart +++ b/lib/features/diary/presentation/widgets/wakeup_and_retire_widget.dart @@ -8,8 +8,8 @@ import 'package:flutter_svg/flutter_svg.dart'; import '../../../../core/theme/theme_helper.dart'; class WakeupAndRetireWidget extends StatefulWidget { - const WakeupAndRetireWidget({super.key, required this.showRetire, this.disable = false}); - final bool showRetire; + const WakeupAndRetireWidget({super.key, required this.isEnabled, this.disable = false}); + final bool isEnabled; final bool disable; @override State createState() => _WakeupAndRetireWidgetState(); @@ -94,6 +94,9 @@ class _WakeupAndRetireWidgetState extends State { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { + if (!widget.isEnabled) { + return const SizedBox.shrink(); + } if (state is DiaryStateLoaded) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 4), @@ -157,67 +160,65 @@ class _WakeupAndRetireWidgetState extends State { ), ), ), - if (widget.showRetire) ...[ - const SizedBox(width: 8), - Expanded( - child: Material( - borderRadius: BorderRadius.circular(12), - color: Colors.white, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 12, - ), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset('assets/icons/retire.svg'), - const SizedBox(width: 8), - const Text( - 'Уход ко сну', - style: TextStyle( - fontSize: 16, + const SizedBox(width: 8), + Expanded( + child: Material( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 12, + ), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset('assets/icons/retire.svg'), + const SizedBox(width: 8), + const Text( + 'Уход ко сну', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + height: 1, + ), + ), + ], + ), + const SizedBox(height: 8), + InkWell( + onTap: widget.disable ? null : () => showTimePicker(state.diary.id, false), + borderRadius: BorderRadius.circular(100), + child: Ink( + height: 32, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + color: const Color(0xFFF1F2F6), + ), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + state.diary.retire.toString().substring( + 0, + state.diary.retire.toString().length - 3, + ), + style: const TextStyle( + color: Color(0xFF6D6F71), + fontSize: 17, fontWeight: FontWeight.w500, - height: 1, - ), - ), - ], - ), - const SizedBox(height: 8), - InkWell( - onTap: widget.disable ? null : () => showTimePicker(state.diary.id, false), - borderRadius: BorderRadius.circular(100), - child: Ink( - height: 32, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100), - color: const Color(0xFFF1F2F6), - ), - child: Container( - alignment: Alignment.center, - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text( - state.diary.retire.toString().substring( - 0, - state.diary.retire.toString().length - 3, - ), - style: const TextStyle( - color: Color(0xFF6D6F71), - fontSize: 17, - fontWeight: FontWeight.w500, - ), ), ), ), ), - ], - ), + ), + ], ), ), ), - ] + ), ], ), );