shared(location): move AndroidLocationProvider to shared/androidMain; add play-services-location and coroutines-play-services deps; add iOS stub

app(main): update imports and keep using centralized provider for startup, auto-scans, and “Nearby” flow
This commit is contained in:
2025-09-14 19:33:00 +02:00
parent 5eb96a0ff1
commit dac05a23d4
5 changed files with 14 additions and 8 deletions

View File

@@ -0,0 +1,25 @@
package app.klottr.location
import android.content.Context
import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority
import kotlinx.coroutines.tasks.await
/** Android-implementation som använder FusedLocationProvider. */
object AndroidLocationProvider : LocationProvider {
/** Hämtar lastLocation och faller tillbaka till getCurrentLocation. */
suspend fun currentOrLastKnown(context: Context): GeoPoint? {
val client = LocationServices.getFusedLocationProviderClient(context)
return try {
val last = client.lastLocation.await()
val loc = last ?: client.getCurrentLocation(Priority.PRIORITY_HIGH_ACCURACY, null).await()
loc?.let { GeoPoint(it.latitude, it.longitude) }
} catch (_: Exception) {
null
}
}
// Interface-override finns för framtida DI utan Context (används ej av :app idag).
override suspend fun currentOrLastKnown(): GeoPoint? = null
}

View File

@@ -0,0 +1,6 @@
package app.klottr.location
/** iOS-stub tills riktig plats läggs till. */
object IosLocationProvider : LocationProvider {
override suspend fun currentOrLastKnown(): GeoPoint? = null
}