-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Feature pull to refresh gallery screen issue [866] #934
Feature pull to refresh gallery screen issue [866] #934
Conversation
app/src/main/java/com/google/samples/apps/sunflower/viewmodels/GalleryViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/samples/apps/sunflower/viewmodels/GalleryViewModel.kt
Show resolved
Hide resolved
app/src/main/java/com/google/samples/apps/sunflower/viewmodels/GalleryViewModel.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more changes to simplify the code
val photo = pagingItems[index] | ||
"${ photo?.id ?: ""}${index}" | ||
|
||
var isRefreshing by remember { mutableStateOf(false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra isRefreshing
state is not needed. pullToRefreshState
should be the source of truth instead of having 2 different "is refreshing" states.
app/src/main/java/com/google/samples/apps/sunflower/compose/gallery/GalleryScreen.kt
Outdated
Show resolved
Hide resolved
if (pullToRefreshState.isRefreshing){ | ||
LaunchedEffect(Unit){ | ||
onPullToRefresh() | ||
isRefreshing = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this per comment above
when (pagingItems.loadState.refresh) { | ||
is LoadState.Loading -> Unit | ||
is LoadState.Error,is LoadState.NotLoading -> { | ||
isRefreshing = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call pullToRefreshState.endRefresh()
directly here
isRefreshing = true | ||
} | ||
} | ||
LaunchedEffect(isRefreshing){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code is not needed
app/src/main/java/com/google/samples/apps/sunflower/viewmodels/GalleryViewModel.kt
Show resolved
Hide resolved
Looks like the build failed due to a merge conflict. If you can address that on your side I'll go ahead and merge this in. Thanks! |
…_866 # Conflicts: # app/src/main/java/com/google/samples/apps/sunflower/compose/gallery/GalleryScreen.kt # app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt
…screen_issue_866' into feature_pull_to_refresh_gallery_screen_issue_866 # Conflicts: # app/src/main/java/com/google/samples/apps/sunflower/compose/home/HomeScreen.kt
Sure i will look into this, Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks |
Implemented Pull to refresh for gallery screen #866
updated material3 version to "1.2.0-alpha11"