elye
02/27/2022, 11:09 AMdimsuz
02/27/2022, 11:17 AMnavControler.graph.addAll(otherGraph)
/`navController.graph.addDestination()` after navigation has started? For example I want to dynamically decide, based on some user choice, that I want to add a whole bunch of new destinations. Will this work OK (+with composables in the graph)? Or is navigation component designed only so that whole graph must be constructed at once on the start?Colton Idle
02/27/2022, 11:24 PMmutableStateListOf<T>
but when I call clear() and then addAll() to it, it seems like compose tries to be "smart" and apply only the changes between the two lists. Is there a way to "opt out" of that behavior?
So Im looking to go from this:
state.list.clear()
state.list.addAll(networkResult.newItems)
to something like this (completely made up api)
state.list.clear().commitTransactionAndWait()
state.list.addAll(networkResult.newItems).commitTransactionAndWait()
YASAN
02/28/2022, 9:19 AMColumn
inside a Row
. The Column
has a Modifier.weight(1f)
inside if which fills the UI with a blank space. Once I add Modifier.requiredHeight(IntrinsicSize.Min)
to the Row
, the weight modifier wont work anymore (it will have width of 0.
My IntrinsicSize.Min
is applied to height only, why is it affecting the width of my items? Ill post some code in the threadSean Proctor
02/28/2022, 12:28 PMaoriani
02/28/2022, 2:32 PMmartinsumera
02/28/2022, 2:44 PM@MyCustomPreviews("component name")
which be equivalent of the following code
@Preview(name = "ProgressButtonPreview")
@Preview(name = "ProgressButtonPreview - night", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Preview(name = "ProgressButtonPreview - scaled font", fontScale = 3f)
@Preview(name = "ProgressButtonPreview - en", locale = en)
...
@Preview(name = "ProgressButtonPreview - api 26", apiLevel = 31)
Enrico Saggiorato
02/28/2022, 6:23 PMbrabo-hi
03/01/2022, 4:11 AM...lo world!
Siyamed
03/01/2022, 10:53 AMhfhbd
03/01/2022, 11:21 AMActivityResultContracts.TakePicture()
should return the file to match Compose declarative style. Currently, you have to create the file first, and keep a reference to it to use it after the camera intent finished successfully. Creating a TakePicturePlus()
returning Uri?
instead does not work, because the TakePicture
result intent is almost empty.Kata
03/01/2022, 2:13 PMBadgedBox
, like it was possible for BadgeDrawable
?Oleg Tretiakov
03/01/2022, 2:18 PMtheapache64
03/01/2022, 3:07 PMB
null?.let {
println("A")
} ?: println("B")
but the below code doesn’t render B
null?.let {
Text(text = "A")
} ?: Text(text = "B")
Why? 🤔Marcin Wisniowski
03/02/2022, 2:21 AMLazyVerticalGrid
?Abhishek Dewan
03/02/2022, 6:39 AMoverride fun navigateToHome() {
navController.navigate(RootScreen.Home.route) {
val popUpRoute = navController.currentBackStackEntry?.destination?.route ?: ""
popUpTo(popUpRoute) {
inclusive = true
}
}
}
I would like to make sure that I can clear the back stack completely and then navigate to home. The way I understand navigation, calling popUpTo(currentScreenOnBackStack) should clear all the backstack before we navigate to Home and should account for both scenarios above. I’m sure I’m misunderstanding something obvious. Would appreciate if someone could point it out for me.ildar.i [Android]
03/02/2022, 8:16 AMwintersoldier
03/02/2022, 8:21 AMAnkit Dubey
03/02/2022, 11:21 AMandroid:digits="abcdefghijklmnopqrstuvwxyz1234567890 "
Luka
03/02/2022, 2:12 PMNick
03/02/2022, 2:36 PMTim Malseed
03/02/2022, 2:36 PMval selected = currentDestination
?.hierarchy
?.any { it.route == bottomNavItem.destination.route } == true
1. Is the idea that you have to leverage nested graphs in order for this to work?
I’m sure this probably makes sense (because how else does Compose know that a particular destination belongs to the same hierarchy)
So, assuming that is the case
2. If you have a screen that is accessible from two different Bottom Navigation roots.. You’d have to declare that route twice (once in each graph)?
If that’s how it works, cool. Just want to make sure I’m thinking about this the right wayMarcin Wisniowski
03/02/2022, 5:17 PMste
03/02/2022, 6:05 PMModifier.swipeable
is part of compose-material
, is there a specific reason? (I mean, it may be useful to non material design users - it also doesn't depend on any MD specific item, of course)mattinger
03/02/2022, 11:18 PMChris Johnson
03/03/2022, 12:07 AMsmallshen
03/03/2022, 12:58 AMAndy Himberger
03/03/2022, 3:34 AMif (event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN) &&
event.getToolType(0) == MotionEvent.TOOL_TYPE_FINGER
) {
// Accessibility touch exploration
return accessibilityDelegate.dispatchHoverEvent(event)
}
Keyboard navigation visuals work fine with the samsung keyboard, its just the trackpad thats not workingsunnat629
03/03/2022, 6:55 AMimplementation "androidx.navigation:navigation-compose:2.4.1"
compose version, I tried both 1.1.0 and 1.2.0-alpha04
I am trying to use this and where I create and add the bottomBar , I got Skipped * frames! The application may be doing too much work on its main thread* without adding any view.
my code snaps -
@Composable
fun BottomNavigationBar(navController: NavHostController) {
BottomNavigation(
backgroundColor = AppColors.BottomNav,
) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
items.forEach { screen ->
BottomNavigationItem(
icon = {
Icon(
painterResource(screen.drawableResId),
tint = AppColors.secondary,
contentDescription = screen.route
)
},
label = { Text(stringResource(screen.resourceId)) },
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {}
)
}
}
}
@ExperimentalMaterialApi
@ExperimentalFoundationApi
@Composable
fun SportWorldUi() {
val navController = rememberNavController()
Scaffold(
topBar = { TopBar(navController) },
bottomBar = { BottomNavigationBar(navController) },
// backgroundColor = Color.Transparent,
modifier = Modifier.fillMaxSize()
) { innerPadding -> }
If I remove bottomBar = { BottomNavigationBar(navController) },
, it works fine.
Where is the issue here?
Thanksziv kesten
03/03/2022, 9:46 AMziv kesten
03/03/2022, 9:46 AMTim Malseed
03/03/2022, 10:29 AMlike this
Which makes it a bit easier for us to read your code.
Can you show us where trackProgress
is referenced? I can see the slider, but I can’t see why the Card would recompose, because I can’t see what code surrounds your Card
ziv kesten
03/03/2022, 10:35 AM@Composable
fun AudioTrackView(viewModel: VoiceRecordingViewModel){
Row(...) {
PlayPauseButton() { viewModel.clickAction() }
Slider(
value = viewModel.trackProgress,
valueRange = 0f..duration,
modifier = Modifier
.weight(1f)
.fillMaxWidth()
onValueChange = { newValue ->
viewModel.goToTrackPosition(newValue)
},
)
Text(...)
TrashIcon()
}
}
trackProgress
which is streamed from the view model is given as the value of the sliderTim Malseed
03/03/2022, 10:38 AMAudioTrackView
here. I don’t see why viewModel.trackProgress
would cause thisAudioTrackView
?viewModel.goToTrackPosition()
?ziv kesten
03/03/2022, 10:39 AMTim Malseed
03/03/2022, 10:42 AMAudioTrackView
?ziv kesten
03/03/2022, 10:42 AMfun VoiceRecordInput(viewModel: VoiceRecordingViewModel) {
Column(...)
{
Text(...)
Text(...)
LaunchedEffect(viewModel) {
snapshotFlow {
viewModel.items.firstOrNull { it.state.isIdle && !it.state.targetState }
}.collect {
if (it != null) {
viewModel.cleanInvisibleItems()
}
}
}
LazyColumn(
content = {
items(
items = viewModel.items,
itemContent = { item ->
AudioTrackView(viewModel, item.audioTrack)
}
)
}
)
Box(...)
Text(...)
Button(...)
}
}
Tim Malseed
03/03/2022, 10:48 AMLogCompositions
to your composables, with a different tag for each one, you can narrow down where your excessive recomposition is coming from.ziv kesten
03/03/2022, 10:51 AMPlayPauseButton() { viewModel.clickAction() }
that contains an AnimatedVisibility
component, i am still investigating but appreciate the help, i hep post my findings here.Tim Malseed
03/03/2022, 11:22 AMMutableInteractionSource()
, but instead use
remember { MutableInteractionSource() }
ziv kesten
03/03/2022, 11:26 AMAnimatedVisibility
Tim Malseed
03/03/2022, 11:30 AMziv kesten
03/03/2022, 11:34 AM@ExperimentalAnimationApi
@Composable
private fun AnimatedVisibilityWrapper(
modifier: Modifier,
visible: Boolean,
rotation: Float,
onClick: () -> Unit,
content: @Composable () -> Unit
) {
LogCompositions(tag = "AnimatedVisibilityWrapper")
AnimatedVisibility(
visible = visible,
enter = fadeIn(
animationSpec = tween(delayMillis = 50, durationMillis = 300, easing = FastOutLinearInEasing)
),
exit = fadeOut(
animationSpec = tween(delayMillis = 50, durationMillis = 300, easing = FastOutLinearInEasing)
)
) {
Card(
backgroundColor = Color(255, Random.nextInt(0, 255), Random.nextInt(0, 255), Random.nextInt(0, 255)),
elevation = 0.dp,
modifier = modifier.then(
Modifier
.fillMaxSize()
.graphicsLayer { rotationZ = rotation }
.clickable(
interactionSource = MutableInteractionSource(),
indication = rememberRipple(
radius = 20.dp,
bounded = false
)
) {
onClick()
},
)
) { content() }
}
}
AnimatedVisibilityWrapper(
modifier = Modifier.align(Center),
visible = !isPlaying,
rotation = animateFloatAsState(targetValue = if (isPlaying) 180f else 0f).value,
onClick = { viewModel.playClicked(audioTrack.id) }
) {
Icon(
painterResource(id = R.drawable.ic_play),
modifier = Modifier.align(Center),
contentDescription = "Localized description",
tint = colorResource(id = R.color.lemonade_pink)
)
}
isPlaying
is
val isPlaying = viewModel.playing(audioTrack.id)
Tim Malseed
03/03/2022, 11:41 AMi tried to post only relevant code as much as possibleYes, fair enough haha
ziv kesten
03/03/2022, 11:42 AMTim Malseed
03/03/2022, 11:46 AMziv kesten
03/03/2022, 11:47 AMTim Malseed
03/03/2022, 11:48 AMziv kesten
03/03/2022, 11:49 AMTim Malseed
03/03/2022, 11:50 AMziv kesten
03/03/2022, 11:51 AMTim Malseed
03/03/2022, 11:52 AMziv kesten
03/03/2022, 11:53 AMmyanmarking
03/03/2022, 3:01 PMziv kesten
03/03/2022, 3:03 PMmyanmarking
03/03/2022, 3:05 PMziv kesten
03/03/2022, 3:12 PMmyanmarking
03/03/2022, 3:19 PMSurface(
modifier = Modifier
.fillMaxSize(),
color = MaterialTheme.colors.background
) {
var value by remember {
mutableStateOf(0f)
}
LaunchedEffect(key1 = Unit) {
while (true) {
delay(100)
value += 1f
}
}
Row {
Button(onClick = {
Log.i("TAG", "Clicked")
}) {
Text(text = "Button: $value")
}
Slider(value = value, onValueChange = {}, valueRange = 0f..1000f)
}
}
Quick test with a similar sample, it works as expected even when it is recomposing the button. hm .. interestingziv kesten
03/03/2022, 3:27 PMmyanmarking
03/03/2022, 3:28 PMziv kesten
03/03/2022, 3:29 PM