From 67dbcc5ab35bf359393cda40e7cfe9aaba5dbd6c Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 15 Sep 2026 09:48:17 +0300 Subject: [PATCH] map improvements --- .../asset_tracking/asset_tracking_page.dart | 77 ++++++++++++++++++- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/lib/modules/asset_tracking/asset_tracking_page.dart b/lib/modules/asset_tracking/asset_tracking_page.dart index d91081e7..ce2213b7 100644 --- a/lib/modules/asset_tracking/asset_tracking_page.dart +++ b/lib/modules/asset_tracking/asset_tracking_page.dart @@ -99,16 +99,22 @@ class _AssetTrackingPageState extends State with SingleTicker ), SafeArea( child: AnimatedSwitcher( - duration: const Duration(milliseconds: 300), - child: selectedIndex == 3 ? MapTrackingPage() : listView(), - ), + duration: const Duration(milliseconds: 300), + child: selectedIndex == 1 + ? assetsListView() + : selectedIndex == 2 + ? assetsGridView() + : MapTrackingPage() + + // selectedIndex == 3 ? MapTrackingPage() : assetsListView(), + ), ).expanded, ], ), ); } - Widget listView() { + Widget assetsListView() { return Consumer(builder: (context, provider, _) { return (provider.assetsList.isEmpty && !provider.isLoading) ? NoDataFound(message: context.translation.noDataFound).center @@ -157,4 +163,67 @@ class _AssetTrackingPageState extends State with SingleTicker ); }); } + + Widget assetsGridView() { + return Consumer(builder: (context, provider, _) { + return (provider.assetsList.isEmpty && !provider.isLoading) + ? NoDataFound(message: context.translation.noDataFound).center + : + // ListView.separated( + // + // padding: const EdgeInsets.all(16), + + GridView.builder( + key: const ValueKey('asset-grid_view'), + padding: const EdgeInsets.all(16), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: .8, + crossAxisSpacing: 12, + mainAxisSpacing: 12, + ), + + itemCount: provider.isLoading ? 6 : provider.assetsList.length, + // separatorBuilder: (listContext, itemIndex) => 12.height, + + itemBuilder: (listContext, itemIndex) { + if (provider.isLoading) return const SizedBox().toAssetListShimmer(listContext, provider.isLoading); + + // Calculate staggered animation delay + final delay = itemIndex * 0.08; + final animation = Tween(begin: 0.0, end: 1.0).animate( + CurvedAnimation( + parent: _animationController, + curve: Interval( + delay.clamp(0.0, 0.7), + (delay + 0.4).clamp(0.0, 1.0), + curve: Curves.easeOut, + ), + ), + ); + + final slideAnimation = Tween( + begin: const Offset(0.0, 0.15), + end: Offset.zero, + ).animate( + CurvedAnimation( + parent: _animationController, + curve: Interval( + delay.clamp(0.0, 0.7), + (delay + 0.4).clamp(0.0, 1.0), + curve: Curves.easeOutCubic, + ), + ), + ); + + return FadeTransition( + opacity: animation, + child: SlideTransition(position: slideAnimation, child: AssetTrackingListItemView(provider.assetsList[itemIndex])).onPress(() { + Navigator.push(context, MaterialPageRoute(builder: (context) => MapTrackingPage(assetTrackingData: provider.assetsList[itemIndex]))); + }), + ); + }, + ); + }); + } }