forked from eatvio/eatvio_app
62 lines
2.2 KiB
Dart
62 lines
2.2 KiB
Dart
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
|
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
|
import 'package:eatvio_app/features/feed/presentation/bloc/plans_cubit/plans_cubit.dart';
|
|
import 'package:eatvio_app/features/feed/presentation/bloc/plans_cubit/plans_state.dart';
|
|
import 'package:eatvio_app/features/feed/presentation/widgets/filter_badge.dart';
|
|
import 'package:eatvio_app/features/feed/presentation/widgets/plan_widget.dart';
|
|
import 'package:eatvio_app/features/feed/presentation/widgets/plans_filter_bottom_sheet.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class Plans extends StatelessWidget {
|
|
const Plans({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return RefreshIndicator(
|
|
onRefresh: () => context.read<PlansCubit>().loadPlans(),
|
|
child: BlocBuilder<PlansCubit, PlansState>(
|
|
builder: (BuildContext context, PlansState state) {
|
|
if (state.isLoading) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.grey.shade200,
|
|
body: const Loader(),
|
|
);
|
|
} else if (state.errorMessage != null) {
|
|
return DataErrorWidget(onReload: () => context.read<PlansCubit>().loadPlans());
|
|
}
|
|
return Stack(
|
|
children: [
|
|
SizedBox.expand(),
|
|
ListView.separated(
|
|
padding: EdgeInsets.symmetric(vertical: 8),
|
|
shrinkWrap: true,
|
|
physics: BouncingScrollPhysics(),
|
|
itemBuilder: (context, index) {
|
|
return PlanWidget(
|
|
plan: state.plans[index],
|
|
index: index,
|
|
);
|
|
},
|
|
separatorBuilder: (context, index) {
|
|
return SizedBox(height: 8);
|
|
},
|
|
itemCount: state.plans.length,
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
bottom: 74,
|
|
child: FilterBadge(
|
|
filterBottomSheet: PlansFilterBottomSheet(
|
|
plansCubit: context.read<PlansCubit>(),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|