https://kotlinlang.org logo
Title
b

Brian Donovan

12/09/2021, 6:13 PM
Hey all, why is this coming up as a val?
j

jim

12/09/2021, 6:14 PM
IIRC in Kotlin, function parameters are always immutable references
👍 4
b

Brian Donovan

12/09/2021, 6:14 PM
ty
I am trying to show a circular spinner once I click on the Log In button but nothing is happening
it’s always in the if block no matter how many times I click the Log in button
j

jim

12/09/2021, 6:17 PM
What happens if the login fails due to a connection issue?
Without looking closely at your code, I get the sense you are creating some source of truth issues.
I'd suggest you consider re-reading the sections on "unidirectional data flow" and "state hoisting" and ensure you are following those principles
b

Brian Donovan

12/09/2021, 6:19 PM
Right now there is no connection, I am just trying to make the UI work. Switching the button to a spinner onClick
I was going to worry about that later
I just don’t know why this condition isn’t working
k

Kirill Grouchnikov

12/09/2021, 6:23 PM
The Compose way is for the "caller" of
LoginButton
to provide a lambda that is called in your
onClick
. It is the caller's responsibility to update the source of truth for the state, not this composable.
This is a "flattened" example of this - but in the real app the state would be managed outside of this composable function, and this function would get the current state and a lambda to call in
onCheckedChange
(where the lambda updates the state and that causes recomposition of your composable)
b

Brian Donovan

12/09/2021, 7:51 PM
ty, I will look this up
a

Abhinav Suthar

12/12/2021, 3:09 PM
Please confirm if
isDisplayed
is a state variable