merge upstream

This commit is contained in:
2026-11-23 11:19:45 +00:00
38 changed files with 2437 additions and 503 deletions

View File

@@ -30,6 +30,7 @@ import 'package:eatvio_app/features/chat/utils/chat_counterpart_utils.dart';
import 'package:eatvio_app/features/consultations/utils/consultation_progress_mapper.dart';
import 'package:eatvio_app/features/order_info/presentation/info_by_order_screen.dart';
import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
import 'package:eatvio_app/features/user_details/presentation/user_details_screen.dart';
import 'package:eatvio_app/features/video_calls/managers/video_call_manager.dart';
import 'package:eatvio_app/features/video_calls/presentation/pages/video_call_screen.dart';
@@ -72,6 +73,10 @@ class _ChatScreenState extends State<ChatScreen> {
String? get conversationUuid => _effectiveUuid ?? widget.uuid;
bool _canStartVideoCall(ChosenPlanModel? chosenPlan) {
return chosenPlan?.chosenPlanState.allowsVideoCall ?? false;
}
void _onHide() {
chatRoomCubit.cancelTimer();
}
@@ -205,6 +210,7 @@ class _ChatScreenState extends State<ChatScreen> {
chosenPlan != null &&
chosenPlan.chosenPlanState !=
ChosenPlanStateEnum.stateCanceledByTheInitiator;
final showVideoCallButton = _canStartVideoCall(chosenPlan);
return Scaffold(
resizeToAvoidBottomInset: true,
@@ -300,12 +306,14 @@ class _ChatScreenState extends State<ChatScreen> {
),
),
actions: [
Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
child: _ChatHeaderVideoCallButton(
onPressed: () => _openVideoCall(context, state, chatCounterpart),
if (showVideoCallButton)
Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
child: _ChatHeaderVideoCallButton(
onPressed: () =>
_openVideoCall(context, state, chatCounterpart),
),
),
),
],
),
body: SafeArea(
@@ -324,8 +332,7 @@ class _ChatScreenState extends State<ChatScreen> {
InfoByOrderScreen.path,
extra: {
'planId': chosenPlan?.id,
'customerSlug':
state.chatRoom.users.receiver.slug,
'customerSlug': state.chatRoom.users.receiver.slug,
},
);
return;
@@ -1018,7 +1025,8 @@ class _ChatScreenState extends State<ChatScreen> {
required bool? amIConsultant,
}) {
if (message.type == ChatMessageType.videoCallStarted &&
!isCurrentUserAuthor) {
!isCurrentUserAuthor &&
_canStartVideoCall(state.chatRoom.chosenPlan)) {
return VideoCallChatMessageWidget(
text: message.data.trim(),
sendTime: message.updatedAt,

View File

@@ -14,6 +14,7 @@ import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
import 'package:eatvio_app/features/diary/repositories/diary_repository.dart';
import 'package:eatvio_app/features/diets/repositories/diet_repository.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.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';
@@ -38,6 +39,8 @@ class DiaryCubit extends Cubit<DiaryState> {
final ChatRepository chatRepository;
final SettingsRepository settingsRepository;
int? diaryId;
int _fetchGeneration = 0;
DiaryCubit({
required this.chatRepository,
required this.diaryRepository,
@@ -61,14 +64,21 @@ class DiaryCubit extends Cubit<DiaryState> {
selectedDay = date;
}
bool _isCurrentFetch(int generation) => generation == _fetchGeneration;
Future<bool> setSelectedDay(DateTime day) async {
final prevDay = selectedDay;
final prevMeal = selectedMeal;
selectedDay = day;
selectedMeal = 1;
final canSelect = await fetchDiaryV2(needLoading: true);
final generation = ++_fetchGeneration;
final canSelect = await fetchDiaryV2(needLoading: true, generation: generation);
if (!canSelect) {
if (!_isCurrentFetch(generation)) {
return false;
}
if (!canSelect && state is! DiaryStateError) {
selectedDay = prevDay;
selectedMeal = prevMeal;
}
@@ -76,22 +86,33 @@ class DiaryCubit extends Cubit<DiaryState> {
return canSelect;
}
Future<bool> fetchDiaryV2({bool needLoading = false, int? diaryId}) async {
Future<bool> fetchDiaryV2({bool needLoading = false, int? diaryId, int? generation}) async {
final request = generation ?? ++_fetchGeneration;
final requestedDay = selectedDay;
final currentState = state;
try {
if (!_isCurrentFetch(request)) {
return false;
}
if (needLoading) {
emit(const DiaryState.loading());
}
if (diaryId != null) {
final diaryDayById = await diaryRepository.getDiaryDay(diaryId);
if (!_isCurrentFetch(request)) {
return false;
}
final diaryEntity = diaryDayById.toEntity();
if (diaryEntity != null) {
setDiary(diaryDay: diaryEntity, diaryId: diaryId);
return true;
await setDiary(diaryDay: diaryEntity, diaryId: diaryId, generation: request);
return _isCurrentFetch(request);
}
}
final diaryDay = await getDiary();
final diaryDay = await getDiary(day: requestedDay);
if (!_isCurrentFetch(request)) {
return false;
}
if (diaryDay == null) {
emit(const DiaryState.error(errorMessage: 'Diary not found'));
return true;
@@ -99,16 +120,26 @@ class DiaryCubit extends Cubit<DiaryState> {
final diaryEntity = diaryDay.toEntity();
if (diaryEntity != null) {
setDiary(diaryDay: diaryEntity, diaryId: diaryId);
return true;
await setDiary(diaryDay: diaryEntity, diaryId: diaryId, generation: request);
return _isCurrentFetch(request);
}
if (diaryDay.typeOfDiary.hasChosenDiet == true && diaryDay.typeOfDiary.diaryState == null) {
setDiaryForDietOnly(diaryDay.toDiaryFutureDayEntity());
return true;
if (_isUnsavedDietPreview(diaryDay)) {
final shown = await setDiaryForDietOnly(diaryDay.toDiaryFutureDayEntity(), generation: request);
if (!_isCurrentFetch(request)) {
return false;
}
if (!shown && state is DiaryStateLoading) {
emit(currentState);
}
return shown;
}
emit(currentState);
return false;
} catch (e, st) {
if (!_isCurrentFetch(request)) {
return false;
}
await reportFrom(e, st, this);
log(e.toString(), stackTrace: st);
emit(DiaryState.error(errorMessage: e.toString()));
@@ -129,17 +160,18 @@ class DiaryCubit extends Cubit<DiaryState> {
}
}
Future<DiaryDayModel?> getDiary() async {
Future<DiaryDayModel?> getDiary({DateTime? day}) async {
final requestedDay = (day ?? selectedDay).toISO8601WithTimeZoneOffset();
try {
await diaryRepository.createDiaryDay(day: selectedDay.toISO8601WithTimeZoneOffset());
final diaryDay = await diaryRepository.getDiaryDayV2(day: selectedDay.toISO8601WithTimeZoneOffset());
await diaryRepository.createDiaryDay(day: requestedDay);
final diaryDay = await diaryRepository.getDiaryDayV2(day: requestedDay);
return diaryDay;
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString(), stackTrace: st);
if (e is DioException) {
if (e.response?.statusCode == 422) {
final diaryDay = await diaryRepository.getDiaryDayV2(day: selectedDay.toISO8601WithTimeZoneOffset());
final diaryDay = await diaryRepository.getDiaryDayV2(day: requestedDay);
return diaryDay;
}
}
@@ -157,92 +189,83 @@ class DiaryCubit extends Cubit<DiaryState> {
}
}
Future<bool> setDiaryForDietOnly(DiaryFutureDietDayEntity diaryDay) async {
if (!diaryDay.typeOfDiary.hasChosenDiet) {
bool _isUnsavedDietPreview(DiaryDayModel diaryDay) {
final diaryState = diaryDay.typeOfDiary.diaryState;
final dayNotStarted = diaryState == null || diaryState == DiaryStateEnum.init;
return diaryDay.typeOfDiary.hasChosenDiet && dayNotStarted;
}
Future<bool> setDiaryForDietOnly(DiaryFutureDietDayEntity diaryDay, {int? generation}) async {
final dietId = diaryDay.diet?.id;
final dayOfChosenDiet = diaryDay.dayOfChosenDiet;
if (!diaryDay.typeOfDiary.hasChosenDiet || dietId == null || dayOfChosenDiet == null) {
return false;
}
if (generation != null && !_isCurrentFetch(generation)) {
return false;
}
emit(const DiaryState.loading());
try {
if (diaryDay.diet?.id != null && diaryDay.dayOfChosenDiet != null) {
final diet = await dietRepository.getDiet((diaryDay.diet?.id)!);
final meals = diet.dailySchedule[diaryDay.dayOfChosenDiet];
final firstMealPortions = meals?[1]?.values.map((elem) {
return PortionModel(
id: 0,
productName: elem.name,
quantity: elem.quantity,
portion: elem.portion.getValue(),
fromDiet: true,
portionState: PortionState.filledDiet,
);
}).toList();
final diet = await dietRepository.getDiet(dietId);
if (generation != null && !_isCurrentFetch(generation)) {
return false;
}
final meals = diet.dailySchedule[dayOfChosenDiet];
List<PortionModel> portionsOfMeal(int mealNumber) {
return meals?[mealNumber]?.values.map(_portionFromDiet).toList() ?? [];
}
final secondMealPortions = meals?[2]?.values.map((elem) {
return PortionModel(
id: 0,
productName: elem.name,
quantity: elem.quantity,
portion: elem.portion.getValue(),
fromDiet: true,
portionState: PortionState.filledDiet,
);
}).toList();
MealModel meal(int mealNumber) {
return MealModel(id: 0, time: '0', typeNumber: mealNumber, satiety: 0, mood: 0, portions: portionsOfMeal(mealNumber), photos: []);
}
final thirdMealPortions = meals?[3]?.values.map((elem) {
return PortionModel(
id: 0,
productName: elem.name,
quantity: elem.quantity,
portion: elem.portion.getValue(),
fromDiet: true,
portionState: PortionState.filledDiet,
);
}).toList();
final fourthMealPortions = meals?[4]?.values.map((elem) {
return PortionModel(
id: 0,
productName: elem.name,
quantity: elem.quantity,
portion: elem.portion.getValue(),
fromDiet: true,
portionState: PortionState.filledDiet,
);
}).toList();
final fifthMealPortions = meals?[5]?.values.map((elem) {
return PortionModel(
id: 0,
productName: elem.name,
quantity: elem.quantity,
portion: elem.portion.getValue(),
fromDiet: true,
portionState: PortionState.filledDiet,
);
}).toList();
final firstMeal = MealModel(id: 0, time: '0', typeNumber: 1, satiety: 0, mood: 0, portions: firstMealPortions ?? [], photos: []);
final secondMeal = MealModel(id: 0, time: '0', typeNumber: 2, satiety: 0, mood: 0, portions: secondMealPortions ?? [], photos: []);
final thirdMeal = MealModel(id: 0, time: '0', typeNumber: 3, satiety: 0, mood: 0, portions: thirdMealPortions ?? [], photos: []);
final fourthMeal = MealModel(id: 0, time: '0', typeNumber: 4, satiety: 0, mood: 0, portions: fourthMealPortions ?? [], photos: []);
final fifthMeal = MealModel(id: 0, time: '0', typeNumber: 5, satiety: 0, mood: 0, portions: fifthMealPortions ?? [], photos: []);
emit(
DiaryState.loadedTomorrowWithDiet(
diary: diaryDay.copyWith(meals: [firstMeal, secondMeal, thirdMeal, fourthMeal, fifthMeal]),
diary: diaryDay.copyWith(meals: [meal(1), meal(2), meal(3), meal(4), meal(5)]),
selectedDay: selectedDay,
selectedMeal: selectedMeal,
),
);
return true;
}
return false;
return true;
} catch (e, st) {
if (generation != null && !_isCurrentFetch(generation)) {
return false;
}
await reportFrom(e, st, this);
emit(DiaryState.error(errorMessage: e.toString()));
return false;
}
}
Future<void> setDiary({int? diaryId, required DiaryDayEntity diaryDay}) async {
PortionModel _portionFromDiet(DailySchedule elem) {
final nutrition = elem.dailyNutrition;
final per100 = elem.portion == Portion.grams && elem.quantity > 0 ? 100 / elem.quantity : 1.0;
return PortionModel(
id: 0,
productNutritionalValueId: elem.productNutritionalValueId,
productCaloriesInfo: nutrition == null
? null
: ProductCaloriesInfoModel(
id: elem.productNutritionalValueId ?? 0,
productName: elem.name,
calories: nutrition.energy * per100,
proteins: nutrition.proteins * per100,
fats: nutrition.fats * per100,
carbohydrates: nutrition.carbohydrates * per100,
energyOnPortion: nutrition.energy,
proteinsOnPortion: nutrition.proteins,
fatsOnPortion: nutrition.fats,
carbohydratesOnPortion: nutrition.carbohydrates,
),
productName: elem.name,
quantity: elem.quantity,
portion: elem.portion.getValue(),
fromDiet: true,
portionState: PortionState.filledDiet,
);
}
Future<void> setDiary({int? diaryId, required DiaryDayEntity diaryDay, int? generation}) async {
this.diaryId ??= diaryId;
final isConsultantView = this.diaryId != null;
try {
@@ -270,6 +293,9 @@ class DiaryCubit extends Cubit<DiaryState> {
currentPlanDay = consultantReview.currentPlanDay;
}
final nutrition = await getNutrition(diaryDay.id);
if (generation != null && !_isCurrentFetch(generation)) {
return;
}
final isDiaryFinished = diaryDay.typeOfDiary.diaryState == DiaryStateEnum.finished || diaryDay.typeOfDiary.diaryState == DiaryStateEnum.lastDayFinished;
@@ -295,6 +321,9 @@ class DiaryCubit extends Cubit<DiaryState> {
),
);
} catch (e, st) {
if (generation != null && !_isCurrentFetch(generation)) {
return;
}
await reportFrom(e, st, this);
log(e.toString(), stackTrace: st);
emit(DiaryState.error(errorMessage: e.toString()));

View File

@@ -22,12 +22,26 @@ class _CalendarWidgetState extends State<CalendarWidget> {
CalendarFormat _calendarFormat = CalendarFormat.week;
DateTime _focusedDay = DateTime.now();
DateTime _selectedDay = DateTime.now();
DateTime? _dayFromState(DiaryState state) {
if (state is DiaryStateLoaded) {
return state.selectedDay;
}
if (state is DiaryStateLoadedTomorrowWithDiet) {
return state.selectedDay;
}
return null;
}
@override
void initState() {
super.initState();
final selected = _dayFromState(context.read<DiaryCubit>().state);
if (widget.date != null) {
_selectedDay = widget.date!;
_focusedDay = widget.date!;
} else if (selected != null) {
_selectedDay = selected;
_focusedDay = selected;
}
}
@@ -47,9 +61,11 @@ class _CalendarWidgetState extends State<CalendarWidget> {
final daysOfWeekHeight = _scaledDaysOfWeekHeight(context);
return BlocConsumer<DiaryCubit, DiaryState>(
listener: (BuildContext context, DiaryState state) {
if (state is DiaryStateLoaded) {
final selected = _dayFromState(state);
if (selected != null) {
setState(() {
_selectedDay = state.selectedDay;
_selectedDay = selected;
_focusedDay = selected;
});
}
},
@@ -77,8 +93,12 @@ class _CalendarWidgetState extends State<CalendarWidget> {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
final canOpenNextDay = await context.read<DiaryCubit>().setSelectedDay(selectedDay);
if (!canOpenNextDay && context.mounted) {
final cubit = context.read<DiaryCubit>();
final canOpenNextDay = await cubit.setSelectedDay(selectedDay);
if (!context.mounted || cubit.state is DiaryStateError) {
return;
}
if (!canOpenNextDay) {
showErrorDialog(context, title: s.want_to_see_tomorrow, description: s.can_not_see_next_day);
setState(() {
_selectedDay = previousSelectedDay;

View File

@@ -88,6 +88,18 @@ enum ChosenPlanStateEnum {
}
}
bool get allowsVideoCall {
switch (this) {
case ChosenPlanStateEnum.stateCanceledByTheInitiator:
case ChosenPlanStateEnum.statePaymentFailed:
case ChosenPlanStateEnum.stateDone:
case ChosenPlanStateEnum.stateChargeWasCollected:
return false;
default:
return true;
}
}
static List<ChosenPlanStateEnum> getActiveStates() {
return [
ChosenPlanStateEnum.statePaid,

View File

@@ -80,29 +80,33 @@ class SettingsCubit extends Cubit<SettingsState> {
}
}
Future<void> updateProfileDetails({
Future<bool> updateProfileDetails({
required ProfileDetailsModel profileDetailsModel,
}) async {
try {
await settingsRepository.updateProfileDetails(
profileDetailsModel: profileDetailsModel,
);
return true;
} catch (e, st) {
await reportFrom(e, st, this);
return false;
} finally {
await init();
}
}
Future<void> updateProfileSettings({
Future<bool> updateProfileSettings({
required ProfileSettingsModel profileSettingsModel,
}) async {
try {
await settingsRepository.updateProfileSettings(
profileSettingsModel: profileSettingsModel,
);
return true;
} catch (e, st) {
await reportFrom(e, st, this);
return false;
} finally {
await init();
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_drop_down.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
@@ -10,6 +11,7 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:cupertino_ui/cupertino_ui.dart';
import 'package:go_router/go_router.dart';
class GeneralInfoScreen extends StatefulWidget {
final SettingsEntity settingsEntity;
@@ -233,7 +235,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
setState(() {
isLoading = true;
});
await widget.settingsEntity.settingsCubit.updateProfileDetails(
final detailsSaved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
firstName: firstNameController.text,
lastName: lastNameController.text,
@@ -244,7 +246,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
lang: languageController.text,
),
);
await widget.settingsEntity.settingsCubit.updateProfileSettings(
final settingsSaved = await widget.settingsEntity.settingsCubit.updateProfileSettings(
profileSettingsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith(
isPublicProfile: isPublicProfile.value,
),
@@ -253,6 +255,10 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
setState(() {
isLoading = false;
});
if (detailsSaved && settingsSaved) {
showSuccessToast(S.of(context).data_saved_successfully);
context.pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:go_router/go_router.dart';
@@ -137,8 +138,8 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
onTap: () async {
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
aboutAlergy: aboutAllergyController.text,
aboutTakingPils: aboutTakingPillsController.text,
@@ -148,7 +149,11 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
additionalInfo: additionalInfoController.text,
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -2,6 +2,8 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -200,7 +202,7 @@ class _PhysicalActivityScreenState extends State<PhysicalActivityScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
onTap: () async {
late final double activityCoefficient;
switch (_physicalActivity) {
case PhysicalActivity.minimum:
@@ -221,12 +223,16 @@ class _PhysicalActivityScreenState extends State<PhysicalActivityScreen> {
default:
break;
}
widget.settingsEntity.settingsCubit.updateProfileDetails(
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
activityCoefficient: activityCoefficient,
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
@@ -108,8 +109,8 @@ class _PhysicalFormScreenState extends State<PhysicalFormScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
onTap: () async {
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
chestCircumference: int.parse(chestCircumferenceController.text),
waistCircumference: int.parse(waistCircumferenceController.text),
@@ -118,7 +119,11 @@ class _PhysicalFormScreenState extends State<PhysicalFormScreen> {
weight: double.parse(weightController.text),
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
@@ -114,8 +115,8 @@ class _PressureScreenState extends State<PressureScreen> {
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
onTap: () async {
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
bloodPressureUp: int.parse(bloodPressureUpController.text),
bloodPressureDown: int.parse(bloodPressureDownController.text),
@@ -123,7 +124,11 @@ class _PressureScreenState extends State<PressureScreen> {
hasHypo: hypo.value,
),
);
GoRouter.of(context).pop();
if (!mounted) return;
if (saved) {
showSuccessToast(S.of(context).data_saved_successfully);
GoRouter.of(context).pop();
}
},
borderRadius: BorderRadius.circular(20),
child: Ink(

View File

@@ -61,6 +61,9 @@ class _VideoCallRecordingsViewState extends State<_VideoCallRecordingsView> {
return;
}
final position = _scrollController.position;
if (position.maxScrollExtent <= 0 || position.pixels < 0) {
return;
}
if (position.pixels >= position.maxScrollExtent - 200) {
context.read<VideoCallRecordingsCubit>().loadNextPage();
}
@@ -170,14 +173,29 @@ class _VideoCallRecordingsViewState extends State<_VideoCallRecordingsView> {
}
if (state.recordings.isEmpty) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text(
s.video_call_recordings_empty,
textAlign: TextAlign.center,
style: TextStyles.textMMedium.copyWith(color: appTheme.blueGray400),
),
return RefreshIndicator(
onRefresh: () => context.read<VideoCallRecordingsCubit>().load(refresh: true),
child: LayoutBuilder(
builder: (context, constraints) {
return ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: [
ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Text(
s.video_call_recordings_empty,
textAlign: TextAlign.center,
style: TextStyles.textMMedium.copyWith(color: appTheme.blueGray400),
),
),
),
),
],
);
},
),
);
}
@@ -186,6 +204,7 @@ class _VideoCallRecordingsViewState extends State<_VideoCallRecordingsView> {
onRefresh: () => context.read<VideoCallRecordingsCubit>().load(refresh: true),
child: ListView.separated(
controller: _scrollController,
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),
itemCount: state.recordings.length + (state.isLoadingMore ? 1 : 0),
separatorBuilder: (_, _) => const SizedBox(height: 16),

View File

@@ -8,7 +8,7 @@ class PublicDownloadsSaver {
const PublicDownloadsSaver();
/// Имя папки приложения в Загрузках / Files.
static const appFolderName = 'Itvio';
static const appFolderName = 'Eatvio';
Future<String> saveToDownloads({
required String sourcePath,

View File

@@ -19,7 +19,7 @@ class VideoCallRecordingFileService {
final Dio dio;
final PublicDownloadsSaver downloadsSaver;
/// Скачивает запись и сохраняет в `Загрузки/Itvio` (Android)
/// Скачивает запись и сохраняет в `Загрузки/Eatvio` (Android)
/// или Documents приложения (iOS, видно в Files).
Future<String> downloadRecordingFile({
required String fileUrl,

View File

@@ -354,6 +354,9 @@ class MessageLookup extends MessageLookupByLibrary {
"customer_price": MessageLookupByLibrary.simpleMessage(
"Цена для покупателя",
),
"data_saved_successfully": MessageLookupByLibrary.simpleMessage(
"Data saved successfully",
),
"date_has_ben_set": MessageLookupByLibrary.simpleMessage(
"Дата старта начала консультации установлена",
),
@@ -1201,7 +1204,7 @@ class MessageLookup extends MessageLookupByLibrary {
),
"video_call_recordings_download_success":
MessageLookupByLibrary.simpleMessage(
"Recording saved to Downloads/Itvio",
"Recording saved to Downloads/Eatvio",
),
"video_call_recordings_download_success_ios":
MessageLookupByLibrary.simpleMessage(

View File

@@ -165,6 +165,9 @@ class MessageLookup extends MessageLookupByLibrary {
"customer_price": MessageLookupByLibrary.simpleMessage(
"Цена для покупателя",
),
"data_saved_successfully": MessageLookupByLibrary.simpleMessage(
"Данные успешно сохранены",
),
"date_of_birth": MessageLookupByLibrary.simpleMessage("Дата рождения"),
"day": MessageLookupByLibrary.simpleMessage("День"),
"days": MessageLookupByLibrary.simpleMessage("дней"),
@@ -696,7 +699,7 @@ class MessageLookup extends MessageLookupByLibrary {
),
"video_call_recordings_download_success":
MessageLookupByLibrary.simpleMessage(
"Запись сохранена в Загрузки/Itvio",
"Запись сохранена в Загрузки/Eatvio",
),
"video_call_recordings_download_success_ios":
MessageLookupByLibrary.simpleMessage(

View File

@@ -134,6 +134,16 @@ class S {
);
}
/// `Data saved successfully`
String get data_saved_successfully {
return Intl.message(
'Data saved successfully',
name: 'data_saved_successfully',
desc: '',
args: [],
);
}
/// `Страна`
String get country {
return Intl.message('Страна', name: 'country', desc: '', args: []);
@@ -5432,10 +5442,10 @@ class S {
);
}
/// `Recording saved to Downloads/Itvio`
/// `Recording saved to Downloads/Eatvio`
String get video_call_recordings_download_success {
return Intl.message(
'Recording saved to Downloads/Itvio',
'Recording saved to Downloads/Eatvio',
name: 'video_call_recordings_download_success',
desc: '',
args: [],

View File

@@ -9,6 +9,7 @@
"last_name": "Фамилия",
"what_is_your_name": "Как вас зовут?",
"date_of_birth": "Дата рождения",
"data_saved_successfully": "Data saved successfully",
"country": "Страна",
"Russia": "Россия",
"city": "Город",
@@ -829,7 +830,7 @@
}
},
"video_call_recordings_download_error": "Could not download the recording. Please try again later.",
"video_call_recordings_download_success": "Recording saved to Downloads/Itvio",
"video_call_recordings_download_success": "Recording saved to Downloads/Eatvio",
"video_call_recordings_download_success_ios": "Recording saved to the Files app",
"video_call_recordings_player_error": "Could not play the recording",
"video_call_recordings_card_title": "Video consultation with a nutrition specialist",

View File

@@ -9,6 +9,7 @@
"last_name": "Фамилия",
"what_is_your_name": "Как вас зовут?",
"date_of_birth": "Дата рождения",
"data_saved_successfully": "Данные успешно сохранены",
"country": "Страна",
"Russia": "Россия",
"city": "Город",
@@ -584,7 +585,7 @@
}
},
"video_call_recordings_download_error": "Не удалось скачать запись. Попробуйте позже.",
"video_call_recordings_download_success": "Запись сохранена в Загрузки/Itvio",
"video_call_recordings_download_success": "Запись сохранена в Загрузки/Eatvio",
"video_call_recordings_download_success_ios": "Запись сохранена в приложении «Файлы»",
"video_call_recordings_player_error": "Не удалось воспроизвести запись",
"video_call_recordings_card_title": "Видеоконсультация со специалистом по питанию",