Skip to content

Commit

Permalink
Merge pull request #21 from manuel-martos/minor-improvements
Browse files Browse the repository at this point in the history
Minor improvements
  • Loading branch information
mmartosdev authored Oct 5, 2023
2 parents f57754e + aaacb91 commit 57ee894
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build

on: [push]
on: [ push, pull_request, workflow_dispatch ]

env:
CI:
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ composeBom = "2023.05.01"
composeCompiler = "1.4.4"
coroutines = "1.7.1"
dependencyAnalysis = "1.13.1"
detekt = "1.21.0"
detekt = "1.22.0"
junit5 = "5.8.2"
jvmTarget = "17"
kotlin = "1.8.10"
Expand Down Expand Up @@ -96,7 +96,7 @@ plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.
plugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
plugin-android = { module = "com.android.tools.build:gradle", version.ref = "agp" }

detekt-compose = "com.twitter.compose.rules:detekt:0.0.26"
detekt-compose = "io.nlopez.compose.rules:detekt:0.3.0"
toolargetool = "com.gu.android:toolargetool:0.3.0"

symbol-processing-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ class GridPuzzle(
model = GridPuzzleModel(savedStateMap, gridRows, gridCols, pieces),
motionController = { GridPuzzleVisualisation(it, defaultAnimationSpec) },
defaultAnimationSpec = defaultAnimationSpec
) {

}
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import com.bumble.puzzyx.ui.appyx_dark
import com.bumble.puzzyx.ui.appyx_yellow1

@Composable
fun CallToActionScreen(modifier: Modifier) {
fun CallToActionScreen(
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bumble.puzzyx.model.Entry
import com.bumble.puzzyx.imageloader.ResourceImage
import com.bumble.puzzyx.model.Entry
import com.bumble.puzzyx.ui.colors

@Composable
fun EntryCard(
modifier: Modifier,
entry: Entry
entry: Entry,
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier.clip(RoundedCornerShape(16.dp))
Expand All @@ -39,6 +39,7 @@ fun EntryCard(
contentScale = entry.contentScale,
modifier = Modifier.fillMaxSize().align(Alignment.Center)
)

is Entry.ComposableContent -> entry.content()
}
GitHubHeader(
Expand Down Expand Up @@ -89,15 +90,14 @@ fun TextEntry(
.fillMaxSize()
.background(colors[colorIdx])
.padding(12.dp)
.padding(top = 36.dp)
,
.padding(top = 36.dp),
)
}

@Composable
fun EntryCardSmall(
modifier: Modifier,
entry: Entry.Text
entry: Entry.Text,
modifier: Modifier = Modifier,
) {
ScaledLayout(
modifier = modifier.padding(8.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import math.noise3D
import kotlin.math.cos

@Composable
fun MessageBoard(modifier: Modifier) {
fun MessageBoard(
modifier: Modifier = Modifier,
) {
ProgressBasedContent(
millisPerFrame = 50000,
) { time ->
Expand All @@ -37,7 +39,10 @@ fun MessageBoard(modifier: Modifier) {
}

@Composable
private fun MessageBoardContent(time: Float, modifier: Modifier) {
private fun MessageBoardContent(
time: Float,
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier
.fillMaxSize()
Expand Down Expand Up @@ -72,8 +77,8 @@ private fun MessageBoardContent(time: Float, modifier: Modifier) {
val entry = entriesShuffled[(y * maxY + x) % entriesShuffled.size]

EntryCard(
modifier = Modifier.fillMaxSize(),
entry
entry = entry,
modifier = Modifier.fillMaxSize()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun ResourceImage(
image?.let {
Image(
bitmap = it,
contentDescription = null,
contentDescription = contentDescription,
modifier = modifier,
contentScale = contentScale
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PuzzyxAppNode(
initialTargets = listOf(screens.first()),
savedStateMap = buildContext.savedStateMap,
),
motionController = { BackStackClipper(it, shape = { progress -> ClipShape(progress) }) }
motionController = { BackStackClipper(it, shape = { progress -> clipShape(progress) }) }
)
) : ParentNode<NavTarget>(
buildContext = buildContext,
Expand Down Expand Up @@ -184,7 +184,7 @@ class PuzzyxAppNode(
}

@Composable
private fun ClipShape(progress: Float): Shape {
private fun clipShape(progress: Float): Shape {
val screenSize = LocalScreenSize.current
val (meshMin, meshMax) = 14 to 25
val meshSizeX = if (screenSize.widthDp > screenSize.heightDp) meshMax else meshMin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -47,7 +46,6 @@ import com.bumble.puzzyx.model.puzzle1Entries
import com.bumble.puzzyx.ui.LocalAutoPlayFlow
import com.bumble.puzzyx.ui.appyx_dark
import com.bumble.puzzyx.ui.colors
import org.jetbrains.compose.resources.ExperimentalResourceApi
import kotlin.random.Random

private val animationSpec = spring<Float>(
Expand Down Expand Up @@ -79,7 +77,6 @@ class Puzzle1Node(
appyxComponent = gridPuzzle
) {

@OptIn(ExperimentalResourceApi::class)
override fun resolve(puzzlePiece: PuzzlePiece, buildContext: BuildContext): Node =
node(buildContext) { modifier ->
val colorIdx = rememberSaveable(puzzlePiece) { Random.nextInt(colors.size) }
Expand All @@ -106,7 +103,8 @@ class Puzzle1Node(
.fillMaxSize()
.background(color),
// TODO decide on the fate of this
entry = puzzle1Entries[puzzlePiece.entryId] as? Entry.Text ?: Entry.Text(Puzzle.PUZZLE1, "n/a")
entry = puzzle1Entries[puzzlePiece.entryId] as? Entry.Text
?: Entry.Text(Puzzle.PUZZLE1, "n/a")
)
}
)
Expand Down Expand Up @@ -148,7 +146,9 @@ class Puzzle1Node(

@OptIn(ExperimentalLayoutApi::class)
@Composable
private fun Controls(modifier: Modifier) {
private fun Controls(
modifier: Modifier = Modifier,
) {
if (!LocalAutoPlayFlow.current.collectAsState().value) {
FlowRow(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import com.bumble.appyx.interactions.core.annotations.FloatRange
import com.bumble.appyx.interactions.core.ui.math.clamp
import com.bumble.appyx.interactions.core.ui.math.lerpFloat
import com.bumble.puzzyx.math.mapValueRange
import java.lang.Integer.max
Expand Down Expand Up @@ -70,16 +69,12 @@ class DottedMeshShape(
+ (0.5f - abs(u - 0.5f))
+ (0.5f - abs(v - 0.5f)))

val radius = clamp(
x = mapValueRange(
value.coerceAtMost(1f),
fromRangeMin = 0f,
fromRangeMax = 1f,
destRangeMin = 0f,
destRangeMax = targetRadius
),
min = 0f,
max = clampRadius,
val radius = mapValueRange(
value = value.coerceAtMost(1f),
fromRangeMin = 0f,
fromRangeMax = 1f,
destRangeMin = 0f,
destRangeMax = targetRadius
)

// Clip with ovals when you see them, but stick with rectangles otherwise. This
Expand Down

0 comments on commit 57ee894

Please sign in to comment.