forked from eatvio/eatvio_app
fix(settings): Issue-256
This commit is contained in:
@@ -32,6 +32,24 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
late bool bedTimeSwitchState;
|
||||
late bool moodSwitchState;
|
||||
|
||||
void _showConsultationWarning() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Предупреждение'),
|
||||
content: const Text('Во время консультации этот параметр нельзя отключить'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Понятно'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<SettingsCubit>(
|
||||
@@ -158,16 +176,24 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
_tile(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
onTap: () {
|
||||
if (state.hasActiveConsultation && !moodSwitchState) {
|
||||
_showConsultationWarning();
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
moodSwitchState = !moodSwitchState;
|
||||
});
|
||||
settingsCubit.updateProfileSettings(profileSettingsModel: state.profileSettings.copyWith(isMoodFillable: moodSwitchState));
|
||||
},
|
||||
title: 'Указывать “настроение” в заполнение дневника',
|
||||
title: 'Указывать "настроение" в заполнение дневника',
|
||||
trailing: CupertinoSwitch(
|
||||
value: moodSwitchState,
|
||||
activeTrackColor: appTheme.blueA400,
|
||||
onChanged: (newValue) {
|
||||
if (state.hasActiveConsultation && !newValue) {
|
||||
_showConsultationWarning();
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
moodSwitchState = newValue;
|
||||
});
|
||||
@@ -179,16 +205,25 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
_tile(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
onTap: () {
|
||||
|
||||
if (state.hasActiveConsultation && !bedTimeSwitchState) {
|
||||
_showConsultationWarning();
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
bedTimeSwitchState = !bedTimeSwitchState;
|
||||
});
|
||||
settingsCubit.updateProfileSettings(profileSettingsModel: state.profileSettings.copyWith(isBedtimeFillable: bedTimeSwitchState));
|
||||
},
|
||||
title: 'Указывать “отход ко сну” в заполнение дневника',
|
||||
title: 'Указывать "отход ко сну" в заполнение дневника',
|
||||
trailing: CupertinoSwitch(
|
||||
value: bedTimeSwitchState,
|
||||
activeTrackColor: appTheme.blueA400,
|
||||
onChanged: (newValue) {
|
||||
if (state.hasActiveConsultation && !newValue) {
|
||||
_showConsultationWarning();
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
bedTimeSwitchState = newValue;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user