diff --git a/lib/presentation/pages/order/order_list/order_page.dart b/lib/presentation/pages/order/order_list/order_page.dart index 93f8e7b..8e00948 100644 --- a/lib/presentation/pages/order/order_list/order_page.dart +++ b/lib/presentation/pages/order/order_list/order_page.dart @@ -4,6 +4,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:line_icons/line_icons.dart'; +import 'package:shimmer/shimmer.dart'; import '../../../../application/order/order_loader/order_loader_bloc.dart'; import '../../../../common/theme/theme.dart'; @@ -76,6 +77,104 @@ class _OrderPageState extends State with TickerProviderStateMixin { super.dispose(); } + Widget _buildShimmerOrderCard() { + return Shimmer.fromColors( + baseColor: Colors.grey[300]!, + highlightColor: Colors.grey[100]!, + child: Container( + margin: const EdgeInsets.only(bottom: 12), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 10, + offset: const Offset(0, 2), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 120, + height: 16, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + ), + Container( + width: 60, + height: 20, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + ), + ], + ), + const SizedBox(height: 8), + Container( + width: double.infinity, + height: 14, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + ), + const SizedBox(height: 6), + Container( + width: 200, + height: 14, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + ), + const SizedBox(height: 12), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 80, + height: 14, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + ), + Container( + width: 100, + height: 16, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + ), + ], + ), + ], + ), + ), + ); + } + + Widget _buildShimmerList() { + return ListView.builder( + itemCount: 5, // Show 5 shimmer cards + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, index) => _buildShimmerOrderCard(), + ); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -180,7 +279,7 @@ class _OrderPageState extends State with TickerProviderStateMixin { child: Column( children: [ // Show filtered transaction count - if (state.status != 'all') + if (state.status != 'all' && !state.isFetching) Padding( padding: const EdgeInsets.only(bottom: 16), child: Row( @@ -196,30 +295,33 @@ class _OrderPageState extends State with TickerProviderStateMixin { ), ), - // Transaction List - state.orders.isEmpty - ? EmptyWidget( - title: 'Order', - message: - 'No ${state.status.toLowerCase()} orders found', - ) - : ListView.builder( - itemCount: state.orders.length, - shrinkWrap: true, - physics: - const NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - itemBuilder: (context, index) { - return OrderTile( - onTap: () => context.router.push( - OrderDetailRoute( - order: state.orders[index], - ), - ), + // Order List with Shimmer Loading + if (state.isFetching) + _buildShimmerList() + else if (state.orders.isEmpty) + EmptyWidget( + title: 'Order', + message: + 'No ${state.status.toLowerCase()} orders found', + ) + else + ListView.builder( + itemCount: state.orders.length, + shrinkWrap: true, + physics: + const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemBuilder: (context, index) { + return OrderTile( + onTap: () => context.router.push( + OrderDetailRoute( order: state.orders[index], - ); - }, - ), + ), + ), + order: state.orders[index], + ); + }, + ), ], ), ), @@ -236,5 +338,3 @@ class _OrderPageState extends State with TickerProviderStateMixin { ); } } - -// Custom delegate for pinned filter header