Skip to content

Commit

Permalink
refine preview with sample data
Browse files Browse the repository at this point in the history
  • Loading branch information
guanlisheng committed Sep 15, 2024
1 parent fcbf613 commit 8f6536c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
7 changes: 4 additions & 3 deletions MMEX/Models/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Account: ExportableEntity {
var notes: String?
var currency: Currency?

init(id: Int64, name: String, type: String, status: AccountStatus, favoriteAcct: String, currencyId: Int64, balance: Double? = nil, notes: String? = nil) {
init(id: Int64, name: String, type: String, status: AccountStatus, favoriteAcct: String, currencyId: Int64, balance: Double? = nil, notes: String? = nil, currency: Currency? = nil) {
self.id = id
self.name = name
self.type = type
Expand All @@ -38,6 +38,7 @@ struct Account: ExportableEntity {
self.currencyId = currencyId
self.balance = balance
self.notes = notes
self.currency = currency
}
}

Expand All @@ -60,8 +61,8 @@ extension Account {
extension Account {
static let sampleData : [Account] =
[
Account(id: 1, name: "Account A", type: "Cash", status: AccountStatus.open, favoriteAcct: "TRUE", currencyId: 1, balance:0.0, notes:""),
Account(id: 2, name: "Account B", type: "Cash", status: AccountStatus.open, favoriteAcct: "TRUE", currencyId: 1, balance:0.0, notes:"")
Account(id: 1, name: "Account A", type: "Cash", status: AccountStatus.open, favoriteAcct: "TRUE", currencyId: 1, balance:0.0, notes:"", currency: Currency.sampleData[0]),
Account(id: 2, name: "Account B", type: "Cash", status: AccountStatus.open, favoriteAcct: "TRUE", currencyId: 2, balance:0.0, notes:"", currency: Currency.sampleData[1])
]
}

Expand Down
6 changes: 3 additions & 3 deletions MMEX/Models/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ extension Transaction {
static var empty: Transaction {Transaction(id: 0, accountID: 1, payeeID: 1, categID:1, transCode: Transcode.withdrawal, status: TransactionStatus.none, transAmount: 0.0, transDate: Date().ISO8601Format())}
static let sampleData : [Transaction] =
[
Transaction(id: 1, accountID: 1, payeeID: 1, categID:1, transCode: Transcode.withdrawal, status: TransactionStatus.none, transAmount: 0.0, transDate: Date().ISO8601Format()),
Transaction(id: 2, accountID: 2, payeeID: 2, categID:1, transCode: Transcode.deposit, status: TransactionStatus.none,transAmount: 0.0, transDate: Date().ISO8601Format()),
Transaction(id: 3, accountID: 3, payeeID: 3, categID:1, transCode: Transcode.transfer, status: TransactionStatus.none, transAmount: 0.0, transDate: Date().ISO8601Format())
Transaction(id: 1, accountID: 1, payeeID: 1, categID:1, transCode: Transcode.withdrawal, status: TransactionStatus.none, transAmount: 10.01, transDate: Date().ISO8601Format()),
Transaction(id: 2, accountID: 2, payeeID: 2, categID:1, transCode: Transcode.deposit, status: TransactionStatus.none,transAmount: 20.02, transDate: Date().ISO8601Format()),
Transaction(id: 3, accountID: 3, payeeID: 3, categID:1, transCode: Transcode.transfer, status: TransactionStatus.none, transAmount: 30.03, transDate: Date().ISO8601Format())
]
}

Expand Down
4 changes: 4 additions & 0 deletions MMEX/Views/AccountDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ struct AccountDetailView: View {
#Preview {
AccountDetailView(account: Account.sampleData[0], databaseURL: URL(string: "path/to/database")!, currencies: .constant(Currency.sampleData))
}

#Preview {
AccountDetailView(account: Account.sampleData[1], databaseURL: URL(string: "path/to/database")!, currencies: .constant(Currency.sampleData))
}
6 changes: 6 additions & 0 deletions MMEX/Views/TransactionDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,9 @@ struct TransactionDetailView: View {
}
}
}

#Preview {
TransactionDetailView(txn: Transaction.sampleData[0], databaseURL: URL(string: "path/to/database")!
, payees: .constant(Payee.sampleData), categories: .constant(Category.sampleData)
, accounts: .constant(Account.sampleData))
}

0 comments on commit 8f6536c

Please sign in to comment.