forked from eatvio/eatvio_app
67 lines
2.1 KiB
Dart
67 lines
2.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/diary/presentation/bloc/diary_cubit.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class ChosenPlanWidget extends StatelessWidget {
|
|
const ChosenPlanWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DiaryCubit, DiaryState>(builder: (context, state) {
|
|
if (state is DiaryStateLoaded) {
|
|
if (state.diary.typeOfDiary.hasChosenPlan) {
|
|
return ChosenPlanWidgetContent(
|
|
currentPlanDay: state.chosenPlanCurrentDay ?? 0,
|
|
planName: state.chosenPlanName ?? '',
|
|
planDuration: state.chosenPlanDuration ?? 0,
|
|
);
|
|
}
|
|
}
|
|
|
|
return const SizedBox.shrink();
|
|
});
|
|
}
|
|
}
|
|
|
|
class ChosenPlanWidgetContent extends StatelessWidget {
|
|
const ChosenPlanWidgetContent({
|
|
super.key,
|
|
required this.currentPlanDay,
|
|
required this.planName,
|
|
required this.planDuration,
|
|
});
|
|
final int currentPlanDay;
|
|
final String planName;
|
|
final int planDuration;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.sizeOf(context);
|
|
final s = S.of(context);
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: size.width * 0.4,
|
|
child: Text(planName, style: TextStyles.textLMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const Spacer(),
|
|
Container(
|
|
decoration: BoxDecoration(color: appTheme.dividerColor, borderRadius: BorderRadius.circular(12)),
|
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
|
|
child: Text('${s.day} $currentPlanDay из $planDuration', style: TextStyles.textMSemibold.copyWith(color: appTheme.gray)),
|
|
)
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 16,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|