forked from eatvio/eatvio_app
48 lines
1.7 KiB
Dart
48 lines
1.7 KiB
Dart
import 'package:eatvio_app/core/widgets/loader.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/features/diary/presentation/widgets/calendar_widget.dart';
|
|
import 'package:eatvio_app/core/locator_service.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/widgets/calories_chart_widget.dart';
|
|
import 'package:eatvio_app/features/diary/presentation/widgets/meal_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class DiaryScreen extends StatefulWidget {
|
|
const DiaryScreen({super.key});
|
|
|
|
@override
|
|
State<DiaryScreen> createState() => _DiaryScreenState();
|
|
}
|
|
|
|
class _DiaryScreenState extends State<DiaryScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider<DiaryCubit>(
|
|
create: (BuildContext context) => sl<DiaryCubit>()..fetchDiary(true),
|
|
child: BlocBuilder<DiaryCubit, DiaryState>(
|
|
builder: (BuildContext context, DiaryState state) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.grey.shade200,
|
|
appBar: AppBar(
|
|
toolbarHeight: 0,
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: const EdgeInsets.only(bottom: 16),
|
|
physics: const BouncingScrollPhysics(),
|
|
child: Column(
|
|
children: [
|
|
CalendarWidget(),
|
|
if (state is DiaryStateLoading) const Loader(),
|
|
if (state is DiaryStateLoaded) MealWidget(),
|
|
CaloriesChartWidget(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|