fix(bugs):
fix(DeviceManagerScreen): show all devices when visibility=DELETED fix(MapScreen): cannot delete polylines when closing SnackBar on iOS
This commit is contained in:
@@ -98,13 +98,19 @@ class DevicesManagerBloc extends BlocBase {
|
||||
final data = jsonDecode(body);
|
||||
List<dynamic> items = data['items'];
|
||||
List<Device> originalDevices = Device.fromJsonDynamicList(items);
|
||||
List<Device> publicDevices = [];
|
||||
|
||||
for(var device in originalDevices){
|
||||
if(device.visibility == "PUBLIC"){
|
||||
publicDevices.add(device);
|
||||
}
|
||||
}
|
||||
devices = (state != -2)
|
||||
? DeviceUtils.instance.sortDeviceAZByName(originalDevices)
|
||||
: DeviceUtils.instance.sortDeviceByState(originalDevices);
|
||||
? DeviceUtils.instance.sortDeviceAZByName(publicDevices)
|
||||
: DeviceUtils.instance.sortDeviceByState(publicDevices);
|
||||
|
||||
if (state == -2) {
|
||||
for (var device in originalDevices) {
|
||||
for (var device in publicDevices) {
|
||||
String stateKey = _getStateKey(device.state!);
|
||||
deviceByState[stateKey]!.add(device);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:simple_ripple_animation/simple_ripple_animation.dart';
|
||||
import 'package:sfm_app/feature/device_log/device_logs_model.dart';
|
||||
|
||||
import '../../../product/constant/image/image_constants.dart';
|
||||
import '../../../product/shared/shared_line_chart.dart';
|
||||
import '../../../product/shared/shared_curve.dart';
|
||||
import '../../device_log/device_logs_model.dart';
|
||||
import '../device_model.dart';
|
||||
import '../../../product/base/bloc/base_bloc.dart';
|
||||
import '../../../product/extension/context_extension.dart';
|
||||
|
||||
@@ -117,12 +117,14 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
|
||||
clusterManager.updateMap();
|
||||
},
|
||||
polylines: {
|
||||
Polyline(
|
||||
polylineId: const PolylineId('router'),
|
||||
points: polylinesSnapshot.data ?? [],
|
||||
color: Colors.deepPurpleAccent,
|
||||
width: 8,
|
||||
),
|
||||
if (polylinesSnapshot.data != null && polylinesSnapshot.data!.isNotEmpty) ... [
|
||||
Polyline(
|
||||
polylineId: const PolylineId('router'),
|
||||
points: polylinesSnapshot.data!,
|
||||
color: Colors.deepPurpleAccent,
|
||||
width: 8,
|
||||
),
|
||||
]
|
||||
},
|
||||
style: mapThemeSnapshot.data,
|
||||
);
|
||||
|
||||
@@ -72,7 +72,7 @@ onTapMarker(
|
||||
double.parse(device.settings!.latitude!),
|
||||
double.parse(device.settings!.longitude!),
|
||||
);
|
||||
mapBloc.findTheWay(
|
||||
await mapBloc.findTheWay(
|
||||
context,
|
||||
controller,
|
||||
myLocation,
|
||||
|
||||
@@ -16,13 +16,11 @@ showDirections(
|
||||
MapBloc mapBloc,
|
||||
String originalName,
|
||||
String destinationLocation,
|
||||
double devicelat,
|
||||
double devicelng,
|
||||
double deviceLat,
|
||||
double deviceLng,
|
||||
) {
|
||||
TextEditingController originController =
|
||||
TextEditingController(text: originalName);
|
||||
TextEditingController destinationController =
|
||||
TextEditingController(text: destinationLocation);
|
||||
TextEditingController originController = TextEditingController(text: originalName);
|
||||
TextEditingController destinationController = TextEditingController(text: destinationLocation);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
@@ -44,15 +42,14 @@ showDirections(
|
||||
alignment: Alignment.centerRight,
|
||||
child: IconButton.outlined(
|
||||
onPressed: () async {
|
||||
await mapBloc.updateCameraPosition(
|
||||
controller,
|
||||
devicelat,
|
||||
devicelng,
|
||||
13.0,
|
||||
);
|
||||
// List<LatLng> polylineCoordinates = [];
|
||||
mapBloc.sinkPolylines.add([]);
|
||||
markers.clear();
|
||||
await mapBloc.updateCameraPosition(
|
||||
controller,
|
||||
deviceLat,
|
||||
deviceLng,
|
||||
13.0,
|
||||
);
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
}
|
||||
@@ -103,10 +100,9 @@ showDirections(
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
List<LatLng> polylineCoordinates = [];
|
||||
mapBloc.sinkPolylines.add(polylineCoordinates);
|
||||
MapsLauncher.launchCoordinates(devicelat, devicelng);
|
||||
MapsLauncher.launchCoordinates(deviceLat, deviceLng);
|
||||
},
|
||||
icon: IconConstants.instance
|
||||
.getMaterialIcon(Icons.near_me_rounded),
|
||||
icon: IconConstants.instance.getMaterialIcon(Icons.near_me_rounded),
|
||||
label: Text(
|
||||
appLocalization(context).map_stream,
|
||||
),
|
||||
|
||||
@@ -52,7 +52,6 @@ showNearPlacesSideSheet(
|
||||
padding: context.paddingLow,
|
||||
width: screenWidth,
|
||||
height: screenHeight / 3,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user