Status Update
Comments
ae...@google.com <ae...@google.com>
an...@google.com <an...@google.com>
du...@google.com <du...@google.com> #2
You may create a LazyPagingItems
through the extension
To construct a Flow<PagingData>
from static sample data for your preview, you can use
ri...@gmail.com <ri...@gmail.com> #3
The preview did compile, but no items displayed, other UI components such as Button works fine though.
The code now:
@Preview
@Composable
fun Preview() {
val usersFlow = flowOf(
PagingData.from(
listOf(
User("123", "33423", "2211", "Makanan", "Dapur", "Risal", "User", "Masakka")
)
)
)
DefaultTheme {
Surface() {
MainUi(
users = usersFlow.collectAsLazyPagingItems(),
onEditItem = {},
onDeleteItem = {}
) {
}
}
}
}
ri...@gmail.com <ri...@gmail.com> #4
I don't know if this is related but the IDE give me this message
High number of internal exceptions has been detected. This indicates a serious problem with the IDE. Please consider clean reinstall of Android Studio. If the problem persists, please report a bug by following the link below.
Build: AI-203.7717.56.2031.7583922, 202107261959,
AI-203.7717.56.2031.7583922, JRE 11.0.10+0-b96-7249189x64 JetBrains s.r.o., OS Linux(amd64) v5.11.0-7620-generic, screens 1920.0x1080.0, 1920.0x1080.0
AS: Arctic Fox | 2020.3.1; Kotlin plugin: 203-1.5.21-release-328-AS7717.8; Android Gradle Plugin: 7.0.0; Gradle: 7.0.2; Gradle JDK: version 11.0.10; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: (not found)
an...@google.com <an...@google.com> #5
The reason is the regular preview is displaying the first frame, however with LazyPagingItems there is always one frame with empty data and only then we load the real values
ri...@gmail.com <ri...@gmail.com> #6
Nope, still the same.
an...@gmail.com <an...@gmail.com> #7
In my project preview also doesn't works. I tried all suggestion above.
de...@gmail.com <de...@gmail.com> #8
to...@gmail.com <to...@gmail.com> #9
Workaround is to create another Compose function which takes regular List<T> instead of LazyPagingItems<T> for previewing purposes.
ke...@gmail.com <ke...@gmail.com> #10
ja...@gmail.com <ja...@gmail.com> #11
ma...@migrosonline.ch <ma...@migrosonline.ch> #12
be...@swile.co <be...@swile.co> #13
be...@swile.co <be...@swile.co> #14
(I'm on Chipmunk Beta 2)
th...@palringo.com <th...@palringo.com> #15
da...@gmail.com <da...@gmail.com> #16
With compose 1.2.0-beta01, constructing a static LazyPagingItems like this works for me in interactive preview.
val ordersFlow = flowOf(PagingData.from(orders))
val pagingItems = ordersFlow.collectAsLazyPagingItems()
However, the static preview will only show an empty list of items.
wo...@gmail.com <wo...@gmail.com> #17
I still cannot preview the list. Interactive preview doesn't show it as well.
du...@google.com <du...@google.com> #18
Preview doesn't work in paging-compose at the moment with PagingData
because it has to wait for some work to be done before any items show up, so the first frame is always empty as mentioned in #5. However, it's worth investigating if we can get it to work with static PagingData
like PagingData.from
ai...@googlemail.com <ai...@googlemail.com> #19
ro...@cloudkitchens.com <ro...@cloudkitchens.com> #20
ki...@gmail.com <ki...@gmail.com> #21
+1 our snapshot tests became useless after moving from unpaged lists to paged lists, would be really nice to have a preview functionality so our snapshot tests can keep working
lu...@gmail.com <lu...@gmail.com> #22
Please reopen.
ki...@gmail.com <ki...@gmail.com> #23
Would be great to reopen this or give a reason why it won't be fixed. Seems like an important functionality since like it currently stands we cannot cover paged lists with paparazzi snapshot tests.
cl...@google.com <cl...@google.com> #24
Reopening as it's something we would want for paging-compose.
Paging currently can't support this because as
[Deleted User] <[Deleted User]> #25
[Deleted User] <[Deleted User]> #26
di...@gmail.com <di...@gmail.com> #27
cl...@google.com <cl...@google.com> #28
We are planning to include preview support as part of stable paging-compose.
ri...@gmail.com <ri...@gmail.com> #29
Any dates/timelines?
cl...@google.com <cl...@google.com> #30
Currently planned for Q2/Q3.
ap...@google.com <ap...@google.com> #31
Branch: androidx-main
commit 15fa26db22d9a0d2e00cb3847620bc6ae08561fc
Author: Clara Fok <clarafok@google.com>
Date: Mon May 01 16:53:10 2023
Add support for Paging preview in compose
Paging Compose now supports previewing a list of fake data by creating a PagingData.from(fakeData) and passing the PagingData to a MutableStateFlow. Call the MutableStateFlow<PagingData<Value>>.collectAsLazyPagingItems() to preview.
Test: ./gradlew paging:paging-compose:cC
Test: preview sample in PagingPreviewSample
Bug: 194544557
Relnote: "Paging Compose now supports previewing a list of fake data by creating a PagingData.from(fakeData) and passing the PagingData to a MutableStateFlow. Call the MutableStateFlow<PagingData<Value>>.collectAsLazyPagingItems() to get previewable LazyPagingItems."
Change-Id: I8a78db059776190b833773986825579e96e042d5
M paging/paging-common/src/main/kotlin/androidx/paging/PagingData.kt
M paging/paging-compose/build.gradle
M paging/paging-compose/samples/build.gradle
A paging/paging-compose/samples/src/main/java/androidx/paging/compose/samples/PagingPreviewSample.kt
A paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsPreviewTest.kt
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
cl...@google.com <cl...@google.com> #32
Fixed internally and will be available in the next Paging release. This bug will be updated with release version at the time.
k....@rebuy.com <k....@rebuy.com> #33
Is it already in 1.0.0-alpha19
? If yes, then could I get an example of how to use it?
cl...@google.com <cl...@google.com> #34
It will be available in the upcoming release on May 24th as paging-compose 1.0.0-alpha20
.
The change does include an example on how to set up
The example has DisplayPaging()
composable inlined within PagingPreview()
composable. This is ONLY FOR sample purposes because of how the @Preview
annotation is rendered in documents. In production code DisplayPaging()
should be its own separate, top-level declaration.
ju...@google.com <ju...@google.com> #35
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.paging:paging-common:3.2.0-alpha06
androidx.paging:paging-compose:1.0.0-alpha20
no...@gmail.com <no...@gmail.com> #36
One important point – inside @Preview
, you should use MutableStateFlow()
rather than builders like flowOf()
– the latter simply doesn’t work
Description
Jetpack Compose release version:1.0.0-rc02
Android Studio Build:Android Studio Bumblebee | 2021.1.1 Canary 4
Kotlin version:1.5.10
I think the title says it all.
LazyPagingItems
constructor is internal. I can't passLazyPagingItems
as parameter in Preview Composable, let alone passing sample data. But I want to show preview of my composable, how should I do this?