Sergey Y.
09/02/2020, 9:57 PMPressed
, enabled
, disabled
, focused
, hovered
, etc.Sean McQuillan [G]
09/02/2020, 10:58 PMZach Klippenstein (he/him) [MOD]
09/02/2020, 11:00 PMSergey Y.
09/02/2020, 11:00 PMSean McQuillan [G]
09/02/2020, 11:01 PM@Composable
fun SelectorBackground(currentState: /*...*/, content: @Composable () -> Unit) {
... logic to select background ...
}
Sergey Y.
09/02/2020, 11:02 PM<selector/>
api going to be reinvented in compose style?Sean McQuillan [G]
09/02/2020, 11:02 PMSean McQuillan [G]
09/02/2020, 11:03 PMSergey Y.
09/02/2020, 11:06 PMSean McQuillan [G]
09/02/2020, 11:07 PMSean McQuillan [G]
09/02/2020, 11:07 PMSean McQuillan [G]
09/02/2020, 11:08 PMSergey Y.
09/02/2020, 11:18 PMandroid.graphics.Drawable
still suitable or Compose has its own types alike to the Drawable
?Sean McQuillan [G]
09/02/2020, 11:20 PMInteractionState
that's designed for handling interactions like this
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/InteractionState.kt?q=androidx%20compose%20InteractionStateSean McQuillan [G]
09/02/2020, 11:20 PMSean McQuillan [G]
09/02/2020, 11:20 PMSergey Y.
09/02/2020, 11:21 PMSean McQuillan [G]
09/02/2020, 11:23 PMButton
is probably the simplest way to get custom behavior (reading a bunch of code to try to answer this question 🙂 )Sean McQuillan [G]
09/02/2020, 11:23 PMSean McQuillan [G]
09/02/2020, 11:24 PMSergey Y.
09/02/2020, 11:26 PMSergey Y.
09/02/2020, 11:26 PMSean McQuillan [G]
09/02/2020, 11:26 PMSean McQuillan [G]
09/02/2020, 11:27 PMSean McQuillan [G]
09/02/2020, 11:28 PMSergey Y.
09/02/2020, 11:28 PMSean McQuillan [G]
09/02/2020, 11:30 PMSean McQuillan [G]
09/02/2020, 11:31 PMSean McQuillan [G]
09/02/2020, 11:32 PMSean McQuillan [G]
09/02/2020, 11:32 PMSean McQuillan [G]
09/02/2020, 11:33 PMSergey Y.
09/02/2020, 11:34 PMSean McQuillan [G]
09/02/2020, 11:35 PMLouis Pullen-Freilich [G]
09/02/2020, 11:37 PMInteractionState
parameter - which allows you to hoist and read this state to customize how the Button appears.
For example, to customize the button based on whether it is pressed would look something like:
val interactionState = remember { InteractionState() }
Button(
interactionState = interactionState,
backgroundColor = if (Interaction.Presesd in interactionState) Color.Red else Color.Blue
) {...}
Unfortunately this hasn't landed yet, so it isn't really easy to do this right nowLouis Pullen-Freilich [G]
09/02/2020, 11:38 PM