Vitaliy Zarubin
05/20/2021, 4:40 PMMichal Klimczak
05/20/2021, 5:34 PMBilly Newman
05/20/2021, 7:38 PMZach Klippenstein (he/him) [MOD]
05/20/2021, 8:49 PMAhmed Mourad
05/21/2021, 1:17 AMLazyVerticalGrid
, you can pass an instance of LazyListState
as a parameter, which itself takes initialFirstVisibleItemIndex
as a parameter:
LazyVerticalGrid(
cells = GridCells.Fixed(cellsPerRow),
state = rememberLazyListState(initialFirstVisibleItemIndex)
)
The problem is that the index passed to rememberLazyListState
is used as a row index instead of an item index.
So if I pass 5 as cellsPerRow
in the above example, and I pass 7 as the initialFirstVisibleItemIndex
, I would expect the second row to be the top of my list, but instead it's 7th row that is at the top.
At this point I usually have to do this to get the correct behavior:
rememberLazyListState(initialFirstVisibleItemIndex / cellsPerRow)
Jason Ankers
05/21/2021, 2:36 AMLazyColumn
? Can only see firstVisibleItemScrollOffset
which is relative to items in the listTin Tran
05/21/2021, 3:13 AMIcon
. All my Icon
turned black when using in a composable and I have to use tint
to turn it into the right color. Does anyone else having the same issue?Colton Idle
05/21/2021, 3:34 AMjean
05/21/2021, 4:42 AMAs a rule of thumb, you should create a view model to hold your state […] when the composable is close to the root of the screen.
When that’s not the case, for examples, composables that are reusables […], don’t use a view model , instead create a regular state holder class to manage state and expose events.This is said shortly after 7:32 in the video, the slide at that time refers to a
Carousel
and a ExpandableCard
but I couldn’t find any related code in the compose-sample project. Does anyone hasve a concrete/sharable example of such a “regular state holder class”?
https://youtu.be/0z_dwBGQQWQ?t=452▾
Yuri Drigin
05/21/2021, 5:24 AMinfiniteTransition
with scale effect for 3 different views, but each transition should start with delay after previous. dalay
in AnimationSpec doesn’t help. Cuz I need only start delay not for every cycleSaiedmomen
05/21/2021, 7:38 AMLazyColumn
as a state and recompose another composable based on it. I have found listState.layoutInfo.visibleItemsInfo
which works mostly except that it gets updated with every minuscule scroll and causes performance issues. Is there a pattern to implement filter or debounce like behavior with compose state?
Is my approach completely wrong?iamthevoid
05/21/2021, 8:18 AMisSystemInDarkTheme()
. For example this fun will be called isAppInDarkTheme()
. I also want to recompose all dependent composables.
Which parts and mechanism of compose is better to use to achieve behavior like it?nitrog42
05/21/2021, 8:58 AM@Preview(locale = "fr")
it remains in english for me 😄 (I'm providing a values-fr/strings.xml)
and of course I also tried @Preview(locale = "fr-rFR")
Aditya Thakar
05/21/2021, 9:58 AM@Composable
fun SplashScreen(navController: NavController) {
SplashScreenContent()
val coroutineScope = rememberCoroutineScope()
SideEffect {
coroutineScope.launch {
delay(2000)
navController.popBackStack()
navController.navigate(Screen.Home.route)
}
}
}
Vitaliy Zarubin
05/21/2021, 10:18 AMimplementation("com.google.accompanist:accompanist-glide:0.10.0")
🙁 What an accompanist wants?
https://google.github.io/accompanist/glide/Felipe Passos
05/21/2021, 11:59 AMalorma
05/21/2021, 1:35 PMLazyColumn
scrolls?
Should I set all the content inside a LazyColumn
?alorma
05/21/2021, 1:54 PMfun LazyListScope.postsListEmpty() {
item {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
Text(text = "No items")
}
}
}
allan.conda
05/21/2021, 2:17 PMscreenA/itemId/userId/someToken
Or is below better even though the syntax is for optional arguments…
screenA/itemId?userId={userId}&someToken={someToken}
natario1
05/21/2021, 3:13 PMBasicTextField
? The three fields below all have text set "x"
, and alignment is TextAlign.Start, Center and End. I'm setting the alignment from text style.rudolf.hladik
05/21/2021, 5:04 PMAlex
05/21/2021, 5:05 PMMarco Pierucci
05/21/2021, 5:30 PMZach Klippenstein (he/him) [MOD]
05/21/2021, 5:31 PMButton
-> MaterialButton
.
(Would love to hear your thinking about this in the thread! Why are you or aren’t you using prefixes?)YASAN
05/21/2021, 6:07 PMonNewIntent()
of my activity but it can sometimes throw a null exception due to it not being initiated yet.Halil Ozercan
05/21/2021, 6:08 PMColton Idle
05/21/2021, 7:35 PMhttps://www.youtube.com/watch?v=JYrpEAz_A1U▾
iamthevoid
05/21/2021, 8:47 PMtad
05/21/2021, 10:58 PMrememberSaveableStateHolder()
restore the scroll state of a LazyColumn
in a child composable?Halil Ozercan
05/21/2021, 11:23 PMswipeable
modifier. However, swipeable
accepts a predefined map of anchors which are limited unless the developer wants to put thousands of anchor points in there. Instead, I reset the swipe state everytime it gets settled and aggregate the total swipe amount. My question; is there a canonical way of doing this snapping behavior without swipeable?Halil Ozercan
05/21/2021, 11:23 PMswipeable
modifier. However, swipeable
accepts a predefined map of anchors which are limited unless the developer wants to put thousands of anchor points in there. Instead, I reset the swipe state everytime it gets settled and aggregate the total swipe amount. My question; is there a canonical way of doing this snapping behavior without swipeable?val swipeableState = rememberSwipeableState(initialValue = 0)
var daysOffset by remember { mutableStateOf(0) }
val progress = swipeableState.progress
LaunchedEffect(progress) {
if (progress.fraction == 1f && <http://progress.to|progress.to> == progress.from) {
daysOffset -= <http://progress.to|progress.to>
swipeableState.snapTo(0)
}
}
.swipeable(
state = swipeableState,
anchors = (-7..7)
.map {
it * (24 * 3600 / secondPerPixel) to it
}
.toMap(),
orientation = Orientation.Horizontal
)
Only 7 anchors are enough because view is limited by a week. If there is no swipe reset, scrolling would completely stop in one week range.Doris Liu
05/22/2021, 12:18 AMswipeable
API, you might want to reach for a lower level API. In this case, I'd recommend dragable
and Animatable
. It may not be that much more code than the hack you have right now. 😛 At the end of the drag, you'd need to use that velocity to calculate the natural stopping point, find the closest anchor among any number of anchors that you might have, and animateTo
it. In fact, there's a good example in the animation codelab for this.scrollable
with a custom FlingBehavior
🙂Halil Ozercan
05/22/2021, 6:31 AMswipeable.progress
.Doris Liu
05/25/2021, 12:05 AM