|
|
|
@ -1,23 +1,13 @@
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_map/flutter_map.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_map_geojson2/flutter_map_geojson2.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:latlong2/latlong.dart';
|
|
|
|
|
|
|
|
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/modules/asset_tracking/asset_tracking_provider.dart';
|
|
|
|
import 'package:test_sa/modules/asset_tracking/asset_tracking_provider.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'asset_tracking_item_view.dart';
|
|
|
|
import 'asset_tracking_item_view.dart';
|
|
|
|
import 'map_tracking_page.dart';
|
|
|
|
import 'map_tracking_page.dart';
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,10 +36,16 @@ class _AssetTrackingPageState extends State<AssetTrackingPage> with SingleTicker
|
|
|
|
_animationController.forward();
|
|
|
|
_animationController.forward();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
assetTrackingProvider.reset();
|
|
|
|
assetTrackingProvider.reset();
|
|
|
|
assetTrackingProvider.getAssetsFromPenguin();
|
|
|
|
getAssetsFromPenguin();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getAssetsFromPenguin({bool loadMore = false}) async {
|
|
|
|
|
|
|
|
await assetTrackingProvider.getAssetsFromPenguin(
|
|
|
|
|
|
|
|
loadMore: loadMore,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
@ -118,48 +114,60 @@ class _AssetTrackingPageState extends State<AssetTrackingPage> with SingleTicker
|
|
|
|
return Consumer<AssetTrackingProvider>(builder: (context, provider, _) {
|
|
|
|
return Consumer<AssetTrackingProvider>(builder: (context, provider, _) {
|
|
|
|
return (provider.assetsList.isEmpty && !provider.isLoading)
|
|
|
|
return (provider.assetsList.isEmpty && !provider.isLoading)
|
|
|
|
? NoDataFound(message: context.translation.noDataFound).center
|
|
|
|
? NoDataFound(message: context.translation.noDataFound).center
|
|
|
|
: ListView.separated(
|
|
|
|
: NotificationListener<ScrollNotification>(
|
|
|
|
key: const ValueKey('asset-list_view'),
|
|
|
|
onNotification: (scrollInfo) {
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
if (!provider.isNextPageLoading && provider.nextPage && scrollInfo.metrics.pixels == scrollInfo.metrics.maxScrollExtent) {
|
|
|
|
itemCount: provider.isLoading ? 6 : provider.assetsList.length,
|
|
|
|
getAssetsFromPenguin(loadMore: true);
|
|
|
|
separatorBuilder: (listContext, itemIndex) => 12.height,
|
|
|
|
}
|
|
|
|
itemBuilder: (listContext, itemIndex) {
|
|
|
|
return false;
|
|
|
|
if (provider.isLoading) return const SizedBox().toAssetListShimmer(listContext, provider.isLoading);
|
|
|
|
},
|
|
|
|
|
|
|
|
child: ListView.separated(
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
key: const ValueKey('asset-list_view'),
|
|
|
|
final delay = itemIndex * 0.08;
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
|
|
itemCount: provider.isLoading ? 6 : provider.assetsList.length + (provider.isNextPageLoading ? 1 : 0),
|
|
|
|
CurvedAnimation(
|
|
|
|
separatorBuilder: (listContext, itemIndex) => 12.height,
|
|
|
|
parent: _animationController,
|
|
|
|
itemBuilder: (listContext, itemIndex) {
|
|
|
|
curve: Interval(
|
|
|
|
if (provider.isLoading) return const SizedBox().toAssetListShimmer(listContext, provider.isLoading);
|
|
|
|
delay.clamp(0.0, 0.7),
|
|
|
|
if (itemIndex >= provider.assetsList.length) {
|
|
|
|
(delay + 0.4).clamp(0.0, 1.0),
|
|
|
|
return const Padding(
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 16),
|
|
|
|
|
|
|
|
child: Center(child: CircularProgressIndicator()),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
final delay = itemIndex * 0.08;
|
|
|
|
|
|
|
|
final animation = Tween<double>(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<Offset>(
|
|
|
|
final slideAnimation = Tween<Offset>(
|
|
|
|
begin: const Offset(0.0, 0.15),
|
|
|
|
begin: const Offset(0.0, 0.15),
|
|
|
|
end: Offset.zero,
|
|
|
|
end: Offset.zero,
|
|
|
|
).animate(
|
|
|
|
).animate(
|
|
|
|
CurvedAnimation(
|
|
|
|
CurvedAnimation(
|
|
|
|
parent: _animationController,
|
|
|
|
parent: _animationController,
|
|
|
|
curve: Interval(
|
|
|
|
curve: Interval(
|
|
|
|
delay.clamp(0.0, 0.7),
|
|
|
|
delay.clamp(0.0, 0.7),
|
|
|
|
(delay + 0.4).clamp(0.0, 1.0),
|
|
|
|
(delay + 0.4).clamp(0.0, 1.0),
|
|
|
|
curve: Curves.easeOutCubic,
|
|
|
|
curve: Curves.easeOutCubic,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return FadeTransition(
|
|
|
|
return FadeTransition(
|
|
|
|
opacity: animation,
|
|
|
|
opacity: animation,
|
|
|
|
child: SlideTransition(position: slideAnimation, child: AssetTrackingListItemView(provider.assetsList[itemIndex])).onPress(() {
|
|
|
|
child: SlideTransition(position: slideAnimation, child: AssetTrackingListItemView(provider.assetsList[itemIndex])).onPress(() {
|
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => MapTrackingPage(assetTrackingData: provider.assetsList[itemIndex])));
|
|
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => MapTrackingPage(assetTrackingData: provider.assetsList[itemIndex])));
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -173,56 +181,78 @@ class _AssetTrackingPageState extends State<AssetTrackingPage> with SingleTicker
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// padding: const EdgeInsets.all(16),
|
|
|
|
// padding: const EdgeInsets.all(16),
|
|
|
|
|
|
|
|
|
|
|
|
GridView.builder(
|
|
|
|
NotificationListener<ScrollNotification>(
|
|
|
|
key: const ValueKey('asset-grid_view'),
|
|
|
|
onNotification: (scrollInfo) {
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
if (!provider.isLoading &&
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
!provider.isNextPageLoading &&
|
|
|
|
crossAxisCount: 2,
|
|
|
|
provider.nextPage &&
|
|
|
|
childAspectRatio: .8,
|
|
|
|
scrollInfo.metrics.pixels >= (scrollInfo.metrics.maxScrollExtent - 200)) {
|
|
|
|
crossAxisSpacing: 12,
|
|
|
|
getAssetsFromPenguin(loadMore: true);
|
|
|
|
mainAxisSpacing: 12,
|
|
|
|
}
|
|
|
|
),
|
|
|
|
return false;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
child: 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);
|
|
|
|
|
|
|
|
|
|
|
|
itemCount: provider.isLoading ? 6 : provider.assetsList.length,
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
// separatorBuilder: (listContext, itemIndex) => 12.height,
|
|
|
|
final delay = itemIndex * 0.08;
|
|
|
|
|
|
|
|
final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
|
|
itemBuilder: (listContext, itemIndex) {
|
|
|
|
CurvedAnimation(
|
|
|
|
if (provider.isLoading) return const SizedBox().toAssetListShimmer(listContext, provider.isLoading);
|
|
|
|
parent: _animationController,
|
|
|
|
|
|
|
|
curve: Interval(
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
delay.clamp(0.0, 0.7),
|
|
|
|
final delay = itemIndex * 0.08;
|
|
|
|
(delay + 0.4).clamp(0.0, 1.0),
|
|
|
|
final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
CurvedAnimation(
|
|
|
|
),
|
|
|
|
parent: _animationController,
|
|
|
|
),
|
|
|
|
curve: Interval(
|
|
|
|
);
|
|
|
|
delay.clamp(0.0, 0.7),
|
|
|
|
|
|
|
|
(delay + 0.4).clamp(0.0, 1.0),
|
|
|
|
final slideAnimation = Tween<Offset>(
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
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])));
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if (provider.isNextPageLoading)
|
|
|
|
|
|
|
|
const Padding(
|
|
|
|
final slideAnimation = Tween<Offset>(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 16),
|
|
|
|
begin: const Offset(0.0, 0.15),
|
|
|
|
child: Center(child: CircularProgressIndicator()),
|
|
|
|
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])));
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|