forked from eatvio/eatvio_app
84 lines
3.1 KiB
Dart
84 lines
3.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/core/widgets/custom_drop_down_button.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:collection/collection.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class PhisicalActivity extends StatefulWidget {
|
|
const PhisicalActivity({super.key});
|
|
|
|
@override
|
|
State<PhisicalActivity> createState() => _PhisicalActivityState();
|
|
}
|
|
|
|
class _PhisicalActivityState extends State<PhisicalActivity> {
|
|
final List<String> activityDropDownTitles = [];
|
|
final List<double> activityDropDownValues = [1.2, 1.375, 1.55, 1.7, 1.9];
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
final s = S.of(context);
|
|
if (activityDropDownTitles.isEmpty) {
|
|
activityDropDownTitles.add(s.activity_first_value);
|
|
activityDropDownTitles.add(s.activity_second_value);
|
|
activityDropDownTitles.add(s.activity_third_value);
|
|
activityDropDownTitles.add(s.activity_fourth_value);
|
|
activityDropDownTitles.add(s.activity_fifth_value);
|
|
}
|
|
}
|
|
|
|
// String _getTitleFromValue(double value) {
|
|
// switch (value) {
|
|
// case 1.2:
|
|
// return activityDropDownTitles[0];
|
|
// case 1.375:
|
|
// return activityDropDownTitles[1];
|
|
// case 1.55:
|
|
// return activityDropDownTitles[2];
|
|
// case 1.7:
|
|
// return activityDropDownTitles[3];
|
|
// case 1.9:
|
|
// return activityDropDownTitles[4];
|
|
// default:
|
|
// return activityDropDownTitles[5];
|
|
// }
|
|
// }
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<RegistrationCubitV2, RegistrationStateV2>(
|
|
builder: (context, state) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
CustomDropDownButton<double>(
|
|
isExpanded: true,
|
|
onChanged: (value) {
|
|
if (value != null) {
|
|
context.read<RegistrationCubitV2>().setActivityCoefficient(value);
|
|
}
|
|
},
|
|
items: activityDropDownTitles
|
|
.mapIndexed(
|
|
(index, value) => DropdownMenuItem<double>(
|
|
value: activityDropDownValues[index],
|
|
child: Text(activityDropDownTitles[index], style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
)
|
|
.toList(),
|
|
value: state.activityCoefficient == 0 ? null : state.activityCoefficient,
|
|
selectedItemBuilder: (context) {
|
|
return activityDropDownTitles.mapIndexed((index, value) => Text(activityDropDownTitles[index], overflow: TextOverflow.clip, maxLines: 1)).toList();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|