Since many use cases should use an Activity Context rather than the Application Context on Android to work properly (mostly to launch Intents), refactor these use cases to take a PlatformContext argument and use it to wrap the Android Context on Android.
Move PlatformContext from the ui module to the domain module so it can be referenced from use cases.
Define PlatformContext as an empty object on iOS and a class containing a Context reference on Android.
Replace LocalPlatformContext CompositionLocal with an expect getPlatformContext() composable function. There is no need to create a new CompositionLocal because Android already has LocalContext to carry the Context over to any composable function, and an expect function is safer because it guarantees that a non-null PlatformContext is provided for every platform at compile time.
Update UrlOpener, OpenMapUseCase, ApplyForAppClinicUseCase, OpenCocUseCase, OpenFaqUseCase, OpenLinkUseCase, OpenPartnerLinkUseCase, OpenXAccountUseCase, OpenXHashtagUseCase, OpenYoutubeUseCase, ShareSessionUseCase to accept a PlatformContext as first argument.
Update the Android implementation of ShareSessionUseCase to use ShareCompat.IntentBuilder from the androidx.core library.
Use safer Uri.Builder instead of custom String formatting to build map Uri.
Since many use cases should use an Activity Context rather than the Application Context on Android to work properly (mostly to launch Intents), refactor these use cases to take a
PlatformContext
argument and use it to wrap the Android Context on Android.PlatformContext
from the ui module to the domain module so it can be referenced from use cases.PlatformContext
as an empty object on iOS and a class containing aContext
reference on Android.LocalPlatformContext
CompositionLocal with anexpect getPlatformContext()
composable function. There is no need to create a new CompositionLocal because Android already hasLocalContext
to carry the Context over to any composable function, and an expect function is safer because it guarantees that a non-nullPlatformContext
is provided for every platform at compile time.UrlOpener
,OpenMapUseCase
,ApplyForAppClinicUseCase
,OpenCocUseCase
,OpenFaqUseCase
,OpenLinkUseCase
,OpenPartnerLinkUseCase
,OpenXAccountUseCase
,OpenXHashtagUseCase
,OpenYoutubeUseCase
,ShareSessionUseCase
to accept aPlatformContext
as first argument.ShareSessionUseCase
to useShareCompat.IntentBuilder
from the androidx.core library.Uri.Builder
instead of custom String formatting to build mapUri
.