-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dashboard usage of cart and itemlist VMs
- Loading branch information
Showing
12 changed files
with
186 additions
and
201 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import protocol Yosemite.POSItem | ||
|
||
enum PointOfSaleItemListState: Equatable { | ||
case empty | ||
case initialLoading | ||
case loading | ||
case loaded([POSItem]) | ||
case error(PointOfSaleErrorState) | ||
|
||
var isLoaded: Bool { | ||
switch self { | ||
case .loaded: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
var isLoading: Bool { | ||
switch self { | ||
case .loading: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
var hasError: PointOfSaleErrorState { | ||
switch self { | ||
case .error(let errorModel): | ||
return errorModel | ||
default: | ||
return PointOfSaleErrorState(title: "Unknown error", | ||
subtitle: "Unknown error", | ||
buttonText: "Retry") | ||
} | ||
} | ||
|
||
// Equatable conformance for testing: | ||
static func == (lhs: PointOfSaleItemListState, rhs: PointOfSaleItemListState) -> Bool { | ||
switch (lhs, rhs) { | ||
case (.initialLoading, .initialLoading), | ||
(.empty, .empty), | ||
(.loading, .loading): | ||
return true | ||
case (.loaded(let lhsItems), .loaded(let rhsItems)): | ||
return lhsItems.map { $0.itemID } == rhsItems.map { $0.itemID } | ||
case (.error(let lhsError), .error(let rhsError)): | ||
return lhsError == rhsError | ||
default: | ||
return false | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...lasses/POS/Presentation/CardReaderConnection/UI States/PointOfSaleItemListErrorView.swift
This file contains 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 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 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 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 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 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
Oops, something went wrong.