forked from eatvio/eatvio_app
55 lines
1.8 KiB
Dart
55 lines
1.8 KiB
Dart
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class MealButtonWidget extends StatefulWidget {
|
|
final int mealNumber;
|
|
|
|
const MealButtonWidget({
|
|
super.key,
|
|
required this.mealNumber,
|
|
});
|
|
|
|
@override
|
|
State<MealButtonWidget> createState() => _MealButtonWidgetState();
|
|
}
|
|
|
|
class _MealButtonWidgetState extends State<MealButtonWidget> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DiaryCubit, DiaryState>(
|
|
builder: (context, state) {
|
|
if (state is DiaryStateLoaded) {
|
|
return InkWell(
|
|
onTap: () {
|
|
context.read<DiaryCubit>().setSelectedMeal(widget.mealNumber);
|
|
},
|
|
borderRadius: BorderRadius.circular(100),
|
|
child: Ink(
|
|
width: MediaQuery.of(context).size.width / 5 - (96 / 5),
|
|
height: 32,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: state.selectedMeal == widget.mealNumber ? appTheme.blueA400 : Color(0xFFF1F2F6),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
'${widget.mealNumber}',
|
|
style: TextStyle(
|
|
color: state.selectedMeal == widget.mealNumber ? Colors.white : Color(0xFF6D6F71),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return const SizedBox.shrink();
|
|
},
|
|
);
|
|
}
|
|
}
|