forked from eatvio/eatvio_app
fix(settings): return to settings with success toast after saving
related to: #989
This commit is contained in:
@@ -11,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:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class GeneralInfoScreen extends StatefulWidget {
|
||||
final SettingsEntity settingsEntity;
|
||||
@@ -256,6 +257,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
|
||||
});
|
||||
if (detailsSaved && settingsSaved) {
|
||||
showSuccessToast(S.of(context).data_saved_successfully);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
||||
@@ -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:flutter/material.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(
|
||||
|
||||
@@ -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:flutter/material.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(
|
||||
|
||||
@@ -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:flutter/material.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(
|
||||
|
||||
@@ -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:flutter/material.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(
|
||||
|
||||
Reference in New Issue
Block a user