Skip to content

Commit

Permalink
Setup default project
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Jordan committed Oct 13, 2023
1 parent 541d8ca commit 799437c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
11 changes: 6 additions & 5 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ kotlin {
}
}

// js(IR) {
// // Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
// moduleName = "puzzyx-common"
// browser()
// }
js(IR) {
// Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942
moduleName = "puzzyx-common"
browser()
}

sourceSets {
val commonMain by getting {
Expand Down Expand Up @@ -63,4 +63,5 @@ dependencies {
add("kspCommonMainMetadata", libs.appyx.mutable.ui.processor)
add("kspAndroid", libs.appyx.mutable.ui.processor)
add("kspDesktop", libs.appyx.mutable.ui.processor)
add("kspJs", libs.appyx.mutable.ui.processor)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class ClipShapeProgress(
coroutineScope: CoroutineScope,
target: Target,
displacement: StateFlow<Float> = MutableStateFlow(0f),
private val shape: @Composable (progress: Float) -> Shape = { RectangleShape },
// web-target doesn't like a lambda here for some reason
private val shape: @Composable ((progress: Float) -> Shape)? = null,
) : MotionProperty<Float, AnimationVector1D>(
coroutineScope = coroutineScope,
animatable = Animatable(target.value),
Expand All @@ -47,10 +48,9 @@ class ClipShapeProgress(
get() = Modifier.composed {
val progress = renderValueFlow.collectAsState().value
if (progress == 0f) this
else this.clip(shape.invoke(progress))
else this.clip(shape?.invoke(progress) ?: RectangleShape)
}


override suspend fun lerpTo(start: Target, end: Target, fraction: Float) {
snapTo(
lerpFloat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import androidx.compose.ui.unit.LayoutDirection
import com.bumble.appyx.interactions.core.annotations.FloatRange
import com.bumble.appyx.interactions.core.ui.math.lerpFloat
import com.bumble.puzzyx.math.mapValueRange
import java.lang.Integer.max
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.bumble.puzzyx.imageloader

import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.toComposeImageBitmap

actual fun ByteArray.toImageBitmap(): ImageBitmap {
return org.jetbrains.skia.Image.makeFromEncoded(this).toComposeImageBitmap()
}
7 changes: 5 additions & 2 deletions webApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kotlin {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
// implementation(project(":shared"))
implementation(project(":shared"))
implementation(libs.appyx.navigation)
implementation(libs.appyx.components.backstack)
}
Expand All @@ -39,7 +39,10 @@ tasks.register<Copy>("copyResources") {
include("**/*")
}

tasks.named("jsMainClasses") {
tasks.named("jsBrowserProductionExecutableDistributeResources") {
dependsOn("copyResources")
}

tasks.named("compileKotlinJs") {
dependsOn("copyResources")
}
15 changes: 15 additions & 0 deletions webApp/src/jsMain/resources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Puzzyx</title>
<script src="skiko.js"></script>
<link type="text/css" rel="stylesheet" href="styles.css"/>
</head>
<body>
<div>
<canvas id="ComposeTarget" width="512" height="512"></canvas>
</div>
<script src="webApp.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions webApp/src/jsMain/resources/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#root {
width: 100%;
height: 100vh;
}

body {
margin: 0;
}

#root > .compose-web-column > div {
position: relative;
}

0 comments on commit 799437c

Please sign in to comment.