|
|
|
|
@ -13,7 +13,7 @@ import 'package:test_sa/views/widgets/equipment/predict_device_item_view.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
|
|
|
|
|
class PredictDeviceView extends StatefulWidget {
|
|
|
|
|
static const String id = "/single-device-Picker";
|
|
|
|
|
static const String id = "/predict_device_view";
|
|
|
|
|
List<PredictedAsset> predictedAsset;
|
|
|
|
|
|
|
|
|
|
PredictDeviceView({Key? key, required this.predictedAsset}) : super(key: key);
|
|
|
|
|
@ -63,118 +63,114 @@ class _PredictDeviceViewState extends State<PredictDeviceView> with SingleTicker
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: widget.predictedAsset.isEmpty
|
|
|
|
|
? NoDataFound(message: context.translation.noDeviceFound).center
|
|
|
|
|
: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
AnimatedSwitcher(
|
|
|
|
|
duration: const Duration(milliseconds: 500),
|
|
|
|
|
child: showListView
|
|
|
|
|
? ListView.separated(
|
|
|
|
|
key: const ValueKey('list_view'),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: widget.predictedAsset.length,
|
|
|
|
|
separatorBuilder: (listContext, itemIndex) => 12.height,
|
|
|
|
|
itemBuilder: (listContext, itemIndex) {
|
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
body: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
AnimatedSwitcher(
|
|
|
|
|
duration: const Duration(milliseconds: 500),
|
|
|
|
|
child: showListView
|
|
|
|
|
? ListView.separated(
|
|
|
|
|
key: const ValueKey('list_view'),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: widget.predictedAsset.length,
|
|
|
|
|
separatorBuilder: (listContext, itemIndex) => 12.height,
|
|
|
|
|
itemBuilder: (listContext, itemIndex) {
|
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
|
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>(
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
final slideAnimation = Tween<Offset>(
|
|
|
|
|
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: PredictDeviceItemView(
|
|
|
|
|
device: widget.predictedAsset[itemIndex],
|
|
|
|
|
onPressed: (device) {
|
|
|
|
|
Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.assetId);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: GridView.builder(
|
|
|
|
|
key: const ValueKey('grid_view'),
|
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 188 / 261, crossAxisSpacing: 12, mainAxisSpacing: 12),
|
|
|
|
|
itemCount: widget.predictedAsset.length,
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
|
final delay = index * 0.08;
|
|
|
|
|
final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
|
|
|
CurvedAnimation(
|
|
|
|
|
parent: _animationController,
|
|
|
|
|
curve: Interval(
|
|
|
|
|
delay.clamp(0.0, 0.8),
|
|
|
|
|
(delay + 0.3).clamp(0.0, 1.0),
|
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return FadeTransition(
|
|
|
|
|
opacity: animation,
|
|
|
|
|
child: SlideTransition(
|
|
|
|
|
position: slideAnimation,
|
|
|
|
|
child: PredictDeviceItemView(
|
|
|
|
|
device: widget.predictedAsset[itemIndex],
|
|
|
|
|
onPressed: (device) {
|
|
|
|
|
//We are not getting asset id in response only have serial number
|
|
|
|
|
// Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.assetId);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: GridView.builder(
|
|
|
|
|
key: const ValueKey('grid_view'),
|
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
crossAxisSpacing: 12,
|
|
|
|
|
childAspectRatio: 1.5,
|
|
|
|
|
mainAxisSpacing: 12),
|
|
|
|
|
itemCount: widget.predictedAsset.length,
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
// Calculate staggered animation delay
|
|
|
|
|
final delay = index * 0.08;
|
|
|
|
|
final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
|
|
|
CurvedAnimation(
|
|
|
|
|
parent: _animationController,
|
|
|
|
|
curve: Interval(
|
|
|
|
|
delay.clamp(0.0, 0.8),
|
|
|
|
|
(delay + 0.3).clamp(0.0, 1.0),
|
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final slideAnimation = Tween<Offset>(
|
|
|
|
|
begin: const Offset(0.0, 0.3),
|
|
|
|
|
end: Offset.zero,
|
|
|
|
|
).animate(
|
|
|
|
|
CurvedAnimation(
|
|
|
|
|
parent: _animationController,
|
|
|
|
|
curve: Interval(
|
|
|
|
|
delay.clamp(0.0, 0.8),
|
|
|
|
|
(delay + 0.3).clamp(0.0, 1.0),
|
|
|
|
|
curve: Curves.easeOutCubic,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
final slideAnimation = Tween<Offset>(
|
|
|
|
|
begin: const Offset(0.0, 0.3),
|
|
|
|
|
end: Offset.zero,
|
|
|
|
|
).animate(
|
|
|
|
|
CurvedAnimation(
|
|
|
|
|
parent: _animationController,
|
|
|
|
|
curve: Interval(
|
|
|
|
|
delay.clamp(0.0, 0.8),
|
|
|
|
|
(delay + 0.3).clamp(0.0, 1.0),
|
|
|
|
|
curve: Curves.easeOutCubic,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return FadeTransition(
|
|
|
|
|
opacity: animation,
|
|
|
|
|
child: SlideTransition(
|
|
|
|
|
position: slideAnimation,
|
|
|
|
|
child: PredictDeviceItemGridView(
|
|
|
|
|
device: widget.predictedAsset[index],
|
|
|
|
|
onPressed: (device) {
|
|
|
|
|
Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.assetId);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (_devicesProvider.isLoading) Align(alignment: Alignment.bottomCenter, child: CircularProgressIndicator().paddingOnly(top: 16, bottom: 16)),
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
return FadeTransition(
|
|
|
|
|
opacity: animation,
|
|
|
|
|
child: SlideTransition(
|
|
|
|
|
position: slideAnimation,
|
|
|
|
|
child: PredictDeviceItemGridView(
|
|
|
|
|
device: widget.predictedAsset[index],
|
|
|
|
|
onPressed: (device) {
|
|
|
|
|
//We are not getting asset id in response only have serial number
|
|
|
|
|
// Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.assetId);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|