Harden geofence automation and home editing
This commit is contained in:
14
lib/features/homes/services/home_connection_change.dart
Normal file
14
lib/features/homes/services/home_connection_change.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import '../../../models/home_config.dart';
|
||||
|
||||
bool hasHomeConnectionChanges({
|
||||
required HomeConfig? originalHome,
|
||||
required String normalizedUrl,
|
||||
required String apiKey,
|
||||
required String originalApiKey,
|
||||
}) {
|
||||
if (originalHome == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return normalizedUrl != originalHome.url || apiKey != originalApiKey;
|
||||
}
|
||||
69
lib/features/homes/services/location_platform_service.dart
Normal file
69
lib/features/homes/services/location_platform_service.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
abstract class LocationPlatformService {
|
||||
Future<bool> isLocationServiceEnabled();
|
||||
|
||||
Future<LocationPermission> checkPermission();
|
||||
|
||||
Future<LocationPermission> requestPermission();
|
||||
|
||||
Future<Position?> getLastKnownPosition();
|
||||
|
||||
Future<Position> getCurrentPosition({
|
||||
required LocationSettings locationSettings,
|
||||
});
|
||||
|
||||
Stream<Position> getPositionStream({
|
||||
required LocationSettings locationSettings,
|
||||
});
|
||||
|
||||
Future<bool> openAppSettings();
|
||||
|
||||
Future<bool> openLocationSettings();
|
||||
}
|
||||
|
||||
class DeviceLocationPlatformService implements LocationPlatformService {
|
||||
@override
|
||||
Future<bool> isLocationServiceEnabled() {
|
||||
return Geolocator.isLocationServiceEnabled();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LocationPermission> checkPermission() {
|
||||
return Geolocator.checkPermission();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LocationPermission> requestPermission() {
|
||||
return Geolocator.requestPermission();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Position?> getLastKnownPosition() {
|
||||
return Geolocator.getLastKnownPosition();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Position> getCurrentPosition({
|
||||
required LocationSettings locationSettings,
|
||||
}) {
|
||||
return Geolocator.getCurrentPosition(locationSettings: locationSettings);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<Position> getPositionStream({
|
||||
required LocationSettings locationSettings,
|
||||
}) {
|
||||
return Geolocator.getPositionStream(locationSettings: locationSettings);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> openAppSettings() {
|
||||
return Geolocator.openAppSettings();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> openLocationSettings() {
|
||||
return Geolocator.openLocationSettings();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user