feat: add device authentication, place gates support, and PiP navigation features
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
class PlaceGate {
|
||||
final String nameAr;
|
||||
final String? nameEn;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final bool isMainGate;
|
||||
|
||||
const PlaceGate({
|
||||
required this.nameAr,
|
||||
this.nameEn,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
this.isMainGate = false,
|
||||
});
|
||||
|
||||
factory PlaceGate.fromJson(Map<String, dynamic> json) {
|
||||
return PlaceGate(
|
||||
nameAr: json['name_ar']?.toString() ?? json['gate_name_ar']?.toString() ?? 'بوابة',
|
||||
nameEn: json['name_en']?.toString() ?? json['gate_name_en']?.toString(),
|
||||
latitude: (json['latitude'] as num?)?.toDouble() ??
|
||||
(json['lat'] as num?)?.toDouble() ??
|
||||
double.tryParse(json['latitude']?.toString() ?? '0.0') ??
|
||||
0.0,
|
||||
longitude: (json['longitude'] as num?)?.toDouble() ??
|
||||
(json['lng'] as num?)?.toDouble() ??
|
||||
double.tryParse(json['longitude']?.toString() ?? '0.0') ??
|
||||
0.0,
|
||||
isMainGate: json['is_main_gate'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'name_ar': nameAr,
|
||||
if (nameEn != null) 'name_en': nameEn,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'is_main_gate': isMainGate,
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'place_gate.dart';
|
||||
|
||||
class PlaceModel {
|
||||
final String id;
|
||||
final String name;
|
||||
@@ -7,6 +9,7 @@ class PlaceModel {
|
||||
final double elevationMeters; // GPS Altitude AMSL in meters (defaults to 0.0)
|
||||
final double? distanceKm;
|
||||
final String? address;
|
||||
final List<PlaceGate> gates;
|
||||
|
||||
PlaceModel({
|
||||
required this.id,
|
||||
@@ -17,8 +20,11 @@ class PlaceModel {
|
||||
this.elevationMeters = 0.0,
|
||||
this.distanceKm,
|
||||
this.address,
|
||||
this.gates = const [],
|
||||
});
|
||||
|
||||
bool get hasGates => gates.isNotEmpty;
|
||||
|
||||
factory PlaceModel.fromJson(Map<String, dynamic> json) {
|
||||
final rawElev = json['elevation_meters'] ?? json['elevation'] ?? json['altitude'] ?? 0.0;
|
||||
double elev = 0.0;
|
||||
@@ -28,6 +34,14 @@ class PlaceModel {
|
||||
elev = double.tryParse(rawElev.toString()) ?? 0.0;
|
||||
}
|
||||
|
||||
final rawGates = json['gates'];
|
||||
List<PlaceGate> parsedGates = [];
|
||||
if (rawGates is List) {
|
||||
parsedGates = rawGates
|
||||
.map((g) => PlaceGate.fromJson(Map<String, dynamic>.from(g)))
|
||||
.toList();
|
||||
}
|
||||
|
||||
return PlaceModel(
|
||||
id: json['id']?.toString() ?? '',
|
||||
name: json['name']?.toString() ?? '',
|
||||
@@ -39,6 +53,7 @@ class PlaceModel {
|
||||
? (json['distanceKm'] as num).toDouble()
|
||||
: null,
|
||||
address: json['address']?.toString() ?? json['neighborhood']?.toString(),
|
||||
gates: parsedGates,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,6 +67,7 @@ class PlaceModel {
|
||||
'elevation_meters': elevationMeters,
|
||||
'altitude': elevationMeters,
|
||||
if (address != null) 'address': address,
|
||||
if (gates.isNotEmpty) 'gates': gates.map((g) => g.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user