import 'package:eatvio_app/features/registration/models/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/generated/l10n.dart'; import 'package:eatvio_app/core/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class WeightScreen extends StatefulWidget { final UserRegistrationSheet sheet; const WeightScreen({super.key, required this.sheet}); @override State createState() => _WeightScreenState(); } class _WeightScreenState extends State { final weightController = TextEditingController(); final weightFocus = FocusNode(); @override void initState() { super.initState(); if (widget.sheet.weight != 0) weightController.text = widget.sheet.weight.toString(); weightFocus.requestFocus(); } @override Widget build(BuildContext context) { final s = S.of(context); return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80, left: 16, right: 16, top: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(s.your_weight), SizedBox(height: 4), CustomTextFormField( autofocus: true, hintText: 'кг', focusNode: weightFocus, textInputAction: TextInputAction.done, controller: weightController, keyboardType: TextInputType.number, inputFormatters: [ FilteringTextInputFormatter.digitsOnly, ], onChanged: (newValue) { final registrationCubit = context.read(); registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(weight: int.parse(newValue))); }, ), ], ), ); } }