feat: implement splash and onboarding flows, update app assets, and add project design documentation
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'gate_model.dart';
|
||||
|
||||
/// نموذج مكان من نتائج البحث (autocomplete / geocode).
|
||||
/// نموذج مكان من نتائج بحث انطلق (geocode / search).
|
||||
class PlaceModel extends Equatable {
|
||||
final String? placeId;
|
||||
final String name;
|
||||
final String? address;
|
||||
final double lat;
|
||||
final double lng;
|
||||
final String? category;
|
||||
final double? totalScore;
|
||||
final String? source;
|
||||
final List<Gate> gates;
|
||||
|
||||
const PlaceModel({
|
||||
this.placeId,
|
||||
@@ -14,32 +19,53 @@ class PlaceModel extends Equatable {
|
||||
this.address,
|
||||
required this.lat,
|
||||
required this.lng,
|
||||
this.category,
|
||||
this.totalScore,
|
||||
this.source,
|
||||
this.gates = const [],
|
||||
});
|
||||
|
||||
factory PlaceModel.fromJson(Map<String, dynamic> j) => PlaceModel(
|
||||
placeId: j['placeId'] as String?,
|
||||
name: (j['description'] ?? j['name'] ?? '') as String,
|
||||
address: j['address'] as String?,
|
||||
lat: (j['lat'] as num).toDouble(),
|
||||
lng: (j['lng'] as num).toDouble(),
|
||||
);
|
||||
|
||||
factory PlaceModel.fromGeocode(Map<String, dynamic> j) => PlaceModel(
|
||||
placeId: j['placeId'] as String?,
|
||||
name: (j['name'] ?? j['formattedAddress'] ?? '') as String,
|
||||
address: j['formattedAddress'] as String?,
|
||||
lat: (j['lat'] as num).toDouble(),
|
||||
lng: (j['lng'] as num).toDouble(),
|
||||
);
|
||||
/// استجابة انطلق الحقيقية — الحقول الم标准.
|
||||
factory PlaceModel.fromJson(Map<String, dynamic> j) {
|
||||
final lat = (j['latitude'] ?? j['location']?['lat'] ?? 0) as num;
|
||||
final lng = (j['longitude'] ?? j['location']?['lng'] ?? 0) as num;
|
||||
return PlaceModel(
|
||||
placeId: j['id'] as String?,
|
||||
name: (j['name'] ?? '') as String,
|
||||
address: (j['full_address'] ?? j['address']) as String?,
|
||||
lat: lat.toDouble(),
|
||||
lng: lng.toDouble(),
|
||||
category: j['category'] as String?,
|
||||
totalScore: (j['totalScore'] as num?)?.toDouble(),
|
||||
source: j['source'] as String?,
|
||||
gates: (j['gates'] as List?)
|
||||
?.map((g) => Gate.fromJson(g as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
if (placeId != null) 'placeId': placeId,
|
||||
if (placeId != null) 'id': placeId,
|
||||
'name': name,
|
||||
if (address != null) 'address': address,
|
||||
'lat': lat,
|
||||
'lng': lng,
|
||||
if (address != null) 'full_address': address,
|
||||
'latitude': lat,
|
||||
'longitude': lng,
|
||||
if (category != null) 'category': category,
|
||||
if (totalScore != null) 'totalScore': totalScore,
|
||||
if (source != null) 'source': source,
|
||||
};
|
||||
|
||||
/// هل لهذا المكان أبواب متعددة?
|
||||
bool get hasMultipleGates => gates.length > 1;
|
||||
|
||||
/// الباب الرئيسي إن وُجد.
|
||||
Gate? get mainGate => gates.cast<Gate?>().firstWhere(
|
||||
(g) => g!.isMainGate,
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [placeId, name, address, lat, lng];
|
||||
List<Object?> get props =>
|
||||
[placeId, name, address, lat, lng, category, totalScore, source, gates];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user