mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 00:57:02 +05:30
build: setup compose multiplatform
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
parent
c5fafba7b5
commit
9517531388
12 changed files with 96 additions and 11 deletions
|
@ -7,13 +7,13 @@ import dagger.hilt.InstallIn
|
|||
import dagger.hilt.android.components.ActivityComponent
|
||||
import dagger.hilt.android.qualifiers.ActivityContext
|
||||
import dev.msfjarvis.lobsters.ui.urllauncher.UrlLauncher
|
||||
import dev.msfjarvis.lobsters.ui.urllauncher.UrlLauncherImpl
|
||||
import dev.msfjarvis.lobsters.ui.urllauncher.AndroidUrlLauncherImpl
|
||||
|
||||
@Module
|
||||
@InstallIn(ActivityComponent::class)
|
||||
object UrlLauncherModule {
|
||||
@Provides
|
||||
fun provideUrlLauncher(@ActivityContext context: Context): UrlLauncher {
|
||||
return UrlLauncherImpl(context)
|
||||
return AndroidUrlLauncherImpl(context)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.urllauncher
|
||||
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
|
||||
val LocalUrlLauncher = staticCompositionLocalOf<UrlLauncher> { error("Needs to be provided") }
|
|
@ -1,5 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.urllauncher
|
||||
|
||||
fun interface UrlLauncher {
|
||||
fun launch(url: String)
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.urllauncher
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
|
||||
class UrlLauncherImpl(private val context: Context) : UrlLauncher {
|
||||
override fun launch(url: String) {
|
||||
val customTabsIntent = CustomTabsIntent.Builder()
|
||||
.setShareState(CustomTabsIntent.SHARE_STATE_ON)
|
||||
.setShowTitle(true)
|
||||
.setColorScheme(CustomTabsIntent.COLOR_SCHEME_DARK)
|
||||
.build()
|
||||
customTabsIntent.launchUrl(context, Uri.parse(url))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue