forked from eatvio/eatvio_app
99 lines
4.1 KiB
Dart
99 lines
4.1 KiB
Dart
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
|
|
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
|
|
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class SexWidget extends StatelessWidget {
|
|
const SexWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final s = S.of(context);
|
|
return BlocBuilder<RegistrationCubitV2, RegistrationStateV2>(
|
|
builder: (context, state) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(s.sex, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
|
InkWell(
|
|
onTap: () {
|
|
context.read<RegistrationCubitV2>().setGender('male');
|
|
},
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: Ink(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF6F6F6),
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: state.isGenderValid
|
|
? state.gender == 'male'
|
|
? Border.all(width: 2, color: appTheme.blueA400)
|
|
: null
|
|
: Border.all(width: 1, color: appTheme.red),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
s.male_short,
|
|
style: TextStyle(
|
|
color: state.gender == 'male' ? appTheme.blueA400 : const Color(0xFF323F4B),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 4),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
context.read<RegistrationCubitV2>().setGender('female');
|
|
},
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: Ink(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF6F6F6),
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: state.isGenderValid
|
|
? state.gender == 'female'
|
|
? Border.all(width: 2, color: appTheme.blueA400)
|
|
: null
|
|
: Border.all(width: 1, color: appTheme.red),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
s.female_short,
|
|
style: TextStyle(
|
|
color: state.gender == 'female' ? appTheme.blueA400 : const Color(0xFF323F4B),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (!state.isGenderValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.gender_error)],
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|