From 5d29a12f0271983d1c62fc9c1ffd7eb4ead532df Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 5 Sep 2020 02:31:00 +0200 Subject: [PATCH] Disabling EditButton if no account has been added yet --- .../ui/views/SectionHeaderWithRightAlignedEditButton.swift | 7 ++++++- .../BankingiOSApp/ui/views/SettingsDialog.swift | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift index 43013d8b..4e926ae3 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift @@ -5,15 +5,20 @@ struct SectionHeaderWithRightAlignedEditButton: View { private let sectionTitle: LocalizedStringKey + private let isEditButtonEnabled: Bool - init(_ sectionTitle: LocalizedStringKey) { + + init(_ sectionTitle: LocalizedStringKey, isEditButtonEnabled: Bool = true) { self.sectionTitle = sectionTitle + + self.isEditButtonEnabled = isEditButtonEnabled } var body: some View { EditButton() .frame(maxWidth: .infinity, alignment: .trailing) + .disabled( !isEditButtonEnabled) .overlay(Text(sectionTitle), alignment: .leading) } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SettingsDialog.swift index 576b44f5..07ee8f38 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/SettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/SettingsDialog.swift @@ -14,7 +14,7 @@ struct SettingsDialog: View { var body: some View { Form { - Section(header: SectionHeaderWithRightAlignedEditButton("Bank Credentials")) { + Section(header: SectionHeaderWithRightAlignedEditButton("Bank Credentials", isEditButtonEnabled: data.hasAtLeastOneAccountBeenAdded)) { ForEach(data.banksSorted) { bank in NavigationLink(destination: LazyView(BankSettingsDialog(bank))) { IconedTitleView(bank)