Jrichards1408
11/17/2020, 5:46 PMLazyColumnFor
just creates a normal listview of items where each item takes up a whole row, what i want is to create basically a gridview that can be scrolled verticallyVivek Sharma
11/17/2020, 6:13 PMRodri Represa
11/17/2020, 6:15 PMvar image by mutableStateOf
value every time I get the viewmodel (val viewModel = getViewModel<MainViewModel>()
) in a composable function?
I'm using koin to inject it.Gabriel
11/17/2020, 7:56 PMColumn(modifier = Modifier.fillMaxSize()
Colton Idle
11/17/2020, 9:39 PMJordi Saumell
11/17/2020, 10:46 PMnavBackStackEntry.lifecycle.addObserver(object: LifecycleEventObserver {
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
if (event == Lifecycle.Event.ON_DESTROY) {
koinScope.close()
}
}
})
The problem is that this is run on every recomposition, so I end up having a lot of observers. It works (the scope will be closed when it needs to be) but it is not ideal having several useless observers being called.
What can I do to only add an observer the first time?caelum19
11/17/2020, 11:54 PMProcess: com.caelumforder.blah, PID: 7462
java.lang.ArrayIndexOutOfBoundsException: length=10280; index=-1219
at androidx.compose.runtime.SlotTableKt.isNode(SlotTable.kt:2416)
at androidx.compose.runtime.SlotTableKt.access$isNode(Unknown Source:0)
at androidx.compose.runtime.SlotReader.isNode(SlotTable.kt:547)
at androidx.compose.runtime.Composer.nodeIndexOf(Composer.kt:1796)
at androidx.compose.runtime.Composer.recomposeToGroupEnd(Composer.kt:1686)
at androidx.compose.runtime.Composer.skipToGroupEnd(Composer.kt:1970)
at androidx.compose.ui.layout.LayoutKt$WithConstraints$1$1$placeables$1.invoke(Layout.kt:531)
...
Jrichards1408
11/18/2020, 11:54 AMText(
text = "Occupation: ",
style = TextStyle(fontWeight = FontWeight.Black),
Modifier.absolutePadding(4.dp, 8.dp, 4.dp, 8.dp)
)
Error below:
one of the following functions can be called with the arguments supplied: public fun Text(text: AnnotatedString, modifier: Modifier = ..., color: Color = ..., fontSize: TextUnit = ..., fontStyle: FontStyle? = ..., fontWeight: FontWeight? = ..., fontFamily: FontFamily? = ..., letterSpacing: TextUnit = ..., textDecoration: TextDecoration? = ..., textAlign: TextAlign? = ..., lineHeight: TextUnit = ..., overflow: TextOverflow = ..., softWrap: Boolean = ..., maxLines: Int = ..., inlineContent: Map<String, InlineTextContent> = ..., onTextLayout: (TextLayoutResult) -> Unit = ..., style: TextStyle = ...): Unit defined in androidx.compose.material
public fun Text(text: String, modifier: Modifier = ..., color: Color = ..., fontSize: TextUnit = ..., fontStyle: FontStyle? = ..., fontWeight: FontWeight? = ..., fontFamily: FontFamily? = ..., letterSpacing: TextUnit = ..., textDecoration: TextDecoration? = ..., textAlign: TextAlign? = ..., lineHeight: TextUnit = ..., overflow: TextOverflow = ..., softWrap: Boolean = ..., maxLines: Int = ..., onTextLayout: (TextLayoutResult) -> Unit = ..., style: TextStyle = ...): Unit defined in androidx.compose.material
``
Jrichards1408
11/18/2020, 12:21 PMAntoine Lamy
11/18/2020, 1:44 PMChristoph
11/18/2020, 2:26 PMTopAppBar
) conditionally.
I want to set a navigationIcon
depending on a condition. but doing
navigationIcon = {
if (showBackArrow) {
IconButton(onClick = onBackClick) {
Icon(Icons.Default.ArrowBack)
}
}
}
this results in a "empty" composable set to the app bar and therefore the title is inset.
what's the best approach here?Dominaezzz
11/18/2020, 11:30 PMSnapshotStateList<T>
and MutableState<List<T>>
? In particular, is there any difference in the granularity of how mutations trigger recomposition? (Like in a LazyColumnFor
)Cyril Find
11/18/2020, 11:48 PMLuis Daivid
11/19/2020, 6:23 AMLuis Daivid
11/19/2020, 6:24 AM@Composable
fun ImageItem(image: ImageModel, onClickImage: (ImageModel) -> Unit) {
Surface(modifier = Modifier.clickable(onClick = { onClickImage(image) })) {
Column {
Box(
) {
GlideImage(
imageModel = image.imagePath.toUri(),
requestOptions = RequestOptions()
.override(500, 500)
.diskCacheStrategy(DiskCacheStrategy.ALL)
)
}
Text(text = image.name)
}
}
}
Kshitij Patil
11/19/2020, 6:52 AMmaxLines=1
for a TextField
in compose 'alpha06' ?allan.conda
11/19/2020, 7:24 AMRosen Dimov
11/19/2020, 11:12 AMText
with vector image as a background. With the XML approach I just had to set padding of TextView
and its background (there I could use gradient drawable as well).
But now it seems a bit more work is involved. I tried creating a custom layout with Layout
(having Text
and Image
as its children, positioned on top of each other). Then I measured the text and set its measures to the image behind it + some padding for the bubble. Looking at the preview, the measures/placement are correct. But the image doesn't stretch horizontally (vertical stretch is ok, on the screenshot you can see the blue border - that's the image composable's rectangle, but the image inside it is not stretched). The image I'm using is SVG converted to vector drawable. I tried setting ContentScale.FillWidth
(it gets stretched, but it's distorted) and Modifier.fillMaxWidth()
(did nothing) on the image. The Layout
itself has fillMaxWidth
set. Any ideas how to fix it, or maybe there's a better approach?ciscorucinski
11/19/2020, 11:22 AMpadding(...)
. This works with padding towards the end.
Image(
modifier = Modifier
.width(70.dp).height(70.dp)
.border(
border = BorderStroke(2.dp, color = Color.White),
shape = CircleShape)
.clip(shape = CircleShape)
.padding(8.dp), // * * HERE near bottom - works * * //
asset = Icons.Filled.Person,
colorFilter = ColorFilter.tint(color = Color.White)
)
However, move it towards the top, and no padding is added at all.
Image(
modifier = Modifier
.width(70.dp).height(70.dp)
.padding(8.dp) // * * HERE near top - fails * * //
.border(
border = BorderStroke(2.dp, color = Color.White),
shape = CircleShape)
.clip(shape = CircleShape),
asset = Icons.Filled.Person,
colorFilter = ColorFilter.tint(color = Color.White)
)
Ashwani Singh
11/19/2020, 11:46 AMScaffold(
bottomBar = {
// Bottom bar code
},
)
But bottom Bar render in bottom, with any offset from bottom or transparent margin.
Is there any way/sample?sindrenm
11/19/2020, 12:39 PMDieter Holz
11/19/2020, 12:55 PMBryan Herbst
11/19/2020, 4:55 PMstaticAmbientOf()
/ ambientOf()
to provide an @Composable
without a factory layer like AmbientIndication
uses?
Specifically my use case is providing my own version of AmbientColors
, but all of my theme’s colors come from resources for interop with our existing View-backed content. The colors are defined like so:
object ColorPalette {
@Composable val red: Color get() = colorResource(R.color.red)
}
Since those colors are @Composable
, I can’t just do something like
val primaryColorAmbient = staticAmbientOf { ColorPalette.red }
Kyle Taylor
11/19/2020, 6:32 PMScrollableColumn(
modifier = Modifier.padding(all = PAGE_PADDING.dp)
) {
AtAGlanceCard(atAGlanceItems)
Spacer(modifier = Modifier.height(SPACE_BETWEEN_SIBLINGS.dp))
QuickLaunchCard(quickTools)
Spacer(modifier = Modifier.height(SPACE_BETWEEN_SIBLINGS.dp))
AccountBalanceCard(balances = accountBalances)
Spacer(modifier = Modifier.height(SPACE_BETWEEN_SIBLINGS.dp))
CurrentCoursesCard(courses)
}
I'm on 1.0.0-alpha07John O'Reilly
11/19/2020, 6:45 PMAmbientNavController
for some reason....am using alpha02 of navigation-compose
. Should this be available?Slackbot
11/19/2020, 8:36 PMJeisson Sáchica
11/19/2020, 9:19 PMVincent tiensi
11/20/2020, 7:33 AMModalDrawerLayout
supports mainly left to right (Unless RTL layout direction), but that is only for one drawer. If I want to have two drawers (Like Discord) then should I try to wrangle my own using ModalDrawerLayout as a base?ziv kesten
11/20/2020, 9:46 AMUnsupportedOperationException: Parcelables don't support default values.
My code for passing the data is:
composable("route".plus("/argument_key"),
arguments = listOf(navArgument("argument_key) {
type = NavType.ParcelableType(AnimationIdHolder::class.java)
})
)
And my code for extracting it is:
backStackEntry.arguments?.getParcelable<AnimationIdHolder>("argument_key")
Where AnimationIdHolder
is:
@Parcelize
data class AnimationIdHolder(
val animationId: Int
): Parcelable
@Ian Lake Any idea on what is the default value required here and why it is not supported?
Further more, maybe someone can point me in the direction of how i can pass parcelable types using the safeArgs in jetpack compose navigation?allan.conda
11/20/2020, 11:01 AM