Status Update
Comments
ap...@google.com <ap...@google.com> #3
Thanks for the report!
ap...@google.com <ap...@google.com> #4
The release notes documentation has been edited to clarify this change in behavior for line height.
To support non-standard text sizes, we encourage users to follow the Material design system and use a different style = LocalTextStyle.current.copy(lineHeight = TextUnit.Unspecified)
, or create a custom Typography
entirely.
ap...@google.com <ap...@google.com> #5
ki...@google.com <ki...@google.com> #6
In my case, I have multiple font sizes in the same Text
(using SpanStyle
in AnnotatedString
). There are legitimate reasons for this. For example, when combining Chinese and English (phonetic) together (for language-learning purposes).
ma...@google.com <ma...@google.com> #7
Hover is planned, we're not sure when we will have it though. It's blocked on the mouse events handling which we don't have yet, but ?I remember Shep was it touch with jetbrains to upstream their mouse work in compose at some point.
Until that point (or until we have other usecases), we commented out Hovered interaction, let me know if you need it now
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit 4ed6a9c01328ed0c177f3661b58f1b3fc29faec3
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Fri Feb 05 14:40:02 2021
Simplifies Indication APIs
Previously IndicationInstance was responsible for both writing state / launching animations and then reading state to draw indication. Typically we want to model this as a one-way pipeline, so IndicationInstance has now been simplified to be only responsible for drawing indication.
Indication#createInstance() has been changed to rememberUpdatedInstance(InteractionState) to convey these responsibilities more clearly - Indication is responsible for observing InteractionState and creating an IndicationInstance which can draw visual effects for the current state.
This CL leaves the current Ripple implementation as is; it will be refactored in a future CL.
Bug:
Test: updateApi
Test: existing tests
Relnote: "Changed Indication#createIndication() to Indication#rememberUpdatedIndication(InteractionState) and removes InteractionState parameter from IndicationInstance#drawIndication(). IndicationInstance should only be responsible for drawing visual effects, and not launching animations / writing state in response to InteractionState changes. These animations and state writes should happen within `rememberUpdatedIndication()` instead. The `indication` parameter in `Modifier.indication` was also changed to be a required parameter."
Change-Id: Ic1764c0417b25cd0a0dbb96ed3e1b0974618c4ca
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
M compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt
ap...@google.com <ap...@google.com> #9
Branch: androidx-main
commit 2ae4491c96160cde4b70863202542499c68da4b7
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Sat Feb 06 21:48:44 2021
InteractionState -> [Mutable]InteractionSource rework
This CL replaces InteractionState with [Mutable]InteractionSource - interfaces responsible for emitting / observing Interaction events. InteractionSource exposes interactions: Flow<Interaction>, which allows consumers to observe the ordered stream of Interactions and change how components appear accordingly.
This resolves a few issues with the existing InteractionState implementation:
- No handling for multiple sources of the same Interaction
For example, a compound component with two `clickable`s - if one `clickable` is pressed, then the other, then the first `clickable` is released, this would appear as though the entire InteractionState was not pressed.
- Lossy compression of events into state
InteractionState turns a stream events into a snapshot state at a given point in time. Complex components / indications such as Ripple care about the ordering of events, and trying to reconstruct ordering from a snapshot state is a bit messy and can lose information.
- Batched state writes
State<> is not a great fit for representing events as the name suggests - one of the reasons for this is that state writes are batched, so multiple changes (such as multiple fast presses) will be batched into one write. This means that we might skip showing ripples for presses if events happen too closely together.
- Lack of detailed information for events
For simple components, just knowing if the component is pressed or not can be enough to change how it appears, but for complicated components it can be important to know if a press was stopped / cancelled - this sort of information did not exist in InteractionState. Additionally metadata such as press position can be important, but there was no scalable way to support this. Now Interactions can just be unique instances with metadata, so Pressed() can contain a press position just as a property for consumers that need to know this information.
As well as the `interactions` Flow, simple extension functions on InteractionSource (collectIsDraggedAsState, collectIsFocusedAsState, collectIsPressedAsState) have been added for cases when components only care about the binary state of a particular interaction, and not the entire stream of events.
MutableInteractionSource exposes `emit()` and `tryEmit()` methods that allow emitting Interactions to the `interactions` Flow.
This CL also changes the existing Interactions to be classes, and adds further classes representing stop / cancel events for the initial events.
Bug:
Fixes:
Fixes:
Fixes:
Test: InteractionSourceTest
Test: updateApi
Relnote: "InteractionState has been replaced with [Mutable]InteractionSource - interfaces responsible for emitting / collecting Interaction events. Instead of passing `interactionState = remember { InteractionState() }` to components such as Button and Modifier.clickable(), use `interactionSource = remember { MutableInteractionSource() }`. Instead of: `Interaction.Pressed in interactionState` you should instead use the extension functions on InteractionSource, such as InteractionSource.collectIsPressedAsState(). For complex use cases you can use InteractionSource.interactions to observe the stream of Interactions. See the InteractionSource documentation and samples for more information."
Change-Id: I85965d0dba39d1740c097915d1d1a367eea2a78c
M compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/MultiDimensionalAnimationDemo.kt
M compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/SingleValueAnimationDemo.kt
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/FoundationDemos.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeVariousInputField.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/FocusableSample.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
A compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionSourceSample.kt
D compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ClickableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/DraggableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/FocusableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/IndicationTest.kt
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/InteractionSourceTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/SelectableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ToggleableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextFieldInteractionsTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Focusable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
D compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Interaction.kt
D compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/InteractionState.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/interaction/DragInteraction.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/interaction/FocusInteraction.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/interaction/Interaction.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/interaction/InteractionSource.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/interaction/PressInteraction.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Selectable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Toggleable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicTextField.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldGestureModifiers.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldPressGestureFilter.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldScroll.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
M compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Scrollbar.desktop.kt
D compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/InteractionStateTest.kt
M compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt
M compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleAnimation.kt
M compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleTheme.kt
M compose/material/material/api/current.txt
M compose/material/material/api/public_plus_experimental_current.txt
M compose/material/material/api/restricted_current.txt
M compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/TopAppBar.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/BottomNavigationScreenshotTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/TabScreenshotTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
M compose/material/material/src/androidMain/kotlin/androidx/compose/material/AndroidMenu.android.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Checkbox.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Elevation.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/IconButton.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/RadioButton.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldDefaults.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
M compose/material/material/src/desktopMain/kotlin/androidx/compose/material/DesktopMenu.desktop.kt
M compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
an...@google.com <an...@google.com> #10
Currently DefaultFloatingActionButton does not have a param for focusedElevation (it has default and hovered), so that will need to be added also
cl...@google.com <cl...@google.com> #11
Confirmed with Louis this is targetting M2
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit e897e07adb935e854493484004e822454d164e49
Author: Igor Demin <igor.demin@jetbrains.com>
Date: Wed Aug 25 20:53:19 2021
Implement HoverInteraction and Modifier.hoverable
Modifier.hoverable triggers HoverInteraction.Enter when pointer enters the component, and HoverInteraction.Exit - when pointer exits the component or when component is disposed.
```
@Composable
fun Sample1() {
val interactionSource = remember { MutableInteractionSource() }
val isHovered by interactionSource.collectIsHoveredAsState()
Box(
Modifier
.size(128.dp)
.background(if (isHovered) Color.Red else Color.Green)
.hoverable(interactionSource = interactionSource)
)
}
```
Change-Id: Iafb99afb3049206fe72a37c0f5b905fda0acba00
Bug: 152525426
Bug: 172253090
Test: ./gradlew buildOnServer
Relnote: Added Modifier.hoverable for enter/exit events of mouse/stylus/etc. See HoverableSample
M compose/foundation/foundation/api/public_plus_experimental_current.txt
M compose/foundation/foundation/api/restricted_current.txt
A compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/HoverableTest.kt
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Scrollbar.desktop.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/HighLevelGesturesDemo.kt
A compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/HoverableSample.kt
M compose/foundation/foundation/build.gradle
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/interaction/HoverInteraction.kt
A compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Hoverable.kt
ap...@google.com <ap...@google.com> #13
Branch: androidx-main
commit 60db6837fc61c0560112a659fb33d24e6d3b1d16
Author: Louis Pullen-Freilich <lpf@google.com>
Date: Tue Oct 12 18:28:42 2021
Clickable and focusable can now be focused in non-touch modes
Also adds focus state support in ripple and Material components.
Bug:
Fixes:
Fixes:
Test: Screenshot tests / modifier tests
Relnote: "Modifier.clickable and Modifier.toggleable can now be focused by default when using a keyboard. Ripple has been updated to support focus state, so components such as Button will now appear focused when necessary."
Change-Id: I2161d9c5e4ef4d039fb8f90cb43a94f0f15c0795
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Focusable.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Toggleable.kt
M compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ClickableTest.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ToggleableTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonScreenshotTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
M compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleTheme.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Elevation.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/RadioButtonScreenshotTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/CheckboxScreenshotTest.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
M compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/PrintToStringTest.kt
M compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
M compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/SelectableTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
M compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/FloatingActionButtonScreenshotTest.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
Description
Elements typically have different visual appearance / behavior when they are:
etc
We should provide a consistent API story around managing these states, and make it easy to combine foundational interactions such as
draggable
, to wire up these states within a component.