This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface GPSService { | |
| suspend fun userGPSCoordinates(): GPSCoordinates? | |
| } | |
| data class GPSCoordinates( | |
| val latitude: Double, | |
| val longitude: Double | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AndroidGPSService( | |
| private val context: Context | |
| ) : GPSService { | |
| // withContext is necessary here because location queries need to be done in the UI Thread | |
| override suspend fun userGPSCoordinates() = withContext(Dispatchers.Main.immediate) { | |
| suspendCancellableCoroutine { continuation -> | |
| // PermissionUtils checks permission using ContextCompat.checkSelfPermission(...) and returns true if granted | |
| if (PermissionUtils.hasPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)) { | |
| val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class IOSGPSService: GPSService { | |
| private let asyncLocationManager = AsyncLocationManager(desiredAccuracy: .threeKilometersAccuracy) | |
| func userGPSCoordinates() async throws -> GPSCoordinates? { | |
| switch asyncLocationManager.getAuthorizationStatus() { | |
| case .authorizedAlways, .authorizedWhenInUse: | |
| let locationUpdate = try? await asyncLocationManager.requestLocation() | |
| switch locationUpdate { | |
| case .didUpdateLocations(let locations): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun restaurantsNearUser(): Flow<List<Restaurant>> = | |
| flow { | |
| emit(null) | |
| gpsService.currentUserLocation().also { location -> | |
| emit(location) | |
| } | |
| } | |
| .map { userLocation -> | |
| buildRestaurantList(userLocation) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Common Code | |
| interface Bootstrap { | |
| val gpsService: GPSService | |
| } | |
| class KoinBootstrap : KoinComponent { | |
| fun initDependencies(bootstrap: Bootstrap) = startKoin { | |
| configureKoin(bootstrap) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.os.Bundle | |
| import androidx.activity.ComponentActivity | |
| import androidx.activity.compose.setContent | |
| import androidx.activity.enableEdgeToEdge | |
| import androidx.compose.animation.AnimatedContent | |
| import androidx.compose.animation.AnimatedVisibilityScope | |
| import androidx.compose.animation.ExperimentalSharedTransitionApi | |
| import androidx.compose.animation.SharedTransitionLayout | |
| import androidx.compose.animation.SharedTransitionScope | |
| import androidx.compose.animation.core.tween |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.os.Bundle | |
| import androidx.activity.ComponentActivity | |
| import androidx.activity.compose.setContent | |
| import androidx.activity.enableEdgeToEdge | |
| import androidx.compose.animation.AnimatedVisibility | |
| import androidx.compose.animation.AnimatedVisibilityScope | |
| import androidx.compose.animation.EnterTransition | |
| import androidx.compose.animation.ExitTransition | |
| import androidx.compose.animation.expandIn | |
| import androidx.compose.animation.fadeIn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class Message( | |
| val id: Int, | |
| val text: String, | |
| val isFromMe: Boolean, | |
| var reaction: String? = null | |
| ) | |
| class MainActivity : ComponentActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.os.Bundle | |
| import androidx.activity.ComponentActivity | |
| import androidx.activity.compose.setContent | |
| import androidx.activity.enableEdgeToEdge | |
| import androidx.activity.SystemBarStyle | |
| import androidx.compose.animation.Crossfade | |
| import androidx.compose.animation.animateColorAsState | |
| import androidx.compose.animation.core.animateDpAsState | |
| import androidx.compose.animation.core.tween | |
| import androidx.compose.foundation.background |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| id("com.github.johnrengelman.shadow") version "8.1.1" | |
| } | |
| configurations { | |
| create("aarToRepackage") | |
| } | |
| dependencies { | |
| // Point to the original Lib-A AAR |
OlderNewer