Zoltan Demant
07/19/2022, 11:46 AMcolor = contentColor.copy(alpha = 1f)
and then use CompositionLocalProvider(LocalContentAlpha provides contentColor.alpha)
to provide the actual alpha just mere lines later?juliocbcotta
07/19/2022, 12:37 PMmattinger
07/19/2022, 1:20 PMKwok Wong
07/19/2022, 1:28 PMLazyColumn
and have been managed to follow the example here to implement the drag-and-drop operation for the list items.
In a compose UI test, we want to test the drag-and-drop behaviours using code below:
onNodeWithContentDescription("itemDesription", substring = true)
.onChild()
.performTouchInput {
down(bottomCenter)
moveTo(percentOffset(0.5f, -0.7f), delayMillis = 1000L)
up()
}
What the code would do:
1. Select an item from list (long-click)
2. Move the item one position up
However, the operation always fails with the step moveTo
So, we are wondering whether we are using the moveTo API properly.
Any suggestions?
Regards,Can Korkmaz
07/19/2022, 1:58 PMVivek Modi
07/19/2022, 4:34 PMviewModelScope.launch
so when I call in my compose function, should I use any thing else? I am reading Side-effects using LunchEffect and DispoableEffect. Is this neccessary in my composable function? If yes can someone guide me, bcoz I unable to understand this concept. Thanks
class MainActivityViewModel(private val resultRepository: ResultRepository) : ViewModel() {
init {
getSportResult()
}
fun getSportResult() {
viewModelScope.launch {
val response = resultRepository.getSportResult()
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SetupView(viewModel :MainActivityViewModel = koinViewModel()) {
Scaffold(topBar = {
TopAppBar(
title = { Text(text = stringResource(id = R.string.app_name)) },
)
}, content = { padding ->
Column(
modifier = Modifier
.fillMaxSize()
) {
Button(onClick = { /*TODO*/ }) {
Text(text = stringResource(id = R.string.get_result))
}
}
})
}
Thanks guys..Nat Strangerweather
07/19/2022, 5:26 PMDropDownMenu
but both Material 2 and Material 3 are leaking in Compose. Do you just put up with the memory leak or is there a workaround?raghunandan
07/20/2022, 3:40 AMjasu
07/20/2022, 4:11 AMKonyaco
07/20/2022, 6:05 AMKonyaco
07/20/2022, 6:17 AMste
07/20/2022, 7:36 AMCanvas
? Given the dark blue rect and the black text, how should I blend them? I tried every single BlendMode
, but none of them gave the desired result. I need to whiten the part of the text that overlaps the rect (or, alternatively, clear the part or the rect the text would overlap)Slackbot
07/20/2022, 10:51 AMLukasz Kalnik
07/20/2022, 12:39 PMLazyVerticalGrid
with items containing some Coil `AsyncImage`s and the scroll is stuttering very hard. Is this a known problem?Vivek Modi
07/20/2022, 2:34 PMA
screen. Inside that I have Button
. When I click I am calling api and getting data. In this whole process I am passing UI state event i.e. IsLoading
, OnSuccess
and OnError
. So when I press the Button
the IsLoading
is trigger and when I get data without any problem, I trigger`OnSuccess` with data. So question is
1. When IsLoading
happening I want to called A
screen -> B
Screen.
Note:- we are standing on B
screen
2. When I get OnSuccess
with data, A
screen pass to B
Screen again.
Is it possible to do that through navigation compose or something else?Mohan manu
07/20/2022, 4:58 PMVikas Singh
07/20/2022, 6:26 PMandrew
07/20/2022, 6:34 PMJasmin Fajkic
07/20/2022, 8:12 PMSean Proctor
07/20/2022, 9:01 PMandroidx.compose.ui.input.key.Key
?Colton Idle
07/20/2022, 10:28 PM1.7.10
Colton Idle
07/20/2022, 10:52 PMK Merle
07/21/2022, 8:26 AMsystem
theme?Kulwinder Singh
07/21/2022, 9:31 AMloloof64
07/21/2022, 9:55 AMSurface
with solid background color, and a Button
.
2. When the user clicks on the button, the expected behaviour is that the square changes its color.
3. In this experiment, things are a bit more complicated : I'm using a ColorSquareState
class, with a method chooseNextColor
, and I'm storing a `mutableState`on an instance of this class.
But when the `chooseNextColor`is called, it does not force recomposition. Why ? Is there a simple workaround keeping the use of `ColorSquareState`as long as method chooseNextColor
?Jasmin Fajkic
07/21/2022, 12:00 PMLisandro Di Meo
07/21/2022, 2:27 PMval isLoginError by loginViewModel.loginError.observeAsState()
val context = LocalContext.current
LaunchedEffect(isLoginError){
when (isLoginError) {
true -> {
Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show()
}
false -> navHostController.navigate(Paths.HOME_PATH)
null -> { // blah }
}
}
LoginScreen(loginViewModel)
Joseph Hawkes-Cates
07/21/2022, 4:13 PMVivek Modi
07/21/2022, 4:42 PMprivate const val NEAREST_RESULT_JSON = "nearestResultJson"
@Composable
internal fun NavigationGraph() {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = ScreenRoute.Home.route) {
composable(ScreenRoute.Home.route) {
SetupMainActivityView { nearestResult ->
val nearestResultJson = Uri.encode(Gson().toJson(nearestResult))
navController.navigate(ScreenRoute.Result.route + "/{$nearestResultJson}")
}
}
composable(
ScreenRoute.Result.route + "/{$NEAREST_RESULT_JSON}",
arguments = listOf(
navArgument(NEAREST_RESULT_JSON) { type = NearestResultParamType() }
)
) { backStackEntry ->
ResultScreen(backStackEntry.arguments?.getParcelableArrayList(NEAREST_RESULT_JSON))
}
}
}
dimsuz
07/21/2022, 5:16 PMFlow<State>
which then gets collected and rendered.
When TextField
emits a value change request — this too is considered a source of change and gets mapped/processed and then ends up in this state flow with actual text
value calculated → rendered. Example usecase: "user inputs foo
, ViewModel receives this request, merges it with some flags and decides to send foo-bar
back to render in the text field".
The thing is: if calculating "foo-bar" value consumes some time, then TextField state gets completely messed up, because it emits faster than it renders.
In the attached video I simply press and hold the 1
key while in code I add some delay before sending it back to the TextField
. See 🧵 for a minimum sample code.
Is this something that can be done correctly?