-
Notifications
You must be signed in to change notification settings - Fork 136
[POS Historical Orders] Pull to Refresh #14578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a890474
Enhance orders state and adapt clients
toupper cc911fc
Implement Pull To Refresh
toupper 73ba760
Add unit tests
toupper 313a64c
Remove non necessary comment
toupper b0f9a13
Merge branch 'feat/WOOMOB-1145-pos-historical-orders-in-memory-cache'…
toupper 3cabebf
Merge branch 'feat/WOOMOB-1145-pos-historical-orders-in-memory-cache'…
toupper 0df5676
Fix tests
toupper ba95772
Fix Detekt
toupper 9713b6d
add missing import
toupper b70396c
Refactor to better readability
toupper 020078a
Simplify state
toupper 48dc8e5
Fix detekt
toupper e4d24ab
Refactor for better readability
toupper 3292780
Remove elvis operator applied to a non-nullable type
toupper 4340083
Revert to a sealed class
toupper 6c9aa20
Use logic from view model
toupper a5378e8
Add information about the pull refresh enabled state
toupper 73bec2d
Simplify view model
toupper 2894ae4
Fix test
toupper 7cf9f93
Keep one source of truth for refreshing
toupper ac705b3
Rename to follow convention,
toupper 6f414cc
Better naming
toupper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
52 changes: 42 additions & 10 deletions
52
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosOrdersState.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,45 @@ | ||
| package com.woocommerce.android.ui.woopos.orders | ||
|
|
||
| import com.woocommerce.android.model.Order | ||
|
|
||
| data class WooPosOrdersState( | ||
| val orders: List<Order> = emptyList(), | ||
| val selectedOrderId: Long? = null, | ||
| val isLoading: Boolean = false, | ||
| val error: String? = null | ||
| ) { | ||
| val selectedOrder: Order? | ||
| get() = selectedOrderId?.let { id -> orders.firstOrNull { it.id == id } } | ||
| import androidx.compose.runtime.Immutable | ||
| import com.woocommerce.android.ui.woopos.home.items.WooPosPaginationState | ||
| import com.woocommerce.android.ui.woopos.home.items.WooPosPullToRefreshState | ||
|
|
||
| @Immutable | ||
| data class OrderItemViewState( | ||
| val id: Long, | ||
| val title: String, | ||
| val date: String, | ||
| val total: String, | ||
| val isSelected: Boolean | ||
| ) | ||
|
|
||
| @Immutable | ||
| sealed class WooPosOrdersState { | ||
| abstract val pullToRefreshState: WooPosPullToRefreshState | ||
|
|
||
| @Immutable | ||
| data class Content( | ||
| val items: List<OrderItemViewState>, | ||
| override val pullToRefreshState: WooPosPullToRefreshState, | ||
| val paginationState: WooPosPaginationState, | ||
| val selectedOrderId: Long? | ||
| ) : WooPosOrdersState() | ||
|
|
||
| @Immutable | ||
| data class Error( | ||
| val message: String, | ||
| ) : WooPosOrdersState() { | ||
| override val pullToRefreshState: WooPosPullToRefreshState = WooPosPullToRefreshState.Disabled | ||
| } | ||
|
|
||
| @Immutable | ||
| data object Loading : WooPosOrdersState() { | ||
| override val pullToRefreshState: WooPosPullToRefreshState = WooPosPullToRefreshState.Disabled | ||
| } | ||
|
|
||
| @Immutable | ||
| data class Empty( | ||
| override val pullToRefreshState: WooPosPullToRefreshState = | ||
| WooPosPullToRefreshState.Enabled | ||
| ) : WooPosOrdersState() | ||
| } |
Oops, something went wrong.
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.
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.
Not related to the PR: on line 55 there is still

?:applied to a non-nullable typeThere 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.
True, removed in 3292780