Eric Ampire [MOD]
06/15/2021, 6:58 PM@Composable
fun TestCardClickable() {
Card(
backgroundColor = Color.Red,
modifier = Modifier.size(100.dp).clickable {
Timber.e("Click")
},
content = {
}
)
}
Daniel
06/16/2021, 1:20 AMfun updatePreconditions(activity: Activity, playServicesPreconditionMetState: MutableState<Boolean?>, settingsPreconditionMetState: MutableState<Boolean?>): Unit
It "returns" by assigning to the states, which I think is cleaner in this case than having generic callbacks. Android Studio tells me I should write it UpdatePreconditions
, but I'd assume something named like that affected the visible uiSlackbot
06/16/2021, 3:57 AMaipok
06/16/2021, 5:11 AM.clickable
ripple effect color on the theme level to avoid
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(color = MaterialTheme.colors.secondary),
onClick = onClicked
)
every time I want to apply theme color?julioromano
06/16/2021, 7:09 AMComposeView
is it generally a bad practice to call setContent
multiple times?
My worry is that doing that will not trigger a recomposition (based on the existing content set in the previous setContent
call) but rather a full composition from scratch.Akram Bensalem
06/16/2021, 8:29 AMgitai
06/16/2021, 10:11 AMMarcin Mazurek
06/16/2021, 11:03 AMNavHost(startDestination = "profile/{userId}") {
...
composable("profile/{userId}") {...}
}
Hello how to pass argument to navhost start destinationAlex
06/16/2021, 11:32 AMOutlinedTextField
?Alex
06/16/2021, 11:54 AMgitai
06/16/2021, 4:15 PMRavi
06/16/2021, 4:56 PMAndroid Studio Arctic Fox | 2020.3.1 Beta 4
, I’m using hilt 2.37
* Exception is:
java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension$DefaultImpls
at dagger.hilt.android.plugin.HiltGradlePlugin.configureBytecodeTransformASM(HiltGradlePlugin.kt:258)
at dagger.hilt.android.plugin.HiltGradlePlugin.configureHilt(HiltGradlePlugin.kt:89)
at dagger.hilt.android.plugin.HiltGradlePlugin.access$configureHilt(HiltGradlePlugin.kt:59)
at dagger.hilt.android.plugin.HiltGradlePlugin$apply$1.execute(HiltGradlePlugin.kt:66)
Tash
06/16/2021, 5:43 PMMutableState<T>
as arguments:
@Composable fun FooButton(fooState: MutableState<Foo>) { /** read/write fooState here **/ }
instead of accepting the raw data (i.e. not MutableState
) + a lambda for the caller to implement:
@Composable fun FooButton(foo: Foo, onClick: () -> Unit) { /** read foo & call onClick() here **/ }
Given the guidelines around state-hoisting for reads/writes, the former looks like an anti-pattern in the declarative/Compose world. Is that right?Michal Thomka
06/16/2021, 6:32 PMModifier.verticalScroll()
from taking over/canceling vertical drag events in nested AndroidView (contains 3rd party Java chart component)?julioromano
06/16/2021, 7:09 PMCLOVIS
06/16/2021, 7:21 PMremember
is used to keep values across recomposition (with a normal variable it would be re-computed everytime)
• State<T>
is used to represent something that can change overtime (or not)
The thing I don't understand is how Compose knows which state force a recompose, and which don't. I thought remember
was used to tell Compose that the current Composable
needed to ‘subscribe/observe' that state; however after reading other comments in this channel I'm confused whether I completely misunderstood something.Hachemi Hamadi
06/17/2021, 9:17 AMste
06/17/2021, 10:13 AMtaponidhi
06/17/2021, 11:16 AMremember{mutableStateOf(<data>)}
for every type of data?dimsuz
06/17/2021, 12:37 PMconfirmStateChange = { notifyStateChangeRequest(it); false }
where notifyStateChangeRequest()
will decide what state to switch to and cause
LaunchedEffect(newSheetState) { scaffoldState.bottomSheetState.animateTo(newSheetState) }
.
The problem is that confirmStateChange { false }
causes Swipeable
to start its own "rollback to previous state" animation which conflicts with mine and produces a visible jitter. Is there a way around this?julioromano
06/17/2021, 1:30 PMmutableStateListOf
and mutableStateMapOf
but no mutableStateSetOf
?rajesh
06/17/2021, 2:22 PMMichał Diner
06/17/2021, 2:26 PMBottomSheet(navController) {
BottomNavigationBar(
navController,
navHost)
}
ModalBottomSheetLayout(
sheetState = bottomSheetScaffoldState,
sheetContent = {...}
content = {
bottomNavigationBar()
Unaccaptable alternatives:
1. BottomSheet opened up by navigation -> replaces current screen and is above the BottomNavBar
2. BottomSheet initialised on currently displayed screen -> shows up above the BottomNavBar.
Any ideas how to improve this or is this it?Andrey Nikanorov
06/17/2021, 3:11 PMChris Fillmore
06/17/2021, 5:07 PM@Composable
fun MainNavHost(
navController: NavHostController,
plugin: Plugin,
) {
NavHost(...) {
// Define regular navigation within the activity
composable(...) {
...
}
// Call this here to define nested navigation for plugin(s)
plugin.navGraph(navController)
}
}
interface Plugin {
fun NavGraphBuilder.navGraph(navController: NavHostController)
...
}
This seems fine to me, though I don’t like passing navController
down to the plugin. But it isn’t obvious to me how to avoid this, since there will be navigation to do within the plugin.
But… does this seem sensible? Any risks stand out to you that I may not have considered? Any feedback is appreciated, thanks!David Albers
06/17/2021, 6:10 PMLazyColumn
s within a scrolling `Column`/other container? 🧵AN
06/17/2021, 6:36 PMmario
06/17/2021, 10:38 PMTravis Griggs
06/17/2021, 10:48 PMfrankelot
06/17/2021, 11:22 PMfrankelot
06/17/2021, 11:22 PMIan Lake
06/17/2021, 11:32 PMhttps://www.youtube.com/watch?v=0z_dwBGQQWQ▾
frankelot
06/17/2021, 11:35 PMIan Lake
06/18/2021, 12:04 AMfrankelot
06/18/2021, 12:10 AM@Composable
fun MainScreen() {
val vm = viewModel()
....
Foo()
...
}
@Composable
fun Foo() {
val anotherVm = viewModel()
....
}
tad
06/18/2021, 2:04 AMfrankelot
06/18/2021, 8:19 AMit doesn’t need to be monolithicWould love to learn more about this though, how can I avoid a god VM in very complex screens 🤔 … should I just use 2 or more VMs at the top level
Cicero
06/20/2021, 10:41 AMfrankelot
07/06/2021, 7:28 AMdarkmoon_uk
09/27/2021, 11:43 PMTextField
and Drop-Down List components constructed from TextField
and DropDownMenu
. Each component has its own sub-VM to manage loading of data/valid states; validation of input both in real-time and at final submission etc. These are clearly reusable units of business logic that mirror the View layer in structure. Hard to imagine having it any other way... copying and pasting this functionality in a single VM would be 🤢. Structuring presentation logic alongside the View feels natural to me and also encourages keeping the View layer (Compose declarations) as thin as possible, meaning easier portability to other systems/flavours of View layer (e.g. Compose for Web). At the end of the day it's whatever works for you - here's a counter-point 🙂