build: setup compose multiplatform

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
Aditya Wasan 2021-03-14 21:24:46 +05:30
parent c5fafba7b5
commit 9517531388
No known key found for this signature in database
GPG key ID: 6D6DF3BF15DE79B5
12 changed files with 96 additions and 11 deletions

View file

@ -0,0 +1,17 @@
package dev.msfjarvis.lobsters.ui.urllauncher
import android.content.Context
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import dev.msfjarvis.lobsters.ui.urllauncher.UrlLauncher
class AndroidUrlLauncherImpl(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))
}
}

View file

@ -0,0 +1,5 @@
package dev.msfjarvis.lobsters.ui.urllauncher
import androidx.compose.runtime.staticCompositionLocalOf
val LocalUrlLauncher = staticCompositionLocalOf { error("Needs to be provided") }

View file

@ -0,0 +1,5 @@
package dev.msfjarvis.lobsters.ui.urllauncher
fun interface UrlLauncher {
fun launch(url: String)
}

View file

@ -0,0 +1,14 @@
package dev.msfjarvis.lobsters.ui.urllauncher
import java.awt.Desktop
import java.net.URI
class JVMLocalLauncherImpl() : UrlLauncher {
override fun launch(url: String) {
val desktop = Desktop.getDesktop()
if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) {
desktop.browse(URI(url))
}
}
}

View file

@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.msfjarvis.lobsters" />