Repository navigation
Migrate Compose image optimization and scrollable grid snippets - #1132
edward-williams-stellarelements wants to merge 7 commits into
Conversation
bda4067 to
117abd8
Compare
…able grid, and nested scroll modifiers
- The adaptive grid snippet published GridCells.Adaptive(minSize = 20.dp) with an empty content lambda behind an exclude. The page prints 128.dp and a real items body, and its prose names 128.dp explicitly, so both are restored and the exclude is no longer needed. - LinearLayoutManager took RecyclerView.VERTICAL where the page prints a bare VERTICAL. Imported the constant so the page's form compiles.
android_compose_components_card_minimal publishes to develop/ui/compose/components/card, which Ramon is migrating in #25 along with time-pickers. Two pull requests adding the same tag to the same file would collide, so this branch leaves the card page alone.
Ivan's review: GesturesSnippets.kt carried a hand-written object R where layout ids were plain integers. It compiled and stayed outside the region tags, so no page published it, but any reader running the snippet would have inflated nothing. Adds the four layouts the file actually needs and removes the stand-in, so R resolves to the generated one. activity_main also declares emoji_text_view, which EmojiSnippets.kt inflates from the same layout name; lint could not check that reference until a real layout existed, and flags it as MissingInflatedId once one does.
- Optimization: one android_compose_graphics_images_optimization region
around both top-level MyImage overloads, which is the tag the DAC macro
uses. The overloads take different parameter types and don't collide, so
the PainterParameterSnippet wrapper and the orphan _url/_painter tags go.
- Adaptive grid: restore the 20.dp form with the required content hidden in
a silent exclude. The tag is used only by the create-scrollable-grid quick
guide, whose prose explains 20.dp. The earlier 128.dp "fix" was checked
against lists.md, which uses android_compose_layouts_lazy_grid_adaptive,
and duplicated that tag.
- Nested scroll interop: drop the TopAppBar stub that shadowed the Material
API and call the real Material3 TopAppBar with a visible title = {}. The
page omits the required title. @OptIn(ExperimentalMaterial3Api::class) is
on the enclosing private object.
- Replace the hand-written "// ..." plus silent exclude forms: the
AndroidView elision is a plain comment (the trailing comma compiles), and
getItemCount() sits in a plain exclude.
- Add full stops to five comments (D29).
117abd8 to
42f8b96
Compare
|
Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
kkuan2011
left a comment
There was a problem hiding this comment.
Could you update the PR description? If the snippets on those pages are already in the snippets repo, then you can omit the page link in the PR.
|
|
||
| @Composable | ||
| private fun LazyVerticalGridAdaptiveSample() { | ||
| // [START android_compose_layout_scrollable_grid_adaptive] |
There was a problem hiding this comment.
Because the visible snippet on DAC does not compile, let's change the visible code so that it does compile, so we should omit the exclude tags
| // [START android_compose_touchinput_gestures_nested_scroll_interop_compose_parent_android_child] | ||
| @Composable | ||
| private fun NestedScrollInteropComposeParentWithAndroidChildExample() { | ||
| val toolbarHeightPx = with(LocalDensity.current) { ToolbarHeight.roundToPx().toFloat() } |
There was a problem hiding this comment.
Ah sorry, I realized I put this page in two tasks, so Peng has already migrated this in #1118 Could you revert this file change and remove this page from your PR description and the corresponding CL?
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> |
There was a problem hiding this comment.
I think you can remove these new xml files now, if you revert the change to GestureSnippets.kt?
The nested-scroll-modifiers page was queued twice, and it's already migrated in android#1118. Both pull requests add the same layout files, so this branch leaves the page to android#1118: - GesturesSnippets.kt goes back to main. The three new interop region tags, their imports, and the @OptIn on NestedScrollInterop are removed, and the stand-in object R that backs the existing interop_activity region is restored. - The four layouts that were added only for those snippets are removed: activity_main, fragment_bottom_sheet, list_item, and view_in_compose_nested_scroll_interop.
afdfb8b to
6b940c2
Compare
Drop the silent exclude around content = {} so the published snippet shows the required empty trailing lambda, ) {}, per review.
Snippets for two Compose pages. One region tag goes into a new file, and one goes into a file that already holds tags.
Pages and tags:
android_compose_graphics_images_optimization(images/ImageOptimizationSnippets.kt, new). It's one region around both top-levelMyImageoverloads. They have different parameter types, so no wrapper object is needed.android_compose_layout_scrollable_grid_adaptive(lists/LazyListSnippets.kt, new)The optimization tag renders exactly what the page prints. The scrollable grid tag has one visible change, listed below.
Ivan reviewed these on our fork, StellarElements#23.
List of modifications:
android_compose_layout_scrollable_grid_adaptive: the closing)is now) {}. The page printsLazyVerticalGrid(columns = GridCells.Adaptive(minSize = 20.dp))with no content, which doesn't compile becausecontentis a required parameter. The empty trailing lambda passes it in the visible code, so the snippet compiles exactly as shown. This replaces the silent exclude that hid, content = {}in the earlier revision. The page's prose explains the20.dpvalue ("the20.dpvalue specifies that every column is at least 20.dp… 88.dp wide, there are 4 columns at 22.dp each"), so 20.dp stays.Not migrated:
touchinput/gestures/GesturesSnippets.ktor adds layout files.Rebased on
main(4fb8a69)../gradlew :compose:snippets:spotlessCheck :compose:snippets:compileDebugKotlinpasses.