loloof64
03/11/2021, 4:18 PM1.0.0-beta02
Does not run on my device any moreloloof64
03/11/2021, 4:19 PMloloof64
03/11/2021, 4:20 PMloloof64
03/11/2021, 4:25 PMloloof64
03/11/2021, 4:28 PMloloof64
03/11/2021, 4:29 PMloloof64
03/11/2021, 4:34 PMSe7eN
03/11/2021, 4:38 PMloloof64
03/11/2021, 4:45 PMlouiscad
03/11/2021, 4:45 PMTimo Drick
03/11/2021, 4:56 PMloloof64
03/11/2021, 5:01 PMTimo Drick
03/11/2021, 5:02 PMloloof64
03/11/2021, 5:04 PM@Composable
private fun MovedPiece(cellsSize: Float, positionFen: String, dndData: DndData) {
val boardLogic = Board.fromFen(positionFen)
val square = getSquareFromCellCoordinates(dndData.startFile, dndData.startRank)
val piece = boardLogic.getSquareOccupant(square)
val imageRef = piece.getPieceImageID()
val imageDescription =
piece.getPieceImageDescriptionID()
val x = with(LocalDensity.current) { dndData.movedPieceX.toDp() }
val y = with(
LocalDensity.current
) { dndData.movedPieceY.toDp() }
val imageSize = with(LocalDensity.current) {
cellsSize.toDp()
}
if (imageRef != null && imageDescription != null) {
Image(
painter = painterResource(id = imageRef),
contentDescription = stringResource(imageDescription),
modifier = Modifier
.size(imageSize)
.offset(x, y)
)
}
}
Here I am trying to render a component if I could get all data, and to not render anything otherwise.louiscad
03/11/2021, 5:11 PMTimo Drick
03/11/2021, 5:12 PMloloof64
03/11/2021, 5:12 PMloloof64
03/11/2021, 5:14 PMImage
or nothing. Using the if clause upwards, in a parent composable makes it work on my device.loloof64
03/11/2021, 5:15 PMlouiscad
03/11/2021, 5:15 PMTimo Drick
03/11/2021, 5:15 PMloloof64
03/11/2021, 5:16 PMlouiscad
03/11/2021, 5:16 PMloloof64
03/11/2021, 5:16 PMloloof64
03/11/2021, 5:49 PMlouiscad
03/11/2021, 5:49 PMloloof64
03/11/2021, 5:49 PMlouiscad
03/11/2021, 5:51 PMloloof64
03/11/2021, 5:56 PMlouiscad
03/11/2021, 6:01 PMloloof64
03/11/2021, 6:10 PMpackage com.loloof64.chessexercisesorganizer.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import java.util.*
@Composable
fun BugPOC() {
Box(modifier = Modifier
.size(300.dp)
.background(Color.Yellow)) {
val date = Date()
if (date.time%2 == 0L) {
Box(modifier = Modifier
.size(20.dp)
.background(Color.Red)
.offset(50.dp, 80.dp))
}
}
}
@Preview
@Composable
fun PreviewBugPOC() {
BugPOC()
}
Timo Drick
03/11/2021, 6:13 PMloloof64
03/11/2021, 6:14 PMTimo Drick
03/11/2021, 6:15 PMloloof64
03/11/2021, 6:15 PMTimo Drick
03/11/2021, 6:16 PMloloof64
03/11/2021, 6:16 PMTimo Drick
03/11/2021, 6:18 PMloloof64
03/11/2021, 6:22 PMTimo Drick
03/11/2021, 6:49 PMloloof64
03/12/2021, 9:44 AM