Files
eatvio_app/lib/features/registration/presentation/pages/height_screen.dart
2024-11-20 14:30:48 +03:00

59 lines
2.0 KiB
Dart

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 HeightScreen extends StatefulWidget {
final UserRegistrationSheet sheet;
const HeightScreen({super.key, required this.sheet});
@override
State<HeightScreen> createState() => _HeightScreenState();
}
class _HeightScreenState extends State<HeightScreen> {
final heightController = TextEditingController();
final heightFocus = FocusNode();
@override
void initState() {
super.initState();
if (widget.sheet.height != 0) heightController.text = widget.sheet.height.toString();
heightFocus.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_height),
SizedBox(height: 4),
CustomTextFormField(
textInputAction: TextInputAction.done,
autofocus: true,
focusNode: heightFocus,
hintText: 'см',
controller: heightController,
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
],
onChanged: (newValue) {
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(height: int.parse(newValue)));
},
),
],
),
);
}
}