feat: implement splash and onboarding flows, update app assets, and add project design documentation
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart';
|
||||
|
||||
/// باب/مدخل مكان — من استجابة انطلق.
|
||||
class Gate extends Equatable {
|
||||
final String nameAr;
|
||||
final String nameEn;
|
||||
final double lat;
|
||||
final double lng;
|
||||
final bool isMainGate;
|
||||
|
||||
const Gate({
|
||||
required this.nameAr,
|
||||
required this.nameEn,
|
||||
required this.lat,
|
||||
required this.lng,
|
||||
this.isMainGate = false,
|
||||
});
|
||||
|
||||
factory Gate.fromJson(Map<String, dynamic> j) => Gate(
|
||||
nameAr: (j['name_ar'] ?? '') as String,
|
||||
nameEn: (j['name_en'] ?? '') as String,
|
||||
lat: (j['latitude'] as num).toDouble(),
|
||||
lng: (j['longitude'] as num).toDouble(),
|
||||
isMainGate: j['is_main_gate'] as bool? ?? false,
|
||||
);
|
||||
|
||||
LatLng get latLng => LatLng(lat, lng);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [nameAr, nameEn, lat, lng, isMainGate];
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -1,25 +1,44 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart';
|
||||
|
||||
/// خطاب polyline مشفر ومسافة/وقت تقريبيان.
|
||||
/// استجابة مسار من انطلق — مع polyline مشفر وإطار خريطة.
|
||||
class RouteModel extends Equatable {
|
||||
final int distanceMeters;
|
||||
final int durationSeconds;
|
||||
final String? polyline;
|
||||
final String? routeName;
|
||||
final String? startName;
|
||||
final String? endName;
|
||||
final List<String>? tags;
|
||||
final List<double>? bbox;
|
||||
final double? trafficFactor;
|
||||
|
||||
const RouteModel({
|
||||
required this.distanceMeters,
|
||||
required this.durationSeconds,
|
||||
this.polyline,
|
||||
this.routeName,
|
||||
this.startName,
|
||||
this.endName,
|
||||
this.tags,
|
||||
this.bbox,
|
||||
this.trafficFactor,
|
||||
});
|
||||
|
||||
/// استجابة مسار انطلق الحقيقية (تُمرر عبر الباك إند كما هي).
|
||||
factory RouteModel.fromJson(Map<String, dynamic> j) {
|
||||
final dist = j['distanceMeters'] ?? j['distance'];
|
||||
final dur = j['durationSeconds'] ?? j['duration'];
|
||||
final dist = (j['distance'] ?? 0) as num;
|
||||
final dur = (j['duration'] ?? 0) as num;
|
||||
return RouteModel(
|
||||
distanceMeters: dist is int ? dist : int.tryParse('$dist') ?? 0,
|
||||
durationSeconds: dur is int ? dur : int.tryParse('$dur') ?? 0,
|
||||
polyline: j['polyline'] as String?,
|
||||
distanceMeters: dist.toInt(),
|
||||
durationSeconds: dur.toInt(),
|
||||
polyline: j['points'] as String?,
|
||||
routeName: j['routeName'] as String?,
|
||||
startName: j['startName'] as String?,
|
||||
endName: j['endName'] as String?,
|
||||
tags: (j['tags'] as List?)?.cast<String>(),
|
||||
bbox: (j['bbox'] as List?)?.map((e) => (e as num).toDouble()).toList(),
|
||||
trafficFactor: (j['trafficFactor'] as num?)?.toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,39 +55,49 @@ class RouteModel extends Equatable {
|
||||
return '$h h ${rem > 0 ? '$rem min' : ''}';
|
||||
}
|
||||
|
||||
/// تحويل bbox إلى LatLngBounds لضبط الكاميرا مع حماية للمواقع القريبة على iOS.
|
||||
LatLngBounds? getLatLngBounds() {
|
||||
if (bbox == null || bbox!.length < 4) return null;
|
||||
var minLat = bbox![1];
|
||||
var minLng = bbox![0];
|
||||
var maxLat = bbox![3];
|
||||
var maxLng = bbox![2];
|
||||
|
||||
// إذا كانت المسافة بين النقاط قريبة جداً (أقل من 0.002 درجة)، نضمن توسعاً أمنياً أدنى لمنع عطل وقفل كاميرا MapLibre على iOS
|
||||
if ((maxLat - minLat).abs() < 0.002) {
|
||||
minLat -= 0.001;
|
||||
maxLat += 0.001;
|
||||
}
|
||||
if ((maxLng - minLng).abs() < 0.002) {
|
||||
minLng -= 0.001;
|
||||
maxLng += 0.001;
|
||||
}
|
||||
|
||||
return LatLngBounds(
|
||||
southwest: LatLng(minLat, minLng),
|
||||
northeast: LatLng(maxLat, maxLng),
|
||||
);
|
||||
}
|
||||
|
||||
/// فك الـ polyline عبر PolylineUtils من الباكيج.
|
||||
List<LatLng> decodePolyline() {
|
||||
if (polyline == null || polyline!.isEmpty) return [];
|
||||
return _decodeEncodedPolyline(polyline!);
|
||||
return PolylineUtils.decode(polyline!);
|
||||
}
|
||||
|
||||
/// فك تشفير polyline وفقاً لخوارزمية Google.
|
||||
static List<LatLng> _decodeEncodedPolyline(String encoded) {
|
||||
final List<LatLng> poly = [];
|
||||
int index = 0, lat = 0, lng = 0;
|
||||
|
||||
while (index < encoded.length) {
|
||||
int b, shift = 0, result = 0;
|
||||
do {
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
lat += ((result & 1) != 0) ? ~(result >> 1) : (result >> 1);
|
||||
|
||||
shift = 0;
|
||||
result = 0;
|
||||
do {
|
||||
b = encoded.codeUnitAt(index++) - 63;
|
||||
result |= (b & 0x1f) << shift;
|
||||
shift += 5;
|
||||
} while (b >= 0x20);
|
||||
lng += ((result & 1) != 0) ? ~(result >> 1) : (result >> 1);
|
||||
|
||||
poly.add(LatLng(lat / 1e5, lng / 1e5));
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
/// هل المسار مباشر (لا أضلاع)?
|
||||
bool get isStraightLine => tags?.contains('straight-line') ?? false;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [distanceMeters, durationSeconds, polyline];
|
||||
List<Object?> get props => [
|
||||
distanceMeters,
|
||||
durationSeconds,
|
||||
polyline,
|
||||
routeName,
|
||||
startName,
|
||||
endName,
|
||||
tags,
|
||||
bbox,
|
||||
trafficFactor,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user