mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 12:07:03 +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
58
common/build.gradle.kts
Normal file
58
common/build.gradle.kts
Normal file
|
@ -0,0 +1,58 @@
|
|||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.compose") version "0.4.0-build173"
|
||||
`lobsters-plugin`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
google()
|
||||
}
|
||||
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
|
||||
// workaround for https://youtrack.jetbrains.com/issue/KT-43944
|
||||
android {
|
||||
configurations {
|
||||
create("androidTestApi")
|
||||
create("androidTestDebugApi")
|
||||
create("androidTestReleaseApi")
|
||||
create("testApi")
|
||||
create("testDebugApi")
|
||||
create("testReleaseApi")
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
android()
|
||||
|
||||
sourceSets {
|
||||
val androidMain by getting {
|
||||
dependencies {
|
||||
implementation(Dependencies.AndroidX.Compose.runtime)
|
||||
implementation(Dependencies.AndroidX.browser)
|
||||
}
|
||||
}
|
||||
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(Dependencies.AndroidX.Compose.runtime)
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(Dependencies.AndroidX.Compose.runtime)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package dev.msfjarvis.lobsters.ui.urllauncher
|
||||
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
|
||||
val LocalUrlLauncher = staticCompositionLocalOf { error("Needs to be provided") }
|
|
@ -0,0 +1,5 @@
|
|||
package dev.msfjarvis.lobsters.ui.urllauncher
|
||||
|
||||
fun interface UrlLauncher {
|
||||
fun launch(url: String)
|
||||
}
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
2
common/src/main/AndroidManifest.xml
Normal file
2
common/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="dev.msfjarvis.lobsters" />
|
Loading…
Add table
Add a link
Reference in a new issue