Se7eN
10/30/2020, 10:23 AMjava.lang.UnsupportedOperationException: Parcelables don't support default values.
at androidx.navigation.NavType$ParcelableType.parseValue(NavType.java:679)
at androidx.navigation.NavType.parseAndPut(NavType.java:96)
at androidx.navigation.NavDeepLink.parseArgument(NavDeepLink.java:306)
at androidx.navigation.NavDeepLink.getMatchingArguments(NavDeepLink.java:260)
at androidx.navigation.NavDestination.matchDeepLink(NavDestination.java:474)
at androidx.navigation.NavGraph.matchDeepLink(NavGraph.java:79)
at androidx.navigation.NavController.navigate(NavController.java:1025)
at androidx.navigation.NavController.navigate(NavController.java:1008)
at androidx.navigation.NavController.navigate(NavController.java:994)
at androidx.navigation.compose.NavHostControllerKt.navigate(NavHostController.kt:100)
This is my code:
composable(Routing.Root.Main.route) {
Routing.Root.Main.Content(
onChatClick = { user ->
navController.navigate("${Routing.Root.Conversation.route}/${user}")
}
)
}
composable(
"${Routing.Root.Conversation.route}/{user}",
arguments = listOf(navArgument("user") { type = NavType.ParcelableType(User::class.java) })
) { backStackEntry ->
backStackEntry.arguments?.getParcelable<User>("user")?.let { user ->
Routing.Root.Conversation.Content(user = user)
}
}
And this is the User class:
@Parcelize
data class User(
val name: Name,
val picture: Picture
) : Parcelable
@Parcelize
data class Name(
val first: String,
val last: String,
val title: String
) : Parcelable
@Parcelize
data class Picture(
val large: String,
val medium: String,
val thumbnail: String
) : Parcelable
I know @Ian Lake suggested using IDs but I don't wanna bother with that right now for a sample app. How can I fix this?Kshitij Patil
10/30/2020, 12:24 PMPhilip Blandford
10/30/2020, 12:49 PMGrzegorz Baczek
10/30/2020, 1:47 PMcb
10/30/2020, 4:29 PMpavi2410
10/30/2020, 6:10 PMPrashant Priyadarshi
10/30/2020, 6:39 PMTextField(
value = text.value,
onValueChange = { s ->
text.value = s
},
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Send,
onImeActionPerformed = { action: ImeAction, keyboard: SoftwareKeyboardController?
->
// close keyboard when submit button is clicked
if(action == ImeAction.Send)
keyboard?.hideSoftwareKeyboard()
},
)
loloof64
10/30/2020, 7:34 PMloloof64
10/30/2020, 7:44 PMOussama Haff.
10/30/2020, 8:47 PM+ Parent // retrieves state from ViewModel, declares fun action on VM
|
|---+ Child A // passes state without using it, passes action as fun
|
|---+ Child A-1 // uses state
|
|---+ Child A-2
|
|---+ Child A-3 // invoke the action fun
When : invoking the passed action by clicking on Child A-3
Then :
+ Parent // will NOT recompose
|
|---+ Child A // will recompose (because A-1 recompose)
|
|---+ Child A-1 // will recompose
|
|---+ Child A-2 // will NOT recompose
|
|---+ Child A-3 // will NOT recompose
ziv kesten
10/30/2020, 9:27 PM3bdoelnaggar
10/31/2020, 12:05 AMVsevolod Ganin
10/31/2020, 12:38 AMDropdownMenu
and DropdownMenuItem
but I can’t figure what to put in toggle
to make it look like from design doc. It seems that there should be either TextField
or OutlineTextField
but these are very unfriendly when I try to mute their text editing capabilitiesNat Strangerweather
10/31/2020, 9:41 AMSe7eN
10/31/2020, 10:55 AMText(user?.name ?: "")
make the code ugly?Grigorii Yurkov
10/31/2020, 11:50 AMnavigation-compose
advantages over simple when (screen) {...}
?
@Composable
private fun AppContent(
navigationViewModel: NavigationViewModel,
postsRepository: PostsRepository,
interestsRepository: InterestsRepository
) {
Crossfade(navigationViewModel.currentScreen) { screen ->
Surface(color = MaterialTheme.colors.background) {
when (screen) {
is Screen.Home -> HomeScreen(
navigateTo = navigationViewModel::navigateTo,
postsRepository = postsRepository
)
is Screen.Interests -> InterestsScreen(
navigateTo = navigationViewModel::navigateTo,
interestsRepository = interestsRepository
)
is Screen.Article -> ArticleScreen(
postId = screen.postId,
postsRepository = postsRepository,
onBack = { navigationViewModel.onBack() }
)
}
}
}
}
(code from JetNews)grandstaish
10/31/2020, 12:55 PMCheckbox
(but also not appear disabled)?
Context: I have a ListItem
with a trailing Checkbox
where clicking the list item toggles the checked state. I’m currently sharing the interactionState
between the checkbox and list item so that they ripple together. Sharing interactions like this is cool, but I’d prefer having no ripple at all on the checkboxSe7eN
10/31/2020, 1:21 PMNavHost
. Is this intended? How can I scope the view models to the NavHost
or activity?
NavHost(navController = navController, startDestination = "screen1") {
composable("screen1") { Screen1() }
composable("screen2") { Screen2() }
}
@Composable fun Screen1() {
val viewModel: MainViewModel = viewModel()
}
@Composable fun Screen2() {
val viewModel: MainViewModel = viewModel()
}
Najib Ghadri
10/31/2020, 1:59 PMjaqxues
10/31/2020, 2:34 PMSe7eN
10/31/2020, 3:33 PMonBackPressed
listener? I want to override onBackPressed to make sure I don't navigate back in certain casesFunkyMuse
10/31/2020, 4:00 PMHalil Ozercan
10/31/2020, 5:08 PMcomposed
) and that state depends on the size of the composable that it is attached to. For example, initial state is going to have 50 random objects if size is smaller than a threshold, 100 objects if it is larger.Nat Strangerweather
10/31/2020, 5:41 PM@Composable
fun CirclesLayout() {
val selectedState = remember { mutableStateOf(false) }
ScrollableRow {
for (circle in listOf()) {
Circles(
color = if (!selectedState.value) Color(0xffA5D6A7) else Color(0xff4CAF50),
gradientColor = Color(0xff4CAF50),
text = "Alarms",
selected = selectedState.value,
onSelected = { selectedState.value = !selectedState.value }),
Circles(
color = if (!selectedState.value) Color(0xffB39DDB) else Color(0xff673AB7),
gradientColor = Color(0xff673AB7),
text = "Media Sounds",
selected = selectedState.value,
onSelected = { selectedState.value = !selectedState.value }),
Circles(
color = if (!selectedState.value) Color(0xffFFAB91) else Color(0xffFF5722),
gradientColor = Color(0xffFF5722),
text = "Touch Sounds",
selected = selectedState.value,
onSelected = { selectedState.value = !selectedState.value })
}
}
}
Any ideas? Thanks!Se7eN
10/31/2020, 6:03 PMval navController = rememberNavController()
val visible by remember { mutableStateOf(false) }
Scaffold(
...
) {
NavHost(navController, "screen1") {
composable("screen1") { ... }
composable("screen2") { ... }
}
}
AnimatedVisibility(visible) {
Box(modifier = Modifier.fillMaxSize()) { ... }
}
When I'm on screen2 and the AnimatedVisiblity
becomes visible, it automatically navigates to screen1. This feels like a bug 🤔jaqxues
10/31/2020, 6:34 PMRobert Menke
10/31/2020, 7:03 PMromainguy
10/31/2020, 7:59 PMHalil Ozercan
10/31/2020, 9:28 PMhttps://youtu.be/iCe5f7L9vBg▾
FunkyMuse
10/31/2020, 10:54 PMFunkyMuse
10/31/2020, 10:54 PMAdam Powell
10/31/2020, 11:46 PMLifecycleObserver
, LifecycleOwnerAmbient
and DisposableEffect
together to get exactly that, but there might be a better fit for what you're doing. What's the use case?FunkyMuse
11/01/2020, 9:48 AMAdam Powell
11/01/2020, 2:20 PM