Files
eatvio_app/lib/features/settings/presentation/pages/other_info_screen.dart

176 lines
6.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class OtherInfoScreen extends StatefulWidget {
final SettingsEntity settingsEntity;
const OtherInfoScreen({
super.key,
required this.settingsEntity,
});
@override
State<OtherInfoScreen> createState() => _OtherInfoScreenState();
}
class _OtherInfoScreenState extends State<OtherInfoScreen> {
final aboutAllergyController = TextEditingController();
final aboutTakingPillsController = TextEditingController();
final aboutSportHobbiesController = TextEditingController();
final favoriteFoodsController = TextEditingController();
final unFavouriteFoodsController = TextEditingController();
final additionalInfoController = TextEditingController();
@override
void initState() {
super.initState();
aboutAllergyController.text = widget.settingsEntity.profileDetailsModel.aboutAlergy;
aboutTakingPillsController.text = widget.settingsEntity.profileDetailsModel.aboutTakingPils;
aboutSportHobbiesController.text = widget.settingsEntity.profileDetailsModel.aboutSportHobbies;
favoriteFoodsController.text = widget.settingsEntity.profileDetailsModel.favoriteFoods;
unFavouriteFoodsController.text = widget.settingsEntity.profileDetailsModel.unfavoriteFoods;
additionalInfoController.text = widget.settingsEntity.profileDetailsModel.additionalInfo;
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Scaffold(
appBar: AppBar(
title: const Text('Прочая информаиця'),
),
bottomSheet: SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.only(bottom: 56), // высота bottomNavigationBar
child: _saveButton(),
),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16) + const EdgeInsets.only(bottom: 120), // 52 (кнопка) + 56 (навигация) + 12 (отступ)
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.allergies_presence),
const SizedBox(height: 4),
CustomTextFormField(
controller: aboutAllergyController,
hintText: 'Например: орехи, мёд и т.д.',
autofocus: true,
minLines: 2,
maxLines: 8,
maxLength: 250,
onChanged: (newValue) {},
),
const SizedBox(height: 16),
Text(s.do_you_take_pills),
const SizedBox(height: 4),
CustomTextFormField(
controller: aboutTakingPillsController,
hintText: s.enter_information,
autofocus: true,
minLines: 2,
maxLength: 250,
maxLines: 8,
onChanged: (newValue) {},
),
const SizedBox(height: 16),
Text(s.your_favorite_sports),
const SizedBox(height: 4),
CustomTextFormField(
controller: aboutSportHobbiesController,
hintText:
"Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!",
autofocus: true,
maxLines: 8,
maxLength: 250,
onChanged: (newValue) {},
),
const SizedBox(height: 16),
Text(s.favorite_foods),
const SizedBox(height: 4),
CustomTextFormField(
controller: favoriteFoodsController,
hintText: s.enter_information,
maxLines: 7,
minLines: 2,
maxLength: 250,
onChanged: (newValue) {},
),
const SizedBox(height: 16),
Text(s.unfavorite_foods),
const SizedBox(height: 4),
CustomTextFormField(
controller: unFavouriteFoodsController,
hintText: s.enter_information,
maxLines: 7,
minLines: 2,
maxLength: 250,
onChanged: (newValue) {},
),
const SizedBox(height: 16),
const Text(
'Дополнительная информация',
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.start,
),
const SizedBox(height: 4),
CustomTextFormField(
controller: additionalInfoController,
maxLength: 250,
hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни",
maxLines: 8,
onChanged: (newValue) {},
),
],
),
),
);
}
InkWell _saveButton() {
return InkWell(
onTap: () {
widget.settingsEntity.settingsCubit.updateProfileDetails(
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
aboutAlergy: aboutAllergyController.text,
aboutTakingPils: aboutTakingPillsController.text,
aboutSportHobbies: aboutSportHobbiesController.text,
favoriteFoods: favoriteFoodsController.text,
unfavoriteFoods: unFavouriteFoodsController.text,
additionalInfo: additionalInfoController.text,
),
);
GoRouter.of(context).pop();
},
borderRadius: BorderRadius.circular(20),
child: Ink(
height: 52,
width: MediaQuery.of(context).size.width - 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: appTheme.blueA400,
),
child: const Center(
child: Text(
'Сохранить',
style: TextStyle(
color: Colors.white,
height: 1,
fontWeight: FontWeight.w600,
fontSize: 18,
),
),
),
),
);
}
}