Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,9 @@ fun LazyStaggeredGridSnippet() {
model = photo,
contentScale = ContentScale.Crop,
contentDescription = null,
modifier = Modifier.fillMaxWidth().wrapContentHeight()
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
)
}
},
Expand All @@ -666,7 +668,9 @@ fun LazyStaggeredGridSnippetFixed() {
model = photo,
contentScale = ContentScale.Crop,
contentDescription = null,
modifier = Modifier.fillMaxWidth().wrapContentHeight()
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
)
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

package com.example.compose.snippets.lists

import android.provider.MediaStore
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import org.w3c.dom.Text

// [START android_compose_lists_multiple_item_types]
@Composable
fun ListWithMultipleItems(messages: List<Any>) {
LazyColumn {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this need the surrounding snippet comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

items(
messages.size,
contentType = { it }
) {
for (message in messages)
when (message) {
is MediaStore.Audio -> AudioMessage(message)
is Text -> TextMessage(message)
}
}
}
}

@Composable
fun AudioMessage(message: MediaStore.Audio) {
TODO("Not yet implemented.")
}

@Composable
fun TextMessage(message: Text) {
TODO("Not yet implemented.")
}

data class SampleMessage(val text: String, val content: Any)
// [END android_compose_lists_multiple_item_types]