Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Compose #688

Merged
merged 26 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
54addb7
Merge branch '2.x' of github.com:manuel-martos/appyx into 2.x
mmartosdev Aug 19, 2023
c7ab82d
Merge branch '2.x' of github.com:manuel-martos/appyx into 2.x
mmartosdev Sep 12, 2023
1f33766
Merge branch '2.x' of github.com:manuel-martos/appyx into 2.x
mmartosdev Sep 18, 2023
6220a06
Merge branch '2.x' of github.com:manuel-martos/appyx into 2.x
mmartosdev Oct 25, 2023
c479165
Merge branch '2.x' of github.com:manuel-martos/appyx into 2.x
mmartosdev Oct 25, 2023
d3838be
Merge branch '2.x' of github.com:manuel-martos/appyx into 2.x
mmartosdev Nov 12, 2023
0f1cd56
Merge branch '2.x' of github.com:bumble-tech/appyx into 2.x
mmartosdev Dec 21, 2023
760ad4e
Merge branch '2.x' of github.com:bumble-tech/appyx into 2.x
mmartosdev Jan 12, 2024
3d206f7
Merge branch '2.x' of github.com:bumble-tech/appyx into 2.x
mmartosdev Jan 18, 2024
9ae7c2f
Merge branch '2.x' of github.com:bumble-tech/appyx into 2.x
mmartosdev Feb 20, 2024
1bda860
Merge branch '2.x' of github.com:bumble-tech/appyx into 2.x
mmartosdev Mar 9, 2024
a8a4933
Update to Compose 1.6.0
mmartosdev Mar 9, 2024
03b7c95
Fix BrowserViewportWindow and make it work properly with newer API
mmartosdev Mar 9, 2024
db32e3d
Use CanvasBasedWindow instead of Window as it has been removed from API
mmartosdev Mar 9, 2024
dad8f5c
Fix broken API usage in image-loader
mmartosdev Mar 9, 2024
d8e9f42
Fix module naming that introduces invalid char in Kotlin/JS
mmartosdev Mar 9, 2024
65f5df4
Avoid common as module name to avoid clashes
mmartosdev Mar 9, 2024
5fa6c1b
Use SwipeToDismissBox instead of deprecated SwipeToDismiss
mmartosdev Mar 9, 2024
856cae5
Use latest Compose BOM
mmartosdev Apr 3, 2024
375e3f0
Update screenshots
mmartosdev Apr 3, 2024
b54cec6
Fix lint config issue
mmartosdev Apr 3, 2024
680858d
Update spotlight screenshots
mmartosdev Apr 3, 2024
ad51094
Fix lint issues
mmartosdev Apr 3, 2024
a53267e
Update compose plugin
mmartosdev Apr 3, 2024
bbf1f51
Update Kotlin version
mmartosdev Apr 3, 2024
aef36ee
Update Compose compiler
mmartosdev Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
Expand All @@ -29,12 +29,12 @@ import com.bumble.appyx.interactions.composable.AppyxInteractionsContainer
import com.bumble.appyx.interactions.model.transition.Operation.Mode.IMMEDIATE
import com.bumble.appyx.interactions.model.transition.Operation.Mode.KEYFRAME
import com.bumble.appyx.interactions.ui.helper.AppyxComponentSetup
import com.bumble.appyx.interactions.utils.ui.Element
import com.bumble.appyx.interactions.utils.testing.TestTarget
import com.bumble.appyx.interactions.utils.testing.TestTarget.Child1
import com.bumble.appyx.interactions.utils.testing.TestTarget.Child2
import com.bumble.appyx.interactions.utils.testing.TestTarget.Child3
import com.bumble.appyx.interactions.utils.testing.TestTarget.Child4
import com.bumble.appyx.interactions.utils.ui.Element
import kotlin.math.roundToInt


Expand Down Expand Up @@ -71,8 +71,10 @@ fun PromoterExperiment(modifier: Modifier = Modifier) {
.fillMaxSize()
) {
val density = LocalDensity.current
val screenWidthPx = (LocalConfiguration.current.screenWidthDp * density.density).roundToInt()
val screenHeightPx = (LocalConfiguration.current.screenHeightDp * density.density).roundToInt()
val screenWidthPx =
(LocalConfiguration.current.screenWidthDp * density.density).roundToInt()
val screenHeightPx =
(LocalConfiguration.current.screenHeightDp * density.density).roundToInt()

AppyxInteractionsContainer(
appyxComponent = promoter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.components.experimental.puzzle15.ui.Puzzle15Ui
import org.jetbrains.skiko.wasm.onWasmReady

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
onWasmReady {
Window("Puzzle15") {
CanvasBasedWindow("Puzzle15") {
val requester = remember { FocusRequester() }
var size by remember { mutableStateOf(IntSize.Zero) }
Surface(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.animation.core.SpringSpec
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Surface
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ private const val CANVAS_ELEMENT_ID = "ComposeTarget" // Hardwired into ComposeW
/**
* A Skiko/Canvas-based top-level window using the browser's entire viewport. Supports resizing.
*/
@Composable
@Suppress("FunctionNaming")
fun BrowserViewportWindow(
title: String = "Untitled",
content: @Composable ComposeWindow.() -> Unit
content: @Composable () -> Unit
) {
val htmlHeadElement = document.head!!
htmlHeadElement.appendChild(
Expand Down Expand Up @@ -59,7 +60,7 @@ fun BrowserViewportWindow(
fillViewportSize()
}

ComposeWindow().apply {
ComposeWindow(canvasId = "Appyx", content = content).apply {
window.addEventListener("resize", {
canvas.fillViewportSize()
layer.layer.attachTo(canvas)
Expand All @@ -77,9 +78,5 @@ fun BrowserViewportWindow(
?: document.createElement("title").also { htmlHeadElement.appendChild(it) }
) as HTMLTitleElement
htmlTitleElement.textContent = title

setContent {
content(this)
}
}
}
57 changes: 56 additions & 1 deletion demos/appyx-interactions/android/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.4.0" type="baseline" client="gradle" dependencies="false" name="AGP (7.4.0)" variant="all" version="7.4.0">
<issues format="6" by="lint 8.2.1" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.1)" variant="all" version="8.2.1">

<issue
id="UsingMaterialAndMaterial3Libraries"
message="Using a material import while also using the material3 library"
errorLine1="import androidx.compose.material.FractionalThreshold"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt"
line="12"
column="8"/>
</issue>

<issue
id="UsingMaterialAndMaterial3Libraries"
message="Using a material import while also using the material3 library"
errorLine1="import androidx.compose.material.rememberSwipeableState"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt"
line="13"
column="8"/>
</issue>

<issue
id="UsingMaterialAndMaterial3Libraries"
message="Using a material import while also using the material3 library"
errorLine1="import androidx.compose.material.swipeable"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt"
line="14"
column="8"/>
</issue>

<issue
id="UsingMaterialAndMaterial3Libraries"
message="Using a material import while also using the material3 library"
errorLine1="import androidx.compose.material.Button"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt"
line="12"
column="8"/>
</issue>

<issue
id="UsingMaterialAndMaterial3Libraries"
message="Using a material import while also using the material3 library"
errorLine1="import androidx.compose.material.Text"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt"
line="13"
column="8"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.components.internal.testdrive.TestDriveExperiment
import com.bumble.appyx.components.internal.testdrive.ui.md_amber_500
import com.bumble.appyx.components.internal.testdrive.ui.md_blue_500
Expand Down Expand Up @@ -53,9 +54,10 @@ enum class InteractionTarget {
Child1
}

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
onWasmReady {
Window("Appyx") {
CanvasBasedWindow("Appyx") {
var size by remember { mutableStateOf(IntSize.Zero) }
Surface(
modifier = Modifier
Expand Down
2 changes: 1 addition & 1 deletion demos/appyx-navigation/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ kotlin {
api(project(":utils:utils-customisations"))
api(project(":utils:utils-material3"))
api(project(":utils:utils-multiplatform"))
api(project(":demos:image-loader:image-loader"))
api(project(":demos:image-loader:loader"))
implementation(project(":appyx-components:experimental:cards:cards"))
implementation(project(":appyx-components:experimental:promoter:promoter"))
implementation(project(":appyx-components:standard:backstack:backstack"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ import androidx.compose.material.icons.filled.Delete
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.DismissDirection.EndToStart
import androidx.compose.material3.DismissValue
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SwipeToDismiss
import androidx.compose.material3.SwipeToDismissBox
import androidx.compose.material3.SwipeToDismissBoxValue
import androidx.compose.material3.Text
import androidx.compose.material3.rememberDismissState
import androidx.compose.material3.rememberSwipeToDismissBoxState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand Down Expand Up @@ -118,12 +117,12 @@ private fun LazyItemScope.CartListItem(
val quantity = cakeToQuantity.second
val coroutineScope = rememberCoroutineScope()

val dismissState = rememberDismissState(confirmValueChange = { dismissValue ->
val dismissState = rememberSwipeToDismissBoxState(confirmValueChange = { dismissValue ->
when (dismissValue) {
DismissValue.Default,
DismissValue.DismissedToEnd -> false
SwipeToDismissBoxValue.Settled,
SwipeToDismissBoxValue.StartToEnd -> false

DismissValue.DismissedToStart -> {
SwipeToDismissBoxValue.EndToStart -> {
coroutineScope.launch {
delay(250)
onDeleteCake(cake)
Expand All @@ -133,21 +132,21 @@ private fun LazyItemScope.CartListItem(
}
})

SwipeToDismiss(
SwipeToDismissBox(
modifier = Modifier.animateItemPlacement(),
state = dismissState,
directions = setOf(EndToStart),
background = { CartItemDismissBackground() },
dismissContent = {
CardItem(
cake = cake,
quantity = quantity,
onGoToCake = onGoToCake,
plusOneCakeAction = onPlusOneCake,
minusOneCakeAction = onMinusOneCake,
)
},
)
enableDismissFromStartToEnd = false,
enableDismissFromEndToStart = true,
backgroundContent = { CartItemDismissBackground() },
) {
CardItem(
cake = cake,
quantity = quantity,
onGoToCake = onGoToCake,
plusOneCakeAction = onPlusOneCake,
minusOneCakeAction = onMinusOneCake,
)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.layout.ContentScale
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.resource
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.readResourceBytes

@OptIn(InternalResourceApi::class)
@Suppress("TooGenericExceptionCaught", "SwallowedException")
@OptIn(ExperimentalResourceApi::class)
@Composable
fun ResourceImage(
path: String,
Expand All @@ -29,13 +29,11 @@ fun ResourceImage(
LaunchedEffect(Unit) {
image = withContext(Dispatchers.Default) {
try {
resource(path)
.readBytes()
readResourceBytes(path)
.toImageBitmap()
} catch (e: Throwable) {
try {
resource(fallbackUrl)
.readBytes()
readResourceBytes(fallbackUrl)
.toImageBitmap()
} catch (e: Throwable) {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.demos.appyxSample
import com.bumble.appyx.demos.common.color_dark


@OptIn(ExperimentalComposeUiApi::class)
fun main() {
appyxSample {
Window("Appyx") {
CanvasBasedWindow("Appyx") {
var size by remember { mutableStateOf(IntSize.Zero) }
Surface(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.demos.appyxSample
import com.bumble.appyx.demos.common.color_dark


@OptIn(ExperimentalComposeUiApi::class)
fun main() {
appyxSample {
Window("Appyx") {
CanvasBasedWindow("Appyx") {
var size by remember { mutableStateOf(IntSize.Zero) }
Surface(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.CanvasBasedWindow
import com.bumble.appyx.demos.appyxSample
import com.bumble.appyx.demos.common.color_dark


@OptIn(ExperimentalComposeUiApi::class)
fun main() {
appyxSample {
Window("Appyx") {
CanvasBasedWindow("Appyx") {
var size by remember { mutableStateOf(IntSize.Zero) }
Surface(
modifier = Modifier
Expand Down
Loading
Loading