Paul Woitaschek
08/03/2021, 4:56 AMJoey
08/03/2021, 7:48 AMsingleLine = true
and maxLines = 1
, but in the emulator I can still press keys like ENTER to create newlines, can I somehow prevent that? Or should I just filter stuff like \n
in the valuechange?Benyam Seifu
08/03/2021, 8:20 AMAlbert Francis
08/03/2021, 8:59 AMmaxLines = 1
, and overflow = TextOverflow.Ellipsis
so it can be like. "Lorem ipsum ..." ⬆️
but if i change the overflow
to Ellipsis
the text takes the whole row and it becomes ->
"Lorem ipsum ..." without the icon
i tried inlineContent
also but that simple thing i couldn't achive anyone has idea?lhwdev
08/03/2021, 9:22 AMif(someState) Content()
, the internal states may fly away. (such as value remembered by remember {}
)
Generally speaking, can I prevent emitting the nodes? (Maybe linking to another composition with wrapper Applier which conditionally delegates to parent applier..? - this would overkill)Vojtech Hrdina
08/03/2021, 9:35 AMNacho Ruiz Martin
08/03/2021, 9:50 AMinclusive = true
I’m getting the following exception:
androidx.navigation.NavGraph cannot be cast to androidx.navigation.compose.ComposeNavigator$Destination
The use case is a user that signs out, so I want to clear the whole backstack and then navigate to the login screen.loloof64
08/03/2021, 12:12 PMViewModel
or remeberSaveable
? Which is best practice ?Akram Bensalem
08/03/2021, 12:55 PMloloof64
08/03/2021, 1:53 PMViewModel
for the same Composable
? This way I will have more granularity.Colton Idle
08/03/2021, 2:18 PMnglauber
08/03/2021, 3:21 PMAlertDialog
pressing back key or clicking outside?
I saw the properties
parameter receives an DialogProperties
object which has these properties (dismissOnBackPress
and dismissOnClickOutside
) set to true by default. But looks like it’s not working 😕Jason Inbody
08/03/2021, 5:04 PMrobnik
08/03/2021, 5:10 PMMarko Novakovic
08/03/2021, 5:37 PM2.4.0-alpha05
and am navigating from 1st to 2nd screen like this:
navController.navigate("$route/${id.value}")
and routes are defined like so:
@JvmInline
value class Routes(val route: String) {
companion object {
val Home = Routes("home")
val ItemDetails = Routes("item_details/{id}")
val ItemGallery = Routes("item_gallery")
}
}
I access that id
parameter inside ViewModel
savedStateHandle.get<String>(ARG_ITEM_ID) // ARG_ITEM_ID = "id", same as route arg
when I go from 1st screen, list of items, to 2nd, details, it works fine BUT when I go from details to gallery and press system back button ARG_ITEM_ID
is null
. it works fine with navigation version 2.4.0-alpha04
Tiago Taraczuk
08/03/2021, 7:09 PMSelectionContainer
?Kurt Renzo Acosta
08/03/2021, 8:02 PMFlow<T>
then I just observe it and wait for the initial value before I update the UI. Now, I’m trying to consume it and it always needs an initial value. I tried to do .collectAsState(initial = null)
but then it makes it nullable and I have to perform null checking on every flow. Is there a better practice around this? I’d like to have Flow<T>
rather than Flow<T?>
. Thanks in advance!Colton Idle
08/03/2021, 9:39 PM@Composable
fun SignUpScreen(
viewModel: SignUpViewModel = hiltViewModel()
) {
val pagerState = rememberPagerState(5)
In order to have a single source of truth, should I just move val pagerState = rememberPagerState(5)
into my ViewModel?ursus
08/04/2021, 12:50 AMAndroidView
and make all the fragment lifecycle work?
(Since they don't provide a View)Colton Idle
08/04/2021, 1:12 AMBerkeli Alashov
08/04/2021, 3:04 AMBackHandler
that consumes back calls before the inner most composable?
My use case is I have a BottomSheetScaffold
at the root of my app (Theme>BottomSheet>Home>NavHost) and I want to close the sheet on back clicks. But BackHandler defined in BottomSheet doesn't get invoked until all back handlers deeper in the tree are used (in my case, NavHost consumes before BottomSheet, until the first destination is reached / nav stack cleared).eygraber
08/04/2021, 3:17 AM@Composable
fun Parent(state: State, eventEmitter: EventEmitter<Event>)
eventEmitter
will always be the same instance for a given composition, and uses an identity based equals
and hashCode
. Is there anything else that I need to do?
Note that I can't use CompositionLocal
here because a lot of the events I need to emit occur in non `@Composable`lambdas (e.g. onClick
).Colton Idle
08/04/2021, 4:21 AMBox() {
Image(
modifier = Modifier.height(140.dp).offset(x = (-200).dp),
painter = painterResource(id = com.myapp.myresources.R.drawable.catdog),
contentDescription = null)
}
Ayfri
08/04/2021, 6:23 AMdp
?iamthevoid
08/04/2021, 6:49 AMMohamed Ibrahim
08/04/2021, 7:21 AMNapa Ram
08/04/2021, 9:31 AMjames
08/04/2021, 10:52 AMView
to be passed into it when using it to use as an anchor.. is there any way to do that? or is this type of interop impossible? it's important to note, the 3rd party library doesn't actually need to do anything with the View
besides use it as an anchor point.. so if there was a way I could programmatically generate a view that could work I guess?natario1
08/04/2021, 10:56 AMandroid:configChanges="(everything)"
as suggested by compose team, so compose handles UI rotations. But I'm seeing issues with `SurfaceView`s in the compose hierarchy. Would love to have some insight about what's happening under the hoodGeorge Kylafas
08/04/2021, 12:19 PMText()
node has text with a certain style, e.g. bold? Is there such a matcher/assertion available?
The testing cheat sheet doesn't seem to include something similar.George Kylafas
08/04/2021, 12:19 PMText()
node has text with a certain style, e.g. bold? Is there such a matcher/assertion available?
The testing cheat sheet doesn't seem to include something similar.Zach Klippenstein (he/him) [MOD]
08/04/2021, 4:46 PMSemanticsProperties.Text
property which gives you a list of `AnnotatedString`s, and check those strings for the styles you expect.
You can look at the implementation of the existing assertions, eg assertTextContains
, as a starting point.George Kylafas
08/06/2021, 12:58 PMSemanticsProperties.Text
's AnnotatedString
s have no spanStyles nor paragraphStyles (both are empty lists).
However, the node also contained a SemanticsActions.GetTextLayoutResult
property, which is a lambda whose enclosing class is a TextController
which contains a TextState
which contains a TextDelegate
which contains a TextStyle
which contains the desired FontWeight
. Since half of those classes are internal, I had to do a fair amount of reflection to come up with this matcher:
@OptIn(InternalFoundationTextApi::class)
fun hasFontWeight(
weight: FontWeight,
): SemanticsMatcher {
val propertyName = SemanticsActions.GetTextLayoutResult
return SemanticsMatcher(
"$propertyName contains $weight text"
) {
val actualWeight = it.config.getOrNull(propertyName)
?.action
?.javaPrivateField("this$0")
?.javaPrivateField("state")
?.javaPrivateField("textDelegate")
?.run { this as TextDelegate }
?.style
?.fontWeight
actualWeight == weight
}
}
where
fun Any.javaPrivateField(fieldName: String): Any? =
this.javaClass
.getDeclaredField(fieldName)
.also { it.isAccessible = true }
.get(this)
I am certain this is NOT the proper way to do this, but until the framework supports this officially I guess it will have to do.Zach Klippenstein (he/him) [MOD]
08/06/2021, 1:21 PMGeorge Kylafas
08/06/2021, 8:58 PM