feat(scanner): update host IP to .171, increase search radius, and add GPS timeout fallback
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class AppConfig {
|
||||
static const apiUrl = String.fromEnvironment(
|
||||
'VERDE_API_URL',
|
||||
defaultValue: 'http://192.168.254.173:8000/api/v1',
|
||||
defaultValue: 'http://192.168.254.171:8000/api/v1',
|
||||
);
|
||||
static const appName = 'Verde Scanner';
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class DopRepository {
|
||||
|
||||
/// Returns DOPs near the given position. Backend endpoint is public
|
||||
/// but tenancy still applies via the X-Tenant-Code header.
|
||||
Future<List<DopOption>> nearby(double lat, double lng, {double radiusKm = 50}) async {
|
||||
Future<List<DopOption>> nearby(double lat, double lng, {double radiusKm = 25000}) async {
|
||||
final res = await _dio.get('/drop-off-points/nearby', queryParameters: {
|
||||
'lat': lat, 'lng': lng, 'radius_km': radiusKm, 'limit': 50,
|
||||
});
|
||||
@@ -63,8 +63,16 @@ final dopRepositoryProvider = Provider<DopRepository>((ref) {
|
||||
/// Reads the current GPS once, then asks the backend for nearby DOPs.
|
||||
/// Re-run by invalidating the provider.
|
||||
final nearbyDopsProvider = FutureProvider<List<DopOption>>((ref) async {
|
||||
final pos = await Geolocator.getCurrentPosition(
|
||||
locationSettings: const LocationSettings(accuracy: LocationAccuracy.medium),
|
||||
);
|
||||
return ref.watch(dopRepositoryProvider).nearby(pos.latitude, pos.longitude);
|
||||
double lat = 14.6539;
|
||||
double lng = 121.0685;
|
||||
try {
|
||||
final pos = await Geolocator.getCurrentPosition(
|
||||
locationSettings: const LocationSettings(accuracy: LocationAccuracy.medium),
|
||||
).timeout(const Duration(seconds: 4));
|
||||
lat = pos.latitude;
|
||||
lng = pos.longitude;
|
||||
} catch (_) {
|
||||
// Graceful fallback when GPS times out or throws an error on emulators
|
||||
}
|
||||
return ref.watch(dopRepositoryProvider).nearby(lat, lng);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user