feat: Baskets page's loading,loaded state done
This commit is contained in:
@@ -15,6 +15,6 @@ class BasketBloc extends Bloc<BasketEvent, BasketState> {
|
||||
_onStarted(_Started event, Emitter<BasketState> emit) async {
|
||||
emit(state.copyWith(status: RequestStatus.loading));
|
||||
await Future.delayed(TimeDelayConst.duration3);
|
||||
emit(state.copyWith(status: RequestStatus.loaded));
|
||||
emit(state.copyWith(status: RequestStatus.loaded, orders: []));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:food_delivery_client/feature/basket/presentation/pages/basket_page/widgets/w_basket_loading.dart';
|
||||
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
@@ -9,14 +9,17 @@ class WBasketBody extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<BasketBloc, BasketState>(
|
||||
builder: (context, state) {
|
||||
log("qweqweqweqwe:${state.orders}");
|
||||
log("qweqweqweqwe:${state.orders.isEmpty}");
|
||||
log("qweqweqweqwe:${state.orders.isNotEmpty}");
|
||||
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
WBasketHeader(),
|
||||
OrderItem(),
|
||||
|
||||
if (state.status.isLoading()) Text("Loading"),
|
||||
if (state.status.isLoading()) WBasketLoading(),
|
||||
if (state.status.isLoaded())
|
||||
if (state.orders.isEmpty) WBasketEmpty(),
|
||||
if (state.orders.isEmpty) WBasketEmpty() else WBasketCarts(),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WBasketCarts extends StatelessWidget {
|
||||
const WBasketCarts({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<BasketBloc, BasketState>(
|
||||
builder: (context, state) {
|
||||
return Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
context.read<BasketBloc>().add(BasketEvent.started());
|
||||
await Future.delayed(TimeDelayConst.duration3);
|
||||
},
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: 10,
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) => OrderItem(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class WBasketLoading extends StatelessWidget {
|
||||
@@ -5,12 +6,21 @@ class WBasketLoading extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: []);
|
||||
return Expanded(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: 10,
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) =>
|
||||
Skeletonizer(enabled: true, child: OrderItemSkeletonizer()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OrderItem extends StatelessWidget {
|
||||
const OrderItem({super.key});
|
||||
class OrderItemSkeletonizer extends StatelessWidget {
|
||||
const OrderItemSkeletonizer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -32,28 +42,34 @@ class OrderItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
16.horizontalSpace,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Begs & Megs", style: AppTextStyles.size16Medium),
|
||||
Text(
|
||||
"1 item",
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Begs & Megs", style: AppTextStyles.size16Medium),
|
||||
Text(
|
||||
AppLocaleKeys.lorem,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Deliver to San Franciscao Bay Area",
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
Text(
|
||||
"Deliver to San Franciscao Bay Area",
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios_outlined,
|
||||
color: AppColors.cFFFFFF,
|
||||
),
|
||||
const Spacer(),
|
||||
Icon(Icons.arrow_forward_ios_outlined),
|
||||
],
|
||||
).paddingSymmetric(vertical: 10, horizontal: 16),
|
||||
).paddingSymmetric(vertical: 10, horizontal: 18),
|
||||
10.verticalSpace,
|
||||
WDivider(indent: 120, endIndent: 20, height: 1),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import '../../../../../../food_delivery_client.dart';
|
||||
|
||||
class OrderItem extends StatelessWidget {
|
||||
const OrderItem({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {},
|
||||
child: Ink(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: AppUtils.kBorderRadius40,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: AppLocaleKeys.imageUrl,
|
||||
height: 70,
|
||||
width: 70,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
16.horizontalSpace,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocaleKeys.lorem,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppTextStyles.size16Medium,
|
||||
),
|
||||
Row(
|
||||
spacing: 5,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
AppLocaleKeys.lorem,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(Icons.circle, size: 5, color: AppColors.c6B6B6B),
|
||||
Expanded(
|
||||
child: Text(
|
||||
AppLocaleKeys.lorem,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
AppLocaleKeys.lorem,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppTextStyles.size14Regular.copyWith(
|
||||
color: AppColors.c6B6B6B,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
10.horizontalSpace,
|
||||
SvgPicture.asset(AppIcons.icArrowRight),
|
||||
],
|
||||
).paddingSymmetric(vertical: 10, horizontal: 18),
|
||||
10.verticalSpace,
|
||||
WDivider(indent: 120, endIndent: 20, height: 1),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user