From 847f1b2508c2179e437ec89490e01ae1011c5487 Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 31 Jul 2020 01:09:51 +0200 Subject: [PATCH] Displaying an icon for AllBanksListItem; extracted AccountFallbackIcon --- ui/BankingiOSApp/BankingiOSApp/ui/Styles.swift | 3 +++ .../BankingiOSApp/ui/views/AllBanksListItem.swift | 3 +-- .../BankingiOSApp/ui/views/IconedTitleView.swift | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/Styles.swift b/ui/BankingiOSApp/BankingiOSApp/ui/Styles.swift index cd881c3d..ebea9c21 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/Styles.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/Styles.swift @@ -8,4 +8,7 @@ class Styles { static let NegativeAmountColor = Color.red + static let AccountFallbackIcon = "accounts" + + } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift index 13c87f55..191359f9 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift @@ -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() diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/IconedTitleView.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/IconedTitleView.swift index 66683219..1cebdb3a 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/IconedTitleView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/IconedTitleView.swift @@ -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) } }