therealbluepandabear
03/13/2021, 5:37 AMjaqxues
03/13/2021, 9:41 AMandroid.app.Activity
?
I see that it requires a ViewTreeLifecycleOwner
, which can be instantiated and set manually. However the ViewTreeSavedStateRegistryOwner
cannot be instantiated, so it must be used with an AppCompatActivity, right?
Is there any way for me to get a ViewTreeSavedStateRegistryOwner
without AppCompatActivity or get Compose (specifically ComposeView
, which checks for these) to work?Lauren Yew
03/13/2021, 11:19 AM1.0.0-beta01
(Android Gradle plugin 7.0.0-alpha09) into an app that doesn't have jetpack compose and android gradle plugin 4.1.0. I'm getting an error
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/internal/ComposableLambdaKt;
when I try to open up my compose views from the library.
Has anyone seen this kind of issue before / know a fix?
I thought compose could be used in a library only and then not be required for the app (my client app has product requirements limiting it from updating the AGP / going to compose).Gabriel
03/13/2021, 12:09 PMmannodermaus
03/13/2021, 1:37 PMYasin Kaçmaz
03/13/2021, 3:58 PM1.0.0-beta02
and MaterialTheme.colors.isLight
does not change when we give light and dark themes with a Boolean mutable state. It was working before. Is there anyone else with the same situation.Shakil Karim
03/13/2021, 4:07 PM@Composable
fun ClubItem(club: Club,
selectedClubs: List<Club> = emptyList(),
onItemClicked: (Club) -> Unit) {
val isSelected by remember { derivedStateOf { selectedClubs.contains(club) } }
}
@Composable
fun ClubItem(club: Club,
selectedClubs: List<Club> = emptyList(),
onItemClicked: (Club) -> Unit) {
val isSelected by remember { mutableStateOf(selectedClubs.contains(club)) }
}
Afzal Najam
03/13/2021, 4:16 PMfillMaxSize()
and using fillMaxHeight().fillMaxWidth()
?alorma
03/13/2021, 4:54 PM"".toUpperCase()
?Slackbot
03/13/2021, 6:54 PMSe7eN
03/13/2021, 7:02 PMNoop
03/13/2021, 8:54 PMJan Skrasek
03/14/2021, 12:16 AMRow {
Column() { ... }
Column(Modifier.matchParentHeight()) { ... }
}
fal
03/14/2021, 3:07 AM@Composable
fun HelloScreen(helloViewModel: HelloViewModel = viewModel()) {
val state: HelloState by helloViewModel.stateFlow.collectAsState(initialState)
Column {
Text(state.title)
SomeStatelessComponent(state.componentValue)
SomeOtherStatelessComponent(state.otherComponentValue)
...
}
}
The idea is that every composable used in HelloScreen are simply stateless composables. My worry is that this won't work out great if compose simply does a reference check (===) instead of an equals to check if it should recompose these stateless composables. If compose simply does a reference check, I see three ways out of this:
• Wrapping every object in this state class in mutableStateOf and adjust the reducer on the viewmodel side -> seems terrible, does this even work?
• Having a stateflow per state value -> seems clunky if your screen has a lot of state properties.
• Orrr find a way to selectively "subscribe" to the stateFlow properties, like
stateFlow.map { state -> state.componentValue }.distinctUntilChanged()
Is this okay? I'm up for other ideasprudhvi reddy
03/14/2021, 6:44 AMdavid.bilik
03/14/2021, 7:02 AMBox
? I have a code like this
@Preview("Positioning", widthDp = 300, heightDp = 300)
@Composable
fun Positioning() {
Box(
modifier = Modifier.size(300.dp)
.background(Color.Blue)
) {
Box(
modifier = Modifier.size(20.dp)
.background(Color.Red)
.absoluteOffset(20.dp, 20.dp)
)
}
}
and I’d like to position inner Box
but the result is not positioned. I know that it does not make sense probably to apply offset to Modifier
of inner Box
because I’d need to affect outer Box
somehow but I did not find a way how to position just a single child. I know I can achieve it easily with Canvas drawing but I’m just thinking what if I’d want to position some other Composable
. ThanksMel D.
03/14/2021, 9:51 AM@Composable
fun Subtitle(modifier: Modifier = Modifier, first: String, second: String) {
Row(modifier = modifier.padding(8.dp)) {
Text(
text = first,
color = colorResource(id = R.color.textLight),
fontSize = 16.sp
)
Text(
modifier = modifier.padding(start = 2.dp),
text = second,
color = colorResource(id = R.color.textBrand),
fontSize = 16.sp
)
}
}
Subtitle(first = args.summary, second = stringResource(R.string.general_more_info))
Nat Strangerweather
03/14/2021, 10:36 AMval convertedString = textState.value.text.splitToSequence(' ')
.filter { it.isNotBlank() }
.toList()
But I can't find how to differentiate the words to decorate them differently:
Text(textState.value.text, style = TextStyle(color = listOfColors.random()))
Mjahangiry75
03/14/2021, 11:56 AMMaterialTheme.Typography
through data class
property
and it's not possible because the MaterialTheme.Typography
is a Composable
so we can't use it in non-composable
. and now the question is how can I achieve that?
the code is in thread to take less space.Shakil Karim
03/14/2021, 12:28 PMcurtjrees
03/14/2021, 1:54 PMBoxWithConstraints
Feels I might need to use a Layout/SubcomposeLayout instead, but I’m not sure
I’m using the maxWidth and maxHeight to calculate sizes and positions for items on a “grid”oday
03/14/2021, 2:41 PMstaticAmbientOf
as wellgrandstaish
03/14/2021, 2:55 PMdev.chrisbanes.accompanist:accompanist-insets:0.6.2
to :compose:foundation:foundation-layout:build.gradle
. I’ve added it to both androidTestImplementation
for non-MPP builds, and to androidAndroidTest.dependencies
for MPP builds. After a Gradle sync, I still can’t reference accompanist insets in BoxTest.kt
. What am I missing?Shawn Tucker
03/14/2021, 3:57 PMColton Idle
03/14/2021, 4:41 PMTash
03/14/2021, 5:22 PMmutableStateListOf<Item>()
vs mutableStateOf<List<Item>>()
?
Trying to assess stability/performance in the case of a List
(size ~200) that will undergo random removals/insertions (that will be either displayed in a LazyColumn
or LazyGrid
)jaqxues
03/14/2021, 5:27 PMHalil Ozercan
03/14/2021, 6:46 PMcomposed
modifier that is used for custom stateful modifiers. My first question is what are the limitations around it? It's a compose function so it lets me call any other composable function that may or may not emit widgets. For example it makes sense to use remember
but it's a little strange calling Box
.mbonnin
03/14/2021, 8:30 PM@Composables
now? I tried using runCatching
and I got a weird error where the result was interpreted as a T
(and not a Result<T>
, see screenshot the debugger sees two types for the same lvalue ?!?). I ended up using try/catch and now it's all working but searching the backlog of this channel (https://kotlinlang.slack.com/archives/CJLTWPH7S/p1603737209131700), it looks like this might be dangerous?Colton Idle
03/15/2021, 12:48 AMColton Idle
03/15/2021, 12:48 AMIan Lake
03/15/2021, 1:31 AMColton Idle
03/15/2021, 1:34 AMIan Lake
03/15/2021, 1:43 AMShakil Karim
03/15/2021, 5:40 AMalorma
03/15/2021, 6:30 AMColton Idle
03/15/2021, 9:17 AMjossiwolf
03/15/2021, 9:56 AMColton Idle
03/15/2021, 10:59 AMDialogs
in my app and just replacing it with bottom sheet dialogs (if there was an easy way to go about it)
`BottomSheetDialogFragment`s are a more modern version of Dialogs. They have a nicer-looking entrance animation and since they are pinned to the bottom they may feel easier to use on larger devices.
jossiwolf
03/15/2021, 11:22 AMShakil Karim
03/15/2021, 11:25 AMColton Idle
03/15/2021, 11:36 AMval bottomSheetDialog = BottomSheetDialog(this)
and it doesn't affect my current view hierarchy since it opens in a Window so I'll be using this for now. I hope that compose ends up having a solution for it so that i can ditch xml land completely.jossiwolf
03/15/2021, 11:56 AM