why
09/02/2021, 12:39 PMOutlinedTextField
, the memory profiler, after setting focus on/selecting the text field without typing anything, shows that Java allocations are happening non-stop, it keeps goin up until it gets GCed, then start going up again over n over, am I missing something?
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
OutlinedTextField(value = "Ok", onValueChange = {})
}
}
Bacho Kurtanidze
09/02/2021, 12:55 PMScott Kruse
09/02/2021, 2:28 PMTolriq
09/02/2021, 4:43 PMChris Johnson
09/02/2021, 7:03 PMLayout
for measurement of the child and then another Layout
that will place X amount of those children based on screen height. The problem I ran into was each child I'm placing needs to be unique/not being currently laid out for the system to not give me "Place was called on a node which was placed already"
.Anthony
09/02/2021, 7:38 PMandroidx.navigation:navigation-compose:2.4.0-alpha08
yet? I seem to be getting an error every time I navigate back to a composable using a navigation graph scope viewmodel.Lilly
09/02/2021, 9:49 PMFlow
that comes from view model? I have a Flow
that produces values for LazyColumn
. Do I have to put the values into a SnapshotStateList
or can I feed the LazyColumn
on the fly with the values? How would I do this?Sanendak
09/02/2021, 10:21 PMNapa Ram
09/03/2021, 5:48 AMallan.conda
09/03/2021, 5:50 AMval displayTime = remember(message.createdTime) {
DateUtils.getRelativeTimeSpanString(message.createdTime * 1_000).toString()
}
Text(displayTime)
When we refresh, we want to update the relative time text but it doesn’t
a recomposition when the time value doesn’t change.
Any idea how to handle this kind of scenario?smit01
09/03/2021, 7:17 AMLilly
09/03/2021, 12:19 PMval requestPermissionLauncher = rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted ->
...
}
and requestPermissionLauncher.launch(permission)
. I have discovered that requestPermissionLauncher.launch(permission)
is responsible for opening the "android permission prompt" false
without waiting for a user action. When I click "Allow" btn the callback is triggered with true
. Is the first run with false inteded? Do we have to suspend here and wait for a user action somehow? I would expect that the callback is only triggered when a button of the prompt is clciked.ursus
09/03/2021, 12:45 PMJoey
09/03/2021, 12:46 PMtylerwilson
09/03/2021, 6:55 PMBox(fillMaxWidth) {
Row(horizontalScroll) {
items.forEach {
Column(width(<boxWidth here>) {
}
}
}
}
I want to dynamically change the inner column width to be the same as the ancestor box (it should be width of device), or some percentage (half or quarter). How can I reference the Box width in order to size the Column(s) properly? Thank you!Carl Benson
09/03/2021, 7:17 PMDialog
to setDecorFitsSystemWindows
to false?josefdolezal
09/03/2021, 9:05 PMButtons
colors based on enabled
? What comes to my mind is to create my own class implementing ButtonColors
which would then animate the color using animateColorAsState
, but it seems a bit too verboseadjpd
09/03/2021, 9:08 PMTextInputLayout
and TextField
? Moreover, is there a plan to make Jetpack Compose the primary view system for Android, or just an alternative?Justin Yue
09/04/2021, 4:38 AMLazyVerticalGrid
inside a Column
with a scroll state, so I now know that I can't nest composables scrolling in the same direction. However, I'm only using LazyVerticalGrid
since the cells can be adaptive, and I don't need its scroll functionality. Is there a way to create a composable that can replicate `LazyVerticalGrid`'s adaptive functionality and removing the scrolling?rajesh
09/04/2021, 10:49 AMfillMaxSize()
) of box having pinch to zoom ability? code is in thread.Lorenzo Benevento
09/04/2021, 11:56 AMBottomSheetScaffold
but as soon as you try to do the same thing with a ModalBottomSheetLayout
it throws java.lang.IllegalArgumentException: The initial value must have an associated anchor.
because you are initializing it with a null value. If you just swap the two or more contents instead of setting a null value when you close the ModalBottomSheet
it will work but it won't animate correctly.Se7eN
09/04/2021, 1:53 PMclass Element {
var position: Offset by mutableStateOf(...)
var rotation: Float by mutableStateOf(...)
...
}
// Then I can do this:
val element = Element(...)
element.position = newPosition
I want to pass this element
object to a composable but don't want it to be mutable. I can create a similar class for an immutable element but then I'd have to update the immutable class whenever I change the Element
class. Is there something else I can do?Fudge
09/04/2021, 2:39 PMLayout
? the use case is to animate a component moving from one part of the screen to another.rajesh
09/04/2021, 5:55 PMTextField
? BasicTextField
support decoration but lacks some of the features that TextField
provides like leading icon. Is there any custom text field created by someone ?adjpd
09/04/2021, 7:01 PMrememberCoroutineScope().launch { }
then bugs may appear; since Compose can call the composables at any moment. In this scenario, or in any scenario, when is it likely to happen? I understand the concept but I can't think of any examples when this may actually happen.
LaunchedEffect(onTimeout) {
delay(SplashWaitTime)
onTimeout()
}
Colton Idle
09/05/2021, 2:34 AMColumn(modifier = Modifier.padding(horizontal = 16.dp)) {
every item need the horizontal padding except for 1 item in the col. Is there an easy way to "opt out"?Colton Idle
09/05/2021, 4:01 AMshahroz
09/05/2021, 8:54 AMbitkiller
09/05/2021, 3:04 PMtext
) of the dialog is just
Column
Box // clipped to Circle
Text
But with this ^ the content is being place over the dialog's title.Viktor Petrovski
09/05/2021, 8:21 PMViktor Petrovski
09/05/2021, 8:21 PMColton Idle
09/05/2021, 8:22 PMViktor Petrovski
09/05/2021, 8:23 PM@Composable
fun Navigation() {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = Screens.SplashScreen.route) {
composable(Screens.SplashScreen.route) {
val authViewModel = hiltViewModel<AuthViewModel>(it)
SplashScreen(authViewModel, navController)
}
composable(Screens.Home.route) {
val feedViewModel = hiltViewModel<FeedViewModel>()
HomeFeedScreen(feedViewModel.state.value)
}
}
}
@Composable
fun SplashScreen(
viewModel: AuthViewModel,
navController: NavController
) {
val state = viewModel.state.collectAsState()
if (state.value.isSuccess) {
navController.navigate(Screens.Home.route) {
popUpTo(Screens.SplashScreen.route) {
inclusive = true
}
}
} else {
// Render view...
}
ViewModel:
@HiltViewModel
class AuthViewModel
@Inject constructor(private val useCase: CreateAnonymousUserUseCase) :
ViewModel() {
private val _state: MutableStateFlow<AnonAuthResponse> = MutableStateFlow(AnonAuthResponse())
val state: StateFlow<AnonAuthResponse> = _state
init {
crateAnonUser()
}
private fun crateAnonUser() {
viewModelScope.launch {
useCase.createAnonymousUser().collect {
_state.value = _state.value.copy(isSuccess = it.isSuccess, loading = it.loading)
}
}
}
}
Added delay instead of the actual network request to maket things easier:
fun createAnonymousUser(): Flow<AnonAuthResponse> = flow {
kotlinx.coroutines.delay(2500)
emit(AnonAuthResponse(isSuccess = true))
}
If I remove the delay everything works fine, but when I add it it keeps on navigating to HomeScreen and re-rendering the SplashScreen.
Thanks 🙏Ian Lake
09/05/2021, 9:53 PMnavigate()
as part of composition. That's always wrong (composition should never have side effects) - you'll end up calling navigate()
on every frame of the animation between destinations, which is absolutely not what you wantColton Idle
09/05/2021, 9:59 PMadjpd
09/05/2021, 10:42 PMColton Idle
09/05/2021, 10:58 PMViktor Petrovski
09/06/2021, 7:35 AMIan Lake
09/06/2021, 2:41 PMif (state.value.isSuccess) {
// Use the value as the key
// so that it only happens once
LaunchedEffect(state.value) {
// Call navigate here
}
}
Viktor Petrovski
09/06/2021, 2:42 PMColton Idle
09/06/2021, 5:24 PMLaunchedEffect(state.value.isSuccess)
?Viktor Petrovski
09/06/2021, 5:24 PMIan Lake
09/06/2021, 9:22 PMby
and you wouldn't need the .value
everywhere in the first place, but yes, I was assuming immutable objects where it wouldn't make a difference - the point is that the Launched effect would run just once for a given value change