Michael Paus
02/14/2022, 5:11 PMoverride fun imageBitmapFromArgb(rawArgbImageData: IntArray, width: Int, height: Int): ImageBitmap {
val image = ImageBitmap(width, height, ImageBitmapConfig.Argb8888, true, ColorSpaces.Srgb)
image.asAndroidBitmap().setPixels(rawArgbImageData, 0, width, 0, 0, width, height)
return image
}
but there does not seem to be a suitable way to do the same on desktop. The Skia bitmap does not seem to have a setPixels
method.frank
02/14/2022, 9:18 PMSrSouza
02/15/2022, 2:14 AMpajatopmr
02/15/2022, 6:39 AMalbrechtroehm
02/15/2022, 10:04 AMKebbin
02/15/2022, 12:49 PMjcechace
02/15/2022, 6:55 PMspierce7
02/15/2022, 7:42 PMwith(LocalDensity.current) {
window.minimumSize = Dimension(400.dp.roundToPx(), 250.dp.roundToPx())
}
Is there a way to subscribe to the local density as state so that if it changes it triggers a re-draw?gnu
02/15/2022, 10:26 PMAhmad Daneshvar
02/15/2022, 10:47 PMTextField
has some sort of padding, that causes the content cut (Please look at attached image)? And how I can eliminate it? Just please consider I don’t want to decrease font size or increase the height of TextField
or OutlinedTextField
to match the content. I am looking for another way. I also tried Modifier.padding
on the textField and didn’t matter.
Thank you in advance.MaxUt
02/16/2022, 12:05 PM@Composable
fun RoomsScreen(
onRoomClick: (Int) -> Unit,
onBack: () -> Unit
) {
val rooms = remember { mutableStateOf(emptyList<WSRoom>()) }
rooms.value = runBlocking { RoomRepository.getAllRooms() }
...
}
Here I've noticed that the RoomRepository.getAllRooms gets called every recomposition. What are your recommandation to avoid that ?Kebbin
02/16/2022, 12:44 PMEmily V
02/17/2022, 6:23 AMvar chartFrame: ChartPanel? = null
@Composable
private fun TheChart() {
Card(elevation = 5.dp, shape = RoundedCornerShape(0.dp), modifier = Modifier.fillMaxSize()) {
if (chartFrame == null) {
val series = XYSeries("Sensors Reading")
series.add(0, 3)
series.add(1, 4)
series.add(2, 5)
series.add(3, 6)
series.add(4, 7)
series.add(5, 3)
val dataset = XYSeriesCollection(series)
val chart: JFreeChart = ChartFactory.createXYLineChart("Test", "Time (seconds)", "Sensors value", dataset)
val frame = ChartPanel(chart)
frame.isVisible = true
chartFrame = frame
}
Box {
SwingPanel(
factory = {
JPanel().apply {
layout = BoxLayout(this, BoxLayout.Y_AXIS)
add(chartFrame)
}
})
}
}
}
This renders great and looks as it should. Now, when I want to push in new data, I basically need to update the dataset, and I do that by adding x,y values to the series object. Now obviously this needs to be hoisted out of the Composable and get pushed into the function as a parameter. But I am not entirely sure on how to architect that properly in Compose. I also added a check for null to make sure not to recreate the chart object on each recomposition and I think this is not ideal here. Can any one assist?Naveed
02/17/2022, 1:53 PMRow
? than padding(top = 8.dp)
? I have tried .wrapContentHeight(Alignment.CenterVertically)
in the modifier and it does not do anything, the text stays stuck at the top.Thomas
02/17/2022, 7:13 PMandroidx.compose.ui.renderComposeScene
seems to have disappeared in 1.2.0-alpha01-dev620
(upgrading from 1.1.0-alpha04
). Where did it go?czuckie
02/17/2022, 9:14 PMpajatopmr
02/17/2022, 9:37 PMcheckIsDisplayed()
, that are not currently implemented in the ui-test-junit4
component thus causing a serious problem for those of us wanting to write GUI tests for our Compose Multiplatform apps.
To address this problem, I have volunteered to work on implementing some of these not yet implemented functions. The first step is to set up a development environment for this work.
That environment is the subject of this post, a Readers Digest version of material provided by @Igor Demin (for which I am so, so grateful).
The basic work is described in https://android.googlesource.com/platform/frameworks/support.git/+/refs/heads/android-arch-work-release/README.md and essentially entails:
1. Getting the source code
2. Setting up java
3. Setting up Android Studio
4. Verifying the development setup by running a working test
5. Developing a fix, with test, for some unimplemented method
6. Getting the code reviewed by @olonho and/or @Igor Demin
7. Generating a PR to the JetBrains fork
Getting the source code
The source code is obtained using a Google tool, '`repo`', which is a layer on top of git.
For work on Compose Multiplatform, the branch to use is "androidx-main".
The download uses ~40G and takes a while. A gigabit network, or better, is highly recommended.
The repo installation instructions can be found at https://source.android.com/setup/develop#installing-repo . I used homebrew (brew install repo
) on a MacBook Pro.
Once repo is installed, the branch (androidx-main) is initialized and downloaded using steps from https://source.android.com/setup/build/downloading :
mkdir <path/for/androidx-main/code>
cd <path/for/androidx-main/code>
repo init -u https://android/googlesource.com/platform/manifest
repo init -u https://android.googlesource.com/platform/manifest -b androidx-main
repo sync -c -j8
Setting up Java
The Compose Multiplatform team recommends using JDK15 but I have been using JDK11 successfully for ui-test-junit4 so far. Homebrew is an excellent way to manage multiple JDK versions simultaneously, particularly Open JDK.
I am also told that JDK11 is provided by the repo
download, but I seem to recall needing an installed JDK11 at one point.
Setting up Android Studio
At this point, when the script completes, we are ready to use Android Studio (Dolphin), which is included in the download of "androidx-main", as a source file editor by executing:
cd frameworks/support
./gradlew studio
Verifying the development setup by running a working test
The next step is to verify that the ScrollBarTest can be run successfully.
While this usually can be done using Android Studio or Gradle, a known bug in Dolphin generates a "Nothing here" message so we use Gradle with:
./gradlew cleanDesktopTest :compose:foundation:foundation:desktopTest --tests "androidx.compose.foundation.ScrollbarTest"
The remaining three steps will be performed in the coming days and I will edit this post accordingly.
My hope is that others will find this documentation useful and enable them to contribute fixes also.Tim Almdal
02/17/2022, 10:47 PMluen
02/18/2022, 5:46 AMNaveed
02/18/2022, 12:47 PMLandry Norris
02/18/2022, 4:07 PMMiquel Àngel Román
02/18/2022, 8:07 PM./gradlew packageDeb
from a macOS in order to later deploy it on a raspberry pi. I've asked @theapache64 but seems like packaging needs to be done on the same platform. Does anybody know a workaround?Alexander Maryanovsky
02/19/2022, 1:23 PMBig Chungus
02/19/2022, 9:07 PMTrammel May
02/20/2022, 12:05 AMCaused by: java.lang.AbstractMethodError: Receiver class androidx.compose.compiler.plugins.kotlin.ComposeComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:610)
... 47 more
Kebbin
02/20/2022, 7:28 AMEnrico Saggiorato
02/20/2022, 2:08 PMAlexander Maryanovsky
02/20/2022, 9:04 PMMarcello Galhardo
02/20/2022, 9:32 PMlhwdev
02/21/2022, 9:20 AMlhwdev
02/21/2022, 9:20 AMgetValue
as the stacktrace shows:Michael Paus
02/21/2022, 1:37 PMlhwdev
02/22/2022, 2:52 AM