nuhkoca
04/26/2022, 10:04 PMoffset
and index
at the right time in no way. Can you tell me how can I show my sticky header once the respective item almost goes out of view? Screen recording in the threadandrew
04/26/2022, 11:44 PMTash
04/27/2022, 12:52 AMandroidx.compose
artifacts, do we also need to update androidx.activity:activity-compose
?
(i.e. looking to update compose to 1.2.0-alpha08
)Colton Idle
04/27/2022, 1:00 AMval options: List<String> = (1..21).map { it.toString() }
DropDownPicker(
options,
should I wrap the
(1..21).map { it.toString() }
in a remember? I'm tempted to file a lint request so that android studio just flags all of these creations as most likely should be wrapped in a remember block.ste
04/27/2022, 10:58 AMEric Martori
04/27/2022, 11:27 AMComposeView
in the XML works for most cases, but now we have to show a pop window and an alert on user interaction.
We have tried creating the PopupWindow
and AlertDialog
programmatically and setting the content view as a ComposeView
with the desired content but we get errors like: java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from android.widget.PopupWindow$PopupDecorView
So we are thinking that maybe there is a way to launch the alert and popup directly from compose, but don't know how to launch it from inside a custom view without replacing the already working content.Chachako
04/27/2022, 1:09 PMfun Font(resId: Int, ...)
is lazily loaded, the fonts created via fun Font(assetManager: AssetManager, ...)
and fun Font(file: File, ...)
are loaded immediately, so what should I do? Is there anything that might be called LazyAssetsFont?Jan
04/27/2022, 2:17 PMprivate val products: SnapshotStateMap<String, List<ShoppingItem>> = mutableStateMapOf()
fun add(shop: String, product: ShoppingItem) {
val list = products.getOrDefault(shop, mutableListOf()).toMutableList()
list.add(product)
products[shop] = list
}
fun replace(shop: String, product: ShoppingItem) {
val list = products.getOrDefault(shop, mutableListOf()).toMutableList()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.replaceAll { if (it.id == product.id) product else it }
}
products[shop] = list
}
I mean adding works but the replace method doesn't wanna work and I don't think thats the right wayChris Fillmore
04/27/2022, 4:02 PMVahalaru
04/27/2022, 4:48 PMJan
04/27/2022, 5:52 PMLaunchedEffect(Unit) {
while(true) {
delay(7000)
try {
productMap.fill(ShoppingRepository.getProducts())
} catch(e: Exception) {
productMap.fill(cache)
e.printStackTrace()
}
}
}
Does this get stopped when the process is not in the foreground or something?agrosner
04/27/2022, 7:08 PMSaiedmomen
04/27/2022, 7:35 PMSideEffect
not having key args?
In the example in the official docs, you can see that there easily can be extra calls to the analytics.
The LaunchedEffect
is great but the suspend block is sometimes not needed and wasteful.
@Composable
fun rememberAnalytics(user: User): FirebaseAnalytics {
val analytics: FirebaseAnalytics = remember {
/* ... */
}
// On every successful composition, update FirebaseAnalytics with
// the userType from the current User, ensuring that future analytics
// events have this metadata attached
SideEffect {
analytics.setUserProperty("userType", user.userType)
}
return analytics
}
Andrew Hughes
04/27/2022, 10:04 PMTextField
and OutlinedTextField
both appear to animate changes (such as color) when transitioning to and from the isError
state. When including an error message below a TextField
, there doesn't appear to be a way to synchronize the appearance of the error message with the internal animations of the TextField
. For example, take the following sample from the official M3 compose samples:
@Sampled
@Composable
fun TextFieldWithErrorState() {
val errorMessage = "Email format is invalid"
var text by rememberSaveable { mutableStateOf("") }
var isError by rememberSaveable { mutableStateOf(false) }
fun validate(text: String) {
isError = !text.contains('@')
}
Column {
TextField(
value = text,
onValueChange = {
text = it
isError = false
},
singleLine = true,
label = { Text(if (isError) "Email*" else "Email") },
isError = isError,
keyboardActions = KeyboardActions { validate(text) },
modifier = Modifier.semantics {
// Provide localized description of the error
if (isError) error(errorMessage)
}
)
// Supporting text for error message.
Text(
text = errorMessage,
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(start = 16.dp, top = 4.dp).alpha(if (isError) 1f else 0f)
)
}
}
I see that internally the animations are using a 150ms tween animation, but there's no way to reference this directly since it's marked as internal
. Is there a recommended way to synchronize these components?natario1
04/27/2022, 10:48 PMDavid Nadejdin
04/28/2022, 7:50 AMSatyam G
04/28/2022, 8:51 AMildar.i [Android]
04/28/2022, 10:46 AMPhilipp Kleber
04/28/2022, 1:08 PMNavController
and both of these routes have a DisposableEffect
. Is the last effect of the route I stop at guaranteed to have been executed after the effect of the other route (the one which I did not stop at)?Francescos
04/28/2022, 1:51 PMmyanmarking
04/28/2022, 2:42 PMDaniel Okanin
04/28/2022, 4:14 PMnuhkoca
04/28/2022, 5:11 PMdepth
animation to my component, similar to DepthPageTransformer
in ViewPager
Ink
04/28/2022, 10:04 PMHirozontalPager()
It always displays the same photo.
product.photos
is a List<String> with different links to photos.Slackbot
04/28/2022, 11:45 PMJérôme Gully
04/29/2022, 6:55 AMcomposer.compositionData.asTree()
, which is too slow for my needs (500ms for a simple view).
There is also Semantics, used by Talkback, it seems lighter, but is not used for every composable/Group, especially for custom views.
I talked a bit about my problem with a person from Google at Android Makers this monday (sorry I don’t remember your name, maybe @Clara Bayarri) and I will be happy to continue the discussion here.
Is there an efficient solution that can be found by using SlotTables/Group directly?
I will buy the book Jetpack Compose Internals to go further but any help to move faster will be welcome, thank you 🤓.Mohan manu
04/29/2022, 9:12 AMArjan van Wieringen
04/29/2022, 9:52 AMste
04/29/2022, 11:10 AMiamthevoid
04/29/2022, 12:08 PMiamthevoid
04/29/2022, 12:08 PMonTextLayout
Tolriq
04/29/2022, 12:09 PMiamthevoid
04/29/2022, 12:10 PMTolriq
04/29/2022, 12:12 PMiamthevoid
04/29/2022, 12:17 PMTolriq
04/29/2022, 12:55 PM