Displaying an icon for AllBanksListItem; extracted AccountFallbackIcon

This commit is contained in:
dankito 2020-07-31 01:09:51 +02:00
parent 4597c3fce5
commit 847f1b2508
3 changed files with 8 additions and 6 deletions

View File

@ -8,4 +8,7 @@ class Styles {
static let NegativeAmountColor = Color.red
static let AccountFallbackIcon = "accounts"
}

View File

@ -11,8 +11,7 @@ struct AllBanksListItem: View {
Section {
ZStack {
HStack {
Text("All accounts")
.font(.headline)
IconedTitleView(accountTitle: "All accounts".localize(), iconUrl: nil, defaultIconName: Styles.AccountFallbackIcon, titleFont: .headline)
Spacer()

View File

@ -17,11 +17,11 @@ struct IconedTitleView: View {
init(_ bank: Customer, titleFont: Font? = nil) {
self.init(accountTitle: bank.displayName, iconUrl: bank.iconUrl, defaultIconName: "accounts", titleFont: titleFont)
self.init(accountTitle: bank.displayName, iconUrl: bank.iconUrl, defaultIconName: Styles.AccountFallbackIcon, titleFont: titleFont)
}
init(_ account: BankAccount, titleFont: Font? = nil) {
self.init(accountTitle: account.displayName, iconUrl: account.customer.iconUrl, defaultIconName: "accounts", titleFont: titleFont)
self.init(accountTitle: account.displayName, iconUrl: account.customer.iconUrl, defaultIconName: Styles.AccountFallbackIcon, titleFont: titleFont)
}
init(accountTitle: String, iconUrl: String?, defaultIconName: String, titleFont: Font? = nil) {
@ -60,7 +60,7 @@ struct IconedTitleView: View {
private func getTitleView() -> Text {
if let titleFont = titleFont {
return Text(self.title)
return Text(title)
.font(titleFont)
}
else {
@ -74,7 +74,7 @@ struct IconedTitleView: View {
struct IconedAccountTitle_Previews: PreviewProvider {
static var previews: some View {
IconedTitleView(accountTitle: "Abzockbank", iconUrl: nil, defaultIconName: "accounts")
IconedTitleView(accountTitle: "Abzockbank", iconUrl: nil, defaultIconName: Styles.AccountFallbackIcon)
}
}