Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoltk authored Oct 26, 2023
2 parents ba0c150 + f9dfd2b commit 451e23f
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/web_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:

- name: Move Output to Directory
run: |
mkdir distribution
mv webApp/build/dist/js/productionExecutable/* distribution/
mkdir docs
mv webApp/build/dist/js/productionExecutable/* docs/
# Commit and push the directory to a specified branch (e.g., "output-branch")
- name: Commit and Push to Branch
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add distribution/
git add docs/
git commit -m "Add output from build"
git push -f origin HEAD:deploy-branch
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ detekt = "1.22.0"
junit5 = "5.8.2"
jvmTarget = "17"
kotlin = "1.9.10"
kotlinxDatetime = "0.4.1"
ksp = "1.9.10-1.0.13"
resources = "0.22.3"
serialization-json = "1.5.0"
Expand Down Expand Up @@ -66,6 +67,7 @@ kotlin-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-s
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
kotlin-coroutines-test-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm", version.ref = "coroutines" }
kotlin-coroutines-rx2 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "coroutines" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization-json" }

rxjava2 = "io.reactivex.rxjava2:rxjava:2.2.21"
Expand Down
1 change: 1 addition & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ kotlin {
api(libs.appyx.components.backstack)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(libs.kotlinx.datetime)
}
}
val commonTest by getting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bumble.livemosaic.model.MosaicConfig.MOSAIC1
import com.bumble.livemosaic.model.MosaicConfig.MOSAIC2
import com.bumble.livemosaic.model.MosaicConfig.MOSAIC3
import com.bumble.livemosaic.participant.ClockWidget

val entries = listOf(
Entry.Text(
Expand All @@ -49,7 +49,7 @@ val entries = listOf(
mosaic = MOSAIC1,
githubUserName = "manuelvicnt",
message = "Don't miss the UI layer talk on Friday at 10:15am!!!! See you at Lovelace ;)"
),
),
Entry.Text(
mosaic = MOSAIC1,
githubUserName = "Cassnyo",
Expand Down Expand Up @@ -210,7 +210,14 @@ val entries = listOf(
mosaic = MOSAIC1,
githubUserName = "edward1432",
message = "Best wishes from all LBG Android Devs!"
)
),
Entry.ComposableContent(
mosaic = MOSAIC1,
githubUserName = "zsmb13",
content = {
ClockWidget(Modifier.background(Color.DarkGray).fillMaxSize())
}
),
)

val mosaic1Entries = entries
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package com.bumble.livemosaic.participant

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.animateSizeAsState
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bumble.livemosaic.composable.scaleFactor
import com.bumble.livemosaic.ui.appyx_dark
import com.bumble.livemosaic.ui.appyx_yellow1
import com.bumble.livemosaic.ui.appyx_yellow2
import kotlinx.coroutines.delay
import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime

data class Time(val hours: Int, val minutes: Int, val seconds: Int)

@Composable
fun ClockWidget(modifier: Modifier = Modifier) {
fun currentTime(): Time {
val cal = Clock.System.now()
val dateTime: LocalDateTime = cal.toLocalDateTime(TimeZone.of("Europe/London"))
return Time(
hours = dateTime.hour,
minutes = dateTime.minute,
seconds = dateTime.second,
)
}

var time by remember { mutableStateOf(currentTime()) }
LaunchedEffect(0) {
while (true) {
time = currentTime()
delay(1000)
}
}

Clock(time, modifier)
}

@Composable
fun Clock(time: Time, modifier: Modifier = Modifier) {
Row(
modifier = modifier.fillMaxSize(),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
val padding = Modifier.padding(horizontal = 2.dp * scaleFactor())

NumberColumn(time.hours / 10, 0..2, padding)
NumberColumn(time.hours % 10, 0..9, padding)

Spacer(Modifier.size(8.dp * scaleFactor()))

NumberColumn(time.minutes / 10, 0..5, padding)
NumberColumn(time.minutes % 10, 0..9, padding)

Spacer(Modifier.size(8.dp * scaleFactor()))

NumberColumn(time.seconds / 10, 0..5, padding)
NumberColumn(time.seconds % 10, 0..9, padding)
}
}

@Composable
fun NumberColumn(
current: Int,
range: IntRange,
modifier: Modifier = Modifier,
) {
val size = 20.dp * scaleFactor()

val mid = (range.last - range.first) / 2f
val reset = current == range.first
val offset by animateDpAsState(
targetValue = size * (mid - current),
animationSpec = if (reset) {
spring(
dampingRatio = Spring.DampingRatioLowBouncy,
stiffness = Spring.StiffnessLow,
)
} else {
tween(
durationMillis = 300,
easing = LinearOutSlowInEasing,
)
}
)

val dens = LocalDensity.current.density
Column(
modifier
.offset {
IntOffset(0, (offset.value * dens).toInt())
}
.requiredHeight(IntrinsicSize.Max)
.clip(RoundedCornerShape(percent = 25))
) {
for (num in range) {
Number(num == current, num, size)
}
}
}

@Composable
fun Number(active: Boolean, value: Int, size: Dp, modifier: Modifier = Modifier) {
val backgroundColor by animateColorAsState(
if (active) appyx_yellow1 else appyx_yellow2,
)
val textSize by animateFloatAsState(
if (active) 12f else 8f,
)

Box(
modifier = modifier.background(backgroundColor).size(size),
contentAlignment = Alignment.Center,
) {
Text(
text = value.toString(),
fontSize = textSize.sp * scaleFactor(),
color = appyx_dark,
fontWeight = if (active) FontWeight.Bold else FontWeight.Normal,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale

private const val EMBED_URL = "https://github.com/bumble-tech/live-mosaic/blob/deploy-branch/distribution/"
private const val EMBED_URL = "live-mosaic/"

@Composable
actual fun EmbeddableResourceImage(
Expand Down
4 changes: 3 additions & 1 deletion webApp/src/jsMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.navigation.integration.ScreenSize
import com.bumble.appyx.navigation.integration.WebNodeHost
import com.bumble.livemosaic.node.app.LiveMosaicAppNode
Expand All @@ -32,10 +33,11 @@ import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import org.jetbrains.skiko.wasm.onWasmReady

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
val events: Channel<Unit> = Channel()
onWasmReady {
BrowserViewportWindow() {
CanvasBasedWindow {
LiveMosaicTheme {
val requester = remember { FocusRequester() }
var hasFocus by remember { mutableStateOf(false) }
Expand Down

0 comments on commit 451e23f

Please sign in to comment.