altavir
09/13/2022, 3:26 PMvar cachedValue by remember { mutableStateOf(initialViewPoint) }
var viewPoint by remember { mutableStateOf(initialViewPoint) }
if (cachedValue != initialViewPoint) {
viewPoint = initialViewPoint
cachedValue = initialViewPoint
}
Charles Jo
09/13/2022, 4:42 PMAndy Himberger
09/13/2022, 6:07 PMdead.fish
09/13/2022, 10:14 PMtheapache64
09/14/2022, 6:05 AMArun Joseph
09/14/2022, 7:41 AMLocalConfiguration.current.screenHeightDp.dp.toPx()
is doing some rounding and I get errors when comparing with Offset
from LayoutCoordinates
.altavir
09/14/2022, 8:04 AMnuhkoca
09/14/2022, 8:43 AMdrawText
of Canvas? Couldn’t find resources for how to use it. Thanks!Louis
09/14/2022, 9:12 AMMatti MK
09/14/2022, 10:46 AMnavHostController.graph
returns a different graph than navHostController.currentDestination.parent
?nuhkoca
09/14/2022, 12:16 PMpartitions.forEach { partition ->
val sweepAngle = partition.sweepAngle
// Draw Circle
drawArc(
startAngle = startAngle,
sweepAngle = sweepAngle,
size = arcSize,
progressBrush = partition.style,
strokeWidthInPx = progressStrokeWidthInPx
)
// Draw Snippet
val snippet = partition.snippet
if (snippet != null) {
val snippetText = snippet.text
val snippetBackground = snippet.background
val textWidth = snippetText.rect.width()
val textHeight = snippetText.rect.height()
val padding = snippetBackground.paddingInPx
val angleMidpoint = startAngle + (sweepAngle / 2)
val angleMidpointInRadians = angleToRadian(angleMidpoint)
val snippetWidth = textWidth + (padding * 2)
val snippetHeight = textHeight + (padding * 2)
// Find polar coordinates of snippet center and convert them to cartesian coordinates
// A great source for learning about coordinates: <https://varun.ca/polar-coords/>
val snippetCenterXCoordinate =
centerX + (((progressStrokeWidthInPx + snippetWidth) / 2) + radius) * cos(angleMidpointInRadians)
val snippetCenterYCoordinate =
centerY + (((progressStrokeWidthInPx + snippetHeight) / 2) + radius) * sin(
angleMidpointInRadians
)
// Calculate the snippet so it is drawn based on its center points
val snippetXCoordinate = snippetCenterXCoordinate - (snippetWidth / 2)
val snippetYCoordinate = snippetCenterYCoordinate - (snippetHeight / 2)
val textXCoordinate = snippetXCoordinate + padding
val textYCoordinate = snippetYCoordinate + textHeight + padding
// Snippet background stroke
val snippetStroke = snippetBackground.stroke
if (snippetStroke != null) {
drawRoundRect(
brush = snippetStroke.style,
x = snippetXCoordinate,
y = snippetYCoordinate,
width = snippetWidth,
height = snippetHeight,
style = Stroke(width = snippetStroke.widthInPx),
cornerRadiusInPx = snippetBackground.cornerRadiusInPx
)
}
// Snippet background fill
drawRoundRect(
brush = snippetBackground.style,
x = snippetXCoordinate,
y = snippetYCoordinate,
width = snippetWidth,
height = snippetHeight,
style = Fill,
cornerRadiusInPx = snippetBackground.cornerRadiusInPx
)
drawLine(
Color.Red,
start = Offset(centerX, centerY),
end = Offset(textXCoordinate, textYCoordinate)
)
drawLine(
Color.Green,
start = Offset(centerX, centerY),
end = Offset(snippetCenterXCoordinate, snippetCenterYCoordinate)
)
// Snippet text
drawText(
x = textXCoordinate,
y = textYCoordinate,
value = snippetText.value,
style = snippetText.style
)
}
startAngle += sweepAngle
}
Alex
09/14/2022, 1:47 PMPath
into another Path
? I am trying to animate one shape into another, both shapes are based on Path
sFrank van der Laan
09/14/2022, 2:53 PMmgrazianodecastro
09/14/2022, 4:38 PMJérémy CROS
09/14/2022, 4:58 PMConstraintLayout
with a lottie animation, some text, a text field and a “next” button
Second one also has a ConstraintLayout and a bunch of data displayed.
When the text field is focused, keyboard shows up, taking up half the screen that becomes scrollable
Issue is when clicking the “next” button when the keyboard is shown completely breaks the layout of the next screen
I assume the keyboard is still there when the second screen is displayed.
Nothing “clean” we’ve tried seems to solve that.
val keyboardController = LocalSoftwareKeyboardController.current
with keyboardController?.hide()
when clicking the button and before navigating away does absolutely nothing
The only approach that seemed to work is to introduce some sort of delay....
Any idea?
Much appreciated! 🙏colintheshots
09/14/2022, 8:30 PMBottomSheetScaffold
. I noticed that you can set a remembered value in Modifier.onGloballyPositioned()
to the height of a composable. Then you can set the peek height to this value.
However, this doesn’t seem to correctly update on recompositions after the initial one. In fact, one needs to swipe away the activity to get it to recalculate the correct peek height. I do know that onGloballyPositioned is supposed to run after composition, but if I change the remembered mutable state used to set the peek height, shouldn’t it recompose again?Chris Fillmore
09/14/2022, 8:42 PMDropdownMenu
when it is clicked? Is the only way through DropdownMenuItem
via its onClick
?
I’ve tried passing DropdownMenu(modifier = Modifier.clickable …)
but this doesn’t have any effect that I can see.Andrey B.
09/14/2022, 11:16 PMThomas Dougherty
09/15/2022, 3:56 AMAdam Brown
09/15/2022, 4:16 AMYusuf Ibragimov
09/15/2022, 7:38 AMJoost Klitsie
09/15/2022, 7:39 AMczuckie
09/15/2022, 9:22 AMCompositionLocalProvider
as a way of exposing a cast icon in my app, so that I can easily override it in my tests whilst also hiding how the cast icon is created from the many screens in my application.
Would this be considered acceptable from a practice point of view? Also, is there actually a 'compose first' way to do casting?dimsuz
09/15/2022, 12:16 PMMyComposable(state, onClick = { someObject.sendEvent() })
and state
is immutable, but someObject
is not `Stable`/`Immutable`, (for example it can be a ViewModel
or Presenter
) this leads to constant recompositions, because onClick
is not considered a Stable
lambda. I confirmed this: my code stops constantly recomposing MyComposable
if I make onClick
empty.
What is the recommended refactoring to avoid such issues? Marking someObject
as Stable is not always possible or often incorrect.Christian Lutnik
09/15/2022, 12:31 PMjvm
Compose Project, I immediately get an exception
'void org.jetbrains.skia.paragraph.ParagraphStyleKt._nSetTextIndent(long, float, float)'
java.lang.UnsatisfiedLinkError: 'void org.jetbrains.skia.paragraph.ParagraphStyleKt._nSetTextIndent(long, float, float)'
at org.jetbrains.skia.paragraph.ParagraphStyleKt._nSetTextIndent(Native Method)
at org.jetbrains.skia.paragraph.ParagraphStyleKt.access$_nSetTextIndent(ParagraphStyle.kt:1)
at org.jetbrains.skia.paragraph.ParagraphStyle.setTextIndent(ParagraphStyle.kt:182)
at androidx.compose.ui.text.platform.ParagraphBuilder.textStyleToParagraphStyle(SkiaParagraph.skiko.kt:776)
at androidx.compose.ui.text.platform.ParagraphBuilder.build(SkiaParagraph.skiko.kt:566)
at androidx.compose.ui.text.platform.ParagraphLayouter.<init>(ParagraphLayouter.skiko.kt:71)
as soon as the Composable under test contains a Text(String)
, so this fails:
class ComposeTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun firstTest() {
composeTestRule.setContent {
Text("Hello")
}
}
}
whereas this does not:
class ComposeTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun firstTest() {
composeTestRule.setContent {
Button({}){}
}
}
}
Does anyone have an idea what the problem could be?Zaki Shaikh
09/15/2022, 1:06 PMOthman El Jazouli
09/15/2022, 1:11 PM@Composable
fun Container() {
SectionA()
SectionB()
}
@Composable
fun SectionA() {
var someState by remember { mutableStateOf(1) }
//...
someState = 2
}
@Composable
fun SectionB() {
}
would the whole Container()
and SectionA()
and SectionB()
recompose when changing someState
? or only SectionA()
?
wondering if there is any potential composition lag if the screen is too largeDaniele Segato
09/15/2022, 3:40 PMfilipegoncalves
09/15/2022, 5:00 PMDiego Arenas
09/15/2022, 5:54 PMDiego Arenas
09/15/2022, 5:54 PMStylianos Gakis
09/15/2022, 8:46 PM