Migrate Compose touch and input snippets - #1118
Open
pengzhi-cb wants to merge 6 commits into
Open
pengzhi-cb wants to merge 6 commits into
pengzhi-cb wants to merge 6 commits into
Conversation
pengzhi-cb
force-pushed
the
pengzhi-cb/compose-migrate-swipeable
branch
from
September 29, 2026 21:56
a0a6981 to
aa14dc4
Compare
pengzhi-cb
marked this pull request as ready for review
September 29, 2026 22:08
kkuan2011
reviewed
Oct 2, 2026
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.offset | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.material.Text |
Contributor
There was a problem hiding this comment.
can you import the m3 versions of Text and TopAppBar?
| import com.example.compose.snippets.touchinput.pointerinput.DragValue.Center | ||
| import com.example.compose.snippets.touchinput.pointerinput.DragValue.End | ||
| import com.example.compose.snippets.touchinput.pointerinput.DragValue.Start | ||
|
|
Contributor
There was a problem hiding this comment.
Looks like we're using deprecated APIs in this file, so not sure if we should migrate those snippets
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code snippets are for:
Total: 11 code snippets (11 Kotlin and 0 XML) across 2 pages.
Resource migration notes
view_in_compose_nested_scroll_interop.xml,list_item.xml, andfragment_bottom_sheet.xml) were added tocompose/snippets/src/main/res/layout/because the tagged Kotlin snippets inNestedScrollModifiers.ktreference their resource symbols (R.layout.view_in_compose_nested_scroll_interop,R.id.main_list,R.layout.list_item,R.layout.fragment_bottom_sheet, andR.id.compose_view) and will not compile without them.inflate(...)andfindViewById(...)calls in the guide page code blocks.List of modifications
<DragValue>(initialValue = DragValue.Start)toSwipeableStateinMySwitchState(android_compose_touchinput_pointerinput_migrate_swipeable_state_legacy) so the class compiles....insideAnchoredDraggableState(...)andDraggableAnchors { ... }with// [START_EXCLUDE]...// [END_EXCLUDE]blocks supplying required constructor parameters and anchor definitions inandroid_compose_touchinput_pointerinput_migrate_swipeable_state_anchored,android_compose_touchinput_pointerinput_migrate_swipeable_access_offset,android_compose_touchinput_pointerinput_migrate_swipeable_anchors_update,android_compose_touchinput_pointerinput_migrate_swipeable_positional_threshold_fraction,android_compose_touchinput_pointerinput_migrate_swipeable_positional_threshold_dp, andandroid_compose_touchinput_pointerinput_migrate_swipeable_velocity_threshold..toInt()tostate.requireOffset()insideIntOffset(...)inandroid_compose_touchinput_pointerinput_migrate_swipeable_access_offset,android_compose_touchinput_pointerinput_migrate_swipeable_anchors_constructor, andandroid_compose_touchinput_pointerinput_migrate_swipeable_anchors_updatebecauseIntOffsetrequiresIntcoordinates whilerequireOffset()returnsFloat, and fixed the mismatched closing brace}to)onBox(...)inandroid_compose_touchinput_pointerinput_migrate_swipeable_access_offset.val density = LocalDensity.currentand wrappedDraggableAnchors { ... }inwith(density) { ... }inandroid_compose_touchinput_pointerinput_migrate_swipeable_anchors_constructorsoDp.toPx()compiles, and hid requiredAnchoredDraggableStateconstructor parameters inside// [START_EXCLUDE silent]...// [END_EXCLUDE]inandroid_compose_touchinput_pointerinput_migrate_swipeable_anchors_constructor.// [START_EXCLUDE silent]title = {},// [END_EXCLUDE]insideTopAppBar(...)and replaced the trailing// ...comment inNestedScrollInteropAdapterwith// [START_EXCLUDE]override fun getItemCount(): Int = items.size// [END_EXCLUDE]inandroid_compose_touchinput_scroll_nested_scroll_interop_compose_parentso the requiredTopAppBarparameter andRecyclerView.Adapter.getItemCount()implementation compile.android.R.layout.list_itemwithR.layout.list_iteminViewInComposeNestedScrollInteropExample(android_compose_touchinput_scroll_view_in_compose_interop) (Required for the Kotlin snippet to compile) and formattedscrollable(...)arguments across lines.view_in_compose_nested_scroll_interop.xml,list_item.xml, andfragment_bottom_sheet.xmlundercompose/snippets/src/main/res/layout/(Required for the Kotlin snippet to compile).Snippets not migrated
touchinput_gestures_nested_scroll_interop.xmlon GitHub via{% includecode %}).