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 createState() => _OtherInfoScreenState(); } class _OtherInfoScreenState extends State { 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: Text('Прочая информаиця'), ), bottomSheet: _saveButton(), body: SingleChildScrollView( padding: EdgeInsets.all(16) + EdgeInsets.only(bottom: 64), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(s.allergies_presence), SizedBox(height: 4), CustomTextFormField( controller: aboutAllergyController, hintText: 'Например: орехи, мёд и т.д.', autofocus: true, minLines: 2, maxLines: 8, maxLength: 250, onChanged: (newValue) {}, ), SizedBox(height: 16), Text(s.do_you_take_pills), SizedBox(height: 4), CustomTextFormField( controller: aboutTakingPillsController, hintText: s.enter_information, autofocus: true, minLines: 2, maxLength: 250, maxLines: 8, onChanged: (newValue) {}, ), SizedBox(height: 16), Text(s.your_favorite_sports), SizedBox(height: 4), CustomTextFormField( controller: aboutSportHobbiesController, hintText: "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", autofocus: true, maxLines: 8, maxLength: 250, onChanged: (newValue) {}, ), SizedBox(height: 16), Text(s.favorite_foods), SizedBox(height: 4), CustomTextFormField( controller: favoriteFoodsController, hintText: s.enter_information, maxLines: 7, minLines: 2, maxLength: 250, onChanged: (newValue) {}, ), SizedBox(height: 16), Text(s.unfavorite_foods), SizedBox(height: 4), CustomTextFormField( controller: unFavouriteFoodsController, hintText: s.enter_information, maxLines: 7, minLines: 2, maxLength: 250, onChanged: (newValue) {}, ), SizedBox(height: 16), Text( 'Дополнительная информация', maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.start, ), SizedBox(height: 4), CustomTextFormField( controller: additionalInfoController, maxLength: 250, hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", maxLines: 8, onChanged: (newValue) {}, ), ], ), ), ); } _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: Center( child: Text( 'Сохранить', style: TextStyle( color: Colors.white, height: 1, fontWeight: FontWeight.w600, fontSize: 18, ), ), ), ), ); } }