[cleanup] tidy `.demo` properties and rename to `.placeholder`
This commit is contained in:
parent
afdd071341
commit
61696bbda6
|
@ -119,3 +119,15 @@ extension HomeViewStore {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: PlaceHolders
|
||||
|
||||
extension HomeState {
|
||||
static var placeholder: Self {
|
||||
.init(
|
||||
transactionHistoryState: .placeHolder,
|
||||
route: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ struct HomeView: View {
|
|||
SendView(
|
||||
store: .init(
|
||||
initialState: .init(
|
||||
transaction: .demo,
|
||||
transaction: .placeholder,
|
||||
route: nil
|
||||
),
|
||||
reducer: SendReducer.default(
|
||||
|
@ -114,13 +114,10 @@ struct HomeView: View {
|
|||
}
|
||||
|
||||
extension HomeStore {
|
||||
static var demo: HomeStore {
|
||||
static var placeholder: HomeStore {
|
||||
HomeStore(
|
||||
initialState: HomeState(
|
||||
transactionHistoryState: .init(
|
||||
transactions: .demo,
|
||||
route: nil
|
||||
),
|
||||
transactionHistoryState: .placeHolder,
|
||||
route: nil
|
||||
),
|
||||
reducer: .default.debug(),
|
||||
|
@ -134,7 +131,7 @@ extension HomeStore {
|
|||
struct HomeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
HomeView(store: .demo)
|
||||
HomeView(store: .placeholder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,3 +85,11 @@ extension SendViewStore {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: PlaceHolders
|
||||
|
||||
extension SendState {
|
||||
static var placeholder: Self {
|
||||
.init(transaction: .placeholder, route: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ struct Approve: View {
|
|||
struct Approve_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
StateContainer(initialState: (Transaction.demo, false)) {
|
||||
StateContainer(initialState: (Transaction.placeholder, false)) {
|
||||
Approve(
|
||||
transaction: $0.0.wrappedValue,
|
||||
isComplete: $0.1
|
||||
|
|
|
@ -46,7 +46,7 @@ struct Create: View {
|
|||
struct Create_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
StateContainer(initialState: (Transaction.demo, false)) {
|
||||
StateContainer(initialState: (Transaction.placeholder, false)) {
|
||||
Create(
|
||||
transaction: $0.0,
|
||||
isComplete: $0.1
|
||||
|
@ -59,10 +59,10 @@ struct Create_Previews: PreviewProvider {
|
|||
|
||||
#if DEBUG
|
||||
extension SendStore {
|
||||
static var demo: SendStore {
|
||||
static var placeholder: SendStore {
|
||||
return SendStore(
|
||||
initialState: .init(
|
||||
transaction: .demo,
|
||||
transaction: .placeholder,
|
||||
route: nil
|
||||
),
|
||||
reducer: .default,
|
||||
|
|
|
@ -44,7 +44,7 @@ struct SendView_Previews: PreviewProvider {
|
|||
SendView(
|
||||
store: .init(
|
||||
initialState: .init(
|
||||
transaction: .demo,
|
||||
transaction: .placeholder,
|
||||
route: nil
|
||||
),
|
||||
reducer: .default,
|
||||
|
|
|
@ -28,6 +28,6 @@ struct Sent: View {
|
|||
|
||||
struct Done_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Sent(transaction: .demo, isComplete: .constant(false))
|
||||
Sent(transaction: .placeholder, isComplete: .constant(false))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,3 +56,61 @@ extension TransactionHistoryViewStore {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: PlaceHolders
|
||||
|
||||
extension Transaction {
|
||||
static var placeholder: Self {
|
||||
.init(
|
||||
id: 2,
|
||||
amount: 123,
|
||||
memo: "defaultMemo",
|
||||
toAddress: "ToAddress",
|
||||
fromAddress: "FromAddress"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension TransactionHistoryState {
|
||||
static var placeHolder: Self {
|
||||
.init(transactions: .placeholder, route: nil)
|
||||
}
|
||||
}
|
||||
|
||||
extension TransactionHistoryStore {
|
||||
static var placeholder: Store<TransactionHistoryState, TransactionHistoryAction> {
|
||||
return Store(
|
||||
initialState: .placeHolder,
|
||||
reducer: .default,
|
||||
environment: ()
|
||||
)
|
||||
}
|
||||
|
||||
static var demoWithSelectedTransaction: Store<TransactionHistoryState, TransactionHistoryAction> {
|
||||
let transactions = IdentifiedArrayOf<Transaction>.placeholder
|
||||
return Store(
|
||||
initialState: TransactionHistoryState(
|
||||
transactions: transactions,
|
||||
route: .showTransaction(transactions[3])
|
||||
),
|
||||
reducer: .default.debug(),
|
||||
environment: ()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension IdentifiedArrayOf where Element == Transaction {
|
||||
static var placeholder: IdentifiedArrayOf<Transaction> {
|
||||
return .init(
|
||||
uniqueElements: (0..<10).map {
|
||||
Transaction(
|
||||
id: $0,
|
||||
amount: 25,
|
||||
memo: "defaultMemo",
|
||||
toAddress: "ToAddress",
|
||||
fromAddress: "FromAddress"
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,25 +8,10 @@ struct TransactionDetailView: View {
|
|||
.navigationTitle("Transaction: \(transaction.id)")
|
||||
}
|
||||
}
|
||||
|
||||
extension Transaction {
|
||||
static var demo: Self {
|
||||
.init(
|
||||
id: 2,
|
||||
amount: 123,
|
||||
memo: "defaultMemo",
|
||||
toAddress: "ToAddress",
|
||||
fromAddress: "FromAddress"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct TransactionDetail_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
TransactionDetailView(transaction: .demo)
|
||||
TransactionDetailView(transaction: .placeholder)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -22,57 +22,10 @@ struct TransactionHistoryView: View {
|
|||
}
|
||||
}
|
||||
|
||||
extension TransactionHistoryStore {
|
||||
static var demo: Store<TransactionHistoryState, TransactionHistoryAction> {
|
||||
return Store(
|
||||
initialState: TransactionHistoryState(
|
||||
transactions: .demo,
|
||||
route: nil
|
||||
),
|
||||
reducer: .default,
|
||||
environment: ()
|
||||
)
|
||||
}
|
||||
|
||||
static var demoWithSelectedTransaction: Store<TransactionHistoryState, TransactionHistoryAction> {
|
||||
let transactions = IdentifiedArrayOf<Transaction>.demo
|
||||
return Store(
|
||||
initialState: TransactionHistoryState(
|
||||
transactions: transactions,
|
||||
route: .showTransaction(transactions[3])
|
||||
),
|
||||
reducer: .default.debug(),
|
||||
environment: ()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension IdentifiedArrayOf where Element == Transaction {
|
||||
static var demo: IdentifiedArrayOf<Transaction> {
|
||||
return .init(
|
||||
uniqueElements: (0..<10).map {
|
||||
Transaction(
|
||||
id: $0,
|
||||
amount: 25,
|
||||
memo: "defaultMemo",
|
||||
toAddress: "ToAddress",
|
||||
fromAddress: "FromAddress"
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct TransactionView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
TransactionHistoryView(store: .demo)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
NavigationView {
|
||||
TransactionHistoryView(store: .demoWithSelectedTransaction)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
TransactionHistoryView(store: .placeholder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import SwiftUI
|
|||
|
||||
@main
|
||||
struct SecantApp: App {
|
||||
var homeStore: HomeStore = .demo
|
||||
var homeStore: HomeStore = .placeholder
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
NavigationView {
|
||||
|
|
Loading…
Reference in New Issue