Skip to content

Commit

Permalink
Merge branch 'main' of github.com:manuel-martos/puzzyx
Browse files Browse the repository at this point in the history
  • Loading branch information
mmartosdev committed Sep 27, 2023
2 parents 05a4ecb + bc96b14 commit bdee04d
Show file tree
Hide file tree
Showing 27 changed files with 456 additions and 101 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on: [push]

env:
CI:

jobs:
build:
name: Build
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/gradle-build-action@v2
- name: Build
run: ./gradlew :desktopApp:packageReleaseStripArchitecture
- name: Upload distributable
uses: actions/upload-artifact@v3
with:
name: Distributable
path: |
desktopApp/build/distributable/
25 changes: 23 additions & 2 deletions desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ kotlin {
sourceSets {
val desktopMain by getting {
dependencies {
// Tricky way to ensure CI builds ARM64 artifacts
val isCIPresent = providers.environmentVariable("CI").isPresent
val composeDependency =
if (isCIPresent) compose.desktop.macos_arm64 else compose.desktop.currentOs

implementation(project(":shared"))
implementation(compose.desktop.currentOs)
implementation(composeDependency)
implementation(libs.appyx.navigation)
implementation(libs.kotlin.coroutines.core)
implementation(libs.kotlin.coroutines.swing)
Expand All @@ -31,8 +36,24 @@ compose.desktop {

nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "desktopApp"
packageName = "puzzyx-desktop"
packageVersion = "1.0.0"
}
}
}

tasks.register<Copy>("packageReleaseStripArchitecture") {
from("build/compose/jars")
// Due to GitHub Actions' lack of support for arm64 macOS virtual machines, we've removed
// the architecture component from our distributable filename. We've enforced the use of
// the arm64 architecture in our dependencies, as shown in 'dependencies' section above.
rename {
it.split("-").run {
slice(0 until size - 2) + last()
}.joinToString("-")
}
into("build/distributable")
}.configure {
dependsOn(tasks.named("packageReleaseUberJarForCurrentOS"))
}

1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ google-accompanist-flow = { module = "com.google.accompanist:accompanist-flowlay
google-material = "com.google.android.material:material:1.4.0"
compose-image-loader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "image-loader-version"}
junit = "junit:junit:4.13.2"
k5-compose = "me.nikhilchaudhari:k5-compose:1.0.1"
kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlin-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
Expand Down
1 change: 1 addition & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kotlin {
api(libs.compose.image.loader)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(libs.k5.compose)
}
}
val commonTest by getting {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bumble.puzzyx.component.backstackclipper
package com.bumble.puzzyx.appyx.component.backstackclipper

import androidx.compose.animation.core.SpringSpec
import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bumble.puzzyx.component.backstackclipper
package com.bumble.puzzyx.appyx.component.backstackclipper

import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bumble.puzzyx.component.backstackclipper
package com.bumble.puzzyx.appyx.component.backstackclipper

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Shape
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.bumble.puzzyx.component.gridpuzzle
package com.bumble.puzzyx.appyx.component.gridpuzzle

import androidx.compose.animation.core.SpringSpec
import com.bumble.appyx.interactions.core.model.BaseAppyxComponent
import com.bumble.appyx.interactions.core.ui.helper.DefaultAnimationSpec
import com.bumble.appyx.navigation.state.SavedStateMap
import com.bumble.puzzyx.puzzle.PuzzlePiece
import com.bumble.puzzyx.model.PuzzlePiece

class GridPuzzle(
savedStateMap: SavedStateMap? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bumble.puzzyx.component.gridpuzzle
package com.bumble.puzzyx.appyx.component.gridpuzzle

import com.bumble.appyx.interactions.core.Element
import com.bumble.appyx.interactions.core.Elements
Expand All @@ -7,8 +7,8 @@ import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel
import com.bumble.appyx.navigation.state.SavedStateMap
import com.bumble.appyx.utils.multiplatform.Parcelable
import com.bumble.appyx.utils.multiplatform.Parcelize
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.SCATTERED
import com.bumble.puzzyx.puzzle.PuzzlePiece
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.SCATTERED
import com.bumble.puzzyx.model.PuzzlePiece

class GridPuzzleModel(
savedStateMap: SavedStateMap? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bumble.puzzyx.component.gridpuzzle
package com.bumble.puzzyx.appyx.component.gridpuzzle

import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.SpringSpec
Expand All @@ -16,12 +16,12 @@ import com.bumble.appyx.interactions.core.ui.property.impl.position.BiasAlignmen
import com.bumble.appyx.interactions.core.ui.property.impl.position.PositionInside.Target
import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState
import com.bumble.appyx.transitionmodel.BaseMotionController
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.ASSEMBLED
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.CAROUSEL
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.FLIPPED
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.SCATTERED
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.State
import com.bumble.puzzyx.puzzle.PuzzlePiece
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.ASSEMBLED
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.CAROUSEL
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.FLIPPED
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.PuzzleMode.SCATTERED
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.State
import com.bumble.puzzyx.model.PuzzlePiece
import kotlin.math.min
import kotlin.random.Random

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bumble.puzzyx.component.gridpuzzle
package com.bumble.puzzyx.appyx.component.gridpuzzle

import com.bumble.appyx.interactions.core.ui.property.impl.AngularPosition
import com.bumble.appyx.interactions.core.ui.property.impl.RotationY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.bumble.puzzyx.component.gridpuzzle.operation
package com.bumble.puzzyx.appyx.component.gridpuzzle.operation

import androidx.compose.animation.core.AnimationSpec
import com.bumble.appyx.components.backstack.BackStack
import com.bumble.appyx.components.backstack.operation.Push
import com.bumble.appyx.interactions.core.model.transition.BaseOperation
import com.bumble.appyx.interactions.core.model.transition.Operation
import com.bumble.appyx.utils.multiplatform.Parcelize
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.State
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.State

@Parcelize
class Assemble(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.bumble.puzzyx.component.gridpuzzle.operation
package com.bumble.puzzyx.appyx.component.gridpuzzle.operation

import androidx.compose.animation.core.AnimationSpec
import com.bumble.appyx.interactions.core.model.transition.BaseOperation
import com.bumble.appyx.interactions.core.model.transition.Operation
import com.bumble.appyx.utils.multiplatform.Parcelize
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.State
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.State

@Parcelize
class Carousel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.bumble.puzzyx.component.gridpuzzle.operation
package com.bumble.puzzyx.appyx.component.gridpuzzle.operation

import androidx.compose.animation.core.AnimationSpec
import com.bumble.appyx.components.backstack.BackStack
import com.bumble.appyx.components.backstack.operation.Push
import com.bumble.appyx.interactions.core.model.transition.BaseOperation
import com.bumble.appyx.interactions.core.model.transition.Operation
import com.bumble.appyx.utils.multiplatform.Parcelize
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.State
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.State

@Parcelize
class Flip(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.bumble.puzzyx.component.gridpuzzle.operation
package com.bumble.puzzyx.appyx.component.gridpuzzle.operation

import androidx.compose.animation.core.AnimationSpec
import com.bumble.appyx.interactions.core.model.transition.BaseOperation
import com.bumble.appyx.interactions.core.model.transition.Operation
import com.bumble.appyx.utils.multiplatform.Parcelize
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.component.gridpuzzle.GridPuzzleModel.State
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzle
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel
import com.bumble.puzzyx.appyx.component.gridpuzzle.GridPuzzleModel.State

@Parcelize
class Scatter(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,103 @@
package com.bumble.puzzyx.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.bumble.puzzyx.entries.Entry
import androidx.compose.ui.unit.sp
import com.bumble.puzzyx.model.Entry
import com.bumble.puzzyx.imageloader.ResourceImage
import com.bumble.puzzyx.ui.colors

@Composable
fun EntryCard(
modifier: Modifier,
entry: Entry
) {
Box(
modifier = modifier.clip(RoundedCornerShape(16.dp))
) {
when (entry) {
is Entry.Text -> TextEntry(entry)
is Entry.Image -> ResourceImage(
path = "participant/${entry.path}",
contentDescription = entry.contentDescription,
contentScale = entry.contentScale,
modifier = Modifier.fillMaxSize().align(Alignment.Center)
)
is Entry.ComposableContent -> entry.content()
}
GitHubHeader(
entry = entry,
modifier = Modifier.padding(8.dp)
)
}
}

@Composable
fun GitHubHeader(
entry: Entry,
modifier: Modifier = Modifier
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
) {
ResourceImage(
path = "github.png",
contentScale = ContentScale.Inside,
modifier = Modifier
.size(32.dp)
.padding(2.dp)
)
Spacer(
modifier = Modifier.size(4.dp)
)
Text(
text = entry.githubUserName,
fontSize = 18.sp,
fontWeight = FontWeight.Bold
)
}
}

@Composable
fun TextEntry(
entry: Entry.Text,
modifier: Modifier = Modifier
) {
val colorIdx = remember { colors.indices.random() }

Text(
text = entry.message,
fontSize = 16.sp,
modifier = modifier
.fillMaxSize()
.background(colors[colorIdx])
.padding(12.dp)
.padding(top = 36.dp)
,
)
}

@Composable
fun EntryCardSmall(
modifier: Modifier,
entry: Entry.Text
) {
ScaledLayout(
modifier = modifier.padding(8.dp),
Expand All @@ -23,7 +108,6 @@ fun EntryCard(
.fillMaxSize()
) {
Text(entry.githubUserName)
Text(entry.twitterHandle)
Text(entry.message)
}
}
Expand Down
Loading

0 comments on commit bdee04d

Please sign in to comment.