|
|
|
|
@ -10,6 +10,7 @@ import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/helper/utils.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/multiple_item_drop_down_menu.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
|
|
|
|
|
@ -39,7 +40,7 @@ class _MapTrackingPageState extends State<MapTrackingPage> {
|
|
|
|
|
|
|
|
|
|
FloorMapModel? floorMapModel;
|
|
|
|
|
Map<String, dynamic>? _geojson;
|
|
|
|
|
List<Marker> markers = [];
|
|
|
|
|
List<Marker> markers = []; // move to provider
|
|
|
|
|
|
|
|
|
|
LatLngBounds? _computedBounds;
|
|
|
|
|
final ExpansibleController expansibleController = ExpansibleController();
|
|
|
|
|
@ -175,33 +176,69 @@ class _MapTrackingPageState extends State<MapTrackingPage> {
|
|
|
|
|
userAgentPackageName: 'com.hmg.atoms',
|
|
|
|
|
),
|
|
|
|
|
if (_geojson != null) ...[
|
|
|
|
|
GeoJsonLayer.memory(
|
|
|
|
|
_geojson!,
|
|
|
|
|
styleDefaults: GeoJsonStyleDefaults.leaflet,
|
|
|
|
|
),
|
|
|
|
|
if (!inAppView) MarkerLayer(markers: markers),
|
|
|
|
|
GeoJsonLayer.memory(_geojson!, styleDefaults: GeoJsonStyleDefaults.leaflet),
|
|
|
|
|
// if (!inAppView || )
|
|
|
|
|
if (markers.isNotEmpty) MarkerLayer(markers: markers),
|
|
|
|
|
if (inAppView)
|
|
|
|
|
Selector<AssetTrackingProvider, List<AssetTrackingModel>>(
|
|
|
|
|
selector: (_, myModel) => myModel.assetsOnTheFloorList,
|
|
|
|
|
builder: (_, assetsOnTheFloorList, __) {
|
|
|
|
|
return assetsOnTheFloorList.isEmpty
|
|
|
|
|
? const SizedBox()
|
|
|
|
|
: DraggableScrollableSheet(
|
|
|
|
|
initialChildSize: _sheetPosition,
|
|
|
|
|
maxChildSize: .8,
|
|
|
|
|
minChildSize: .15,
|
|
|
|
|
builder: (BuildContext context, ScrollController scrollController) {
|
|
|
|
|
return ListView.separated(
|
|
|
|
|
controller: scrollController,
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
itemCount: assetsOnTheFloorList.length,
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) => 12.height,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return AssetTrackingListItemView(assetsOnTheFloorList[index]);
|
|
|
|
|
},
|
|
|
|
|
).bottomSheetContainer(context, padding: const EdgeInsets.all(16));
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
Positioned(
|
|
|
|
|
bottom: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
right: 0,
|
|
|
|
|
child: Selector<AssetTrackingProvider, List<AssetTrackingModel>>(
|
|
|
|
|
selector: (_, myModel) => myModel.assetsOnTheFloorList,
|
|
|
|
|
builder: (_, assetsOnTheFloorList, __) {
|
|
|
|
|
return assetsOnTheFloorList.isEmpty
|
|
|
|
|
? const SizedBox()
|
|
|
|
|
: Container(
|
|
|
|
|
margin: const EdgeInsets.all(16),
|
|
|
|
|
padding: const EdgeInsets.only(right: 0, left: 0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColor.tabBarBackground(context),
|
|
|
|
|
border: Border.all(color: AppColor.tabBarBorder(context)),
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
),
|
|
|
|
|
child: UpwardExpansionTile(title: InfoTextLabelWidget(label: "${assetsOnTheFloorList.length} Assets found on this floor"), children: [
|
|
|
|
|
LimitedBox(
|
|
|
|
|
maxHeight: 120,
|
|
|
|
|
child: MultipleItemDropDownMenu<AssetTrackingModel, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: 'Select Assets To View ',
|
|
|
|
|
initialValue: [],
|
|
|
|
|
showShadow: false,
|
|
|
|
|
staticData: assetsOnTheFloorList,
|
|
|
|
|
showCancel: true,
|
|
|
|
|
showAsFullScreenDialog: true,
|
|
|
|
|
onSelect: (selectedAssets) {
|
|
|
|
|
print("selectedAssets:${selectedAssets?.length}");
|
|
|
|
|
setState(() {
|
|
|
|
|
markers = [
|
|
|
|
|
for (var asset in selectedAssets!)
|
|
|
|
|
Marker(
|
|
|
|
|
point: LatLng(asset.location!.latitude!, asset.location!.longitude!),
|
|
|
|
|
child: const Icon(Icons.location_pin, color: AppColor.red30),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
// markers
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(start: 16, end: 16, top: 16),
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Column(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// children: [
|
|
|
|
|
// Container(
|
|
|
|
|
// width: 50.toScreenWidth,
|
|
|
|
|
// height: 6.toScreenHeight,
|
|
|
|
|
// decoration: BoxDecoration(color: AppColor.white50, borderRadius: BorderRadius.circular(30)),
|
|
|
|
|
// ).center,
|
|
|
|
|
// InfoTextLabelWidget(label: "There is ${assetsOnTheFloorList.length} assets on this floor"),
|
|
|
|
|
// ],
|
|
|
|
|
// ).bottomSheetContainer(context, padding: const EdgeInsets.all(16));
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
@ -295,3 +332,55 @@ class _MapTrackingPageState extends State<MapTrackingPage> {
|
|
|
|
|
: Scaffold(appBar: const DefaultAppBar(title: "Live Asset Tracking"), body: mapWidget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UpwardExpansionTile extends StatefulWidget {
|
|
|
|
|
final Widget title;
|
|
|
|
|
final List<Widget> children;
|
|
|
|
|
|
|
|
|
|
const UpwardExpansionTile({Key? key, required this.title, required this.children}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_UpwardExpansionTileState createState() => _UpwardExpansionTileState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UpwardExpansionTileState extends State<UpwardExpansionTile> {
|
|
|
|
|
bool _isExpanded = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: [
|
|
|
|
|
// Expanded content appears ABOVE the title
|
|
|
|
|
AnimatedCrossFade(
|
|
|
|
|
firstChild: const SizedBox.shrink(),
|
|
|
|
|
secondChild: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: widget.children,
|
|
|
|
|
),
|
|
|
|
|
crossFadeState: _isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
),
|
|
|
|
|
// The clickable header/title sits at the bottom
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isExpanded = !_isExpanded;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
widget.title,
|
|
|
|
|
Icon(_isExpanded ? Icons.expand_less : Icons.expand_more),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|