Michael Bichlmeier
07/13/2022, 7:22 AMTgo1014
07/13/2022, 7:43 AMrememberVectorPainter
but without this I can't use the Image
composable. Is there a way to achieve this?Can Korkmaz
07/13/2022, 7:51 AMVivek Modi
07/13/2022, 9:16 AMCan Korkmaz
07/13/2022, 11:53 AModay
07/13/2022, 11:54 AMenum class StylisedIconColor(val color: Color) {
BRAND(MaterialTheme.colors.Brand), INFO, SUCCESS, WARNING, FAILURE, INACTIVE, EARTH, TITAN, SUN, MARS
}
but the issue is that you cannot invoke that colors call without being in the context of Composabl;eAlex
07/13/2022, 12:26 PMMutableState
in this way:
var result by mutableStateOf<R?>(value = null, policy = neverEqualPolicy())
Now I am setting an object
via result = TheObject
I am listening to that via
LaunchedEffect(Unit) {
snapshotFlow { result }.collectLatest {
(logging here)
}
}
But I am only receiving a log when the first object is set, all subsequent value changes with TheObject
on result
are not logged. Shouldn’t neverEqualPolicy()
ensure that every value change is emitted? What am I missing here?Sebastian Kürten
07/13/2022, 3:38 PMImage
. That works nicely, images appear in their natural size. However on higher density devices, images appear smaller. Is there any easy way to use the LocalDensity
to render an image the same natural size independent of screen density? I've tried applying Modifier.scale(LocalDensity.current.density)
and while the image seems to be rendered bigger on higher density devices, the size of the widget doesn't seem to increase, i.e. only part of the image is visible. I see that Image
is using an ImagePainter
under the hood, but I don't see an easy way to supply a target size for it. Any suggestions?Berkeli Alashov
07/13/2022, 7:21 PM@Composable
fun isCompactWindow(windowSizeClass: WindowSizeClass = LocalWindowSizeClass.current) = windowSizeClass.isCompactWindow()
class Fragment : ComposeFragment { // calls Route in onCreateView by returning ComposeView
@Composable
override fun Route() {
val isCompactWindow = isCompactWindow()
val someOtherState by remember { mutableStateOf(false) }
LaunchedEffect(isCompactWindow){
mainActivity.showFoo(isCompactWindow)
}
// or
SideEffect {
mainActivity.showFoo(isCompactWindow)
}
}
}
I think I should use the LaunchedEffect in this case. Since it makes sure that the code won't run again when someOtherState
changes, right?
If there was only isCompactWindow
, then I could use SideEffect safely too?Colton Idle
07/14/2022, 5:11 AMnlindberg
07/14/2022, 9:08 AMBox(
Modifier
.fillMaxHeight()
.horizontalScroll(scrollState)
) {
CanvasComposable(data = chartData, settings = chartSettings, onHorizontalDrag = { dragX ->
scrollState.dispatchRawDelta(-dragX)
})
Canvas(
modifier.then(
Modifier
.fillMaxHeight()
.clipToBounds()
.pointerInput(Unit) {
// If drag is starting on a specific rectangle inside the canvas drag that otherwise scroll the parent horizontal
// composable according to the x dragAMount and (Fling?)
detectDragGestures(
onDragStart = {},
onDragEnd = {},
onDrag = {change, dragAmount ->
change.consume()
onHorizontalDrag(dragAmount.x)
//dragOffsetStart += dragAmount.x
}
)
}
)
Jonas
07/14/2022, 2:37 PMnuhkoca
07/14/2022, 4:43 PMsubscribeAsState
to collect the list but whenever there is an update in any element in the list, all item gets recomposed over and over so I am having flickers in the UI. I also pass a key per element down to LazyList
val instruments by instrumentList.subscribeAsState(initial = emptyList())
GIF in the threadJan
07/14/2022, 6:32 PMagrosner
07/14/2022, 7:34 PMFrameLayout
inside of a CoordinatorLayout
. The coordinator layout has also a bottom navigation on the bottom of the screen (tabs) there is an issue where the last row of items inside of a LazyVerticalGrid
get cut off on the bottom.
1. On api 33 (or as I understand > API 28), it intermittently happens and only seems to happen very rarely. Then it "fixes itself"
2. On api 28 I can see it happening all of the time.
I add bottom padding to the view below the last set of items to mitigate it. But when I use the nestedScroll
interop connection, it still happens.
anyone run into such an issue as this?Joseph Hawkes-Cates
07/14/2022, 8:08 PMManojna Chintapalli
07/14/2022, 9:40 PMandroid:forceDarkAllowed = true
I didn't find any useful resources on how to use this with Compose. Thanks in advance.Jasmin Fajkic
07/14/2022, 10:01 PMxxfast
07/15/2022, 12:00 AMLocalConfiguration.setLocale(locale)
- this seems to have worked, but it doesn't seem to automatically trigger recomposition by itself. Is there a way to trigger recomposition manually?Tim Malseed
07/15/2022, 12:15 AMStoreListViewModel
and StoreDetailsViewModel
StoreList lets me retrieve a list of Store(val name: String, val lat: Double, val long: Double)
And StoreDetails renders some UI for a particular Store
.
There’s no real ‘identifier’ for a Store, though I could use the hashcode or something. And there’s currently no cache for Stores.
Where do I stash this Store object? I don’t particularly want to share the StoreList's
ViewModel
with the StoreDetails
screen, as it contains properties and functions that don’t relate to StoreDetails.
Do I create a 3rd ViewModel for sharing between the two screens, and set the Store on that VM?Zoltan Demant
07/15/2022, 5:13 AMOnly composable methods can be annotated with Preview
. Usage in 🧵Jasmin Fajkic
07/15/2022, 9:26 AMAngus L
07/15/2022, 9:46 AMLaunchedEffect(someMutableState.value)
will cause a custom Layout()
in the same @Composable
function to remeasure every time the value of the key changes. Which was not what I was expecting.
This got me wondering if there is something wrong with the way LaunchedEffect
is used in this case and what the ideal approach to get around this remeasure would be.
Wrapping it into a separate @Composable
or SubcomposeLayout
would work, but that feels even worse to me.Akram Bensalem
07/15/2022, 6:43 PMNat Strangerweather
07/15/2022, 8:07 PMLocalContext.Current
for some process where I take a screenshot and share it. I have a memory leak and I think this whole process is the cause. Is there a way in which I can dispose of the context when I navigate back to the Homescreen? I thought I could use DisposableEffect
but I can't seem to make it happen (I can't work out how to use it here). I'll put my code in the thread. Thanks.elihart
07/15/2022, 9:31 PMEmmanuel
07/16/2022, 3:31 AMdarkmoon_uk
07/16/2022, 2:24 PM1.2.0-alpha01
Compose Multiplatform Dev builds? iOS source-set is resolving dependencies as expected, androidMain
is not(?)Jasmin Fajkic
07/16/2022, 3:20 PMVivek Modi
07/16/2022, 7:35 PMVivek Modi
07/16/2022, 7:35 PMandrew
07/16/2022, 7:37 PM- Modifier.size(w, h)
- Modifier.size(size)
- Modifier.width(w).height(h)
- Modifier.fillMaxWidth(weight = 1F)
- Modifier.fillMaxHeight(weight = 1F)
- Modifier.fillMaxSize(weight = 1F)
For some of the basicsRow
, Column
, Box
should all shrink to fitVivek Modi
07/16/2022, 7:41 PMandrew
07/16/2022, 7:42 PM