From eac6ec7d621e9ba788776d75d8fdf66d37b4ea4e Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 5 Sep 2020 02:28:30 +0200 Subject: [PATCH] Renamed SectionWithRightAlignedEditButton to SectionHeaderWithRightAlignedEditButton and building now Section in View.body --- .../ui/views/BankSettingsDialog.swift | 2 +- ...tionHeaderWithRightAlignedEditButton.swift | 29 +++++++++++++++ .../SectionWithRightAlignedEditButton.swift | 35 ------------------- .../ui/views/SettingsDialog.swift | 2 +- 4 files changed, 31 insertions(+), 37 deletions(-) create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift delete mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithRightAlignedEditButton.swift diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift index fd0005c2..0e460e0d 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift @@ -74,7 +74,7 @@ struct BankSettingsDialog: View { LabelledUIKitTextField(label: "FinTS server address", value: bank.finTsServerAddress) // TODO: senseful? } - SectionWithRightAlignedEditButton(sectionTitle: "Accounts") { + Section(header: SectionHeaderWithRightAlignedEditButton("Accounts")) { ForEach(accountsSorted) { account in NavigationLink(destination: LazyView(BankAccountSettingsDialog(account))) { Text(account.displayName) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift new file mode 100644 index 00000000..43013d8b --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionHeaderWithRightAlignedEditButton.swift @@ -0,0 +1,29 @@ +import SwiftUI + + +struct SectionHeaderWithRightAlignedEditButton: View { + + private let sectionTitle: LocalizedStringKey + + + init(_ sectionTitle: LocalizedStringKey) { + self.sectionTitle = sectionTitle + } + + + var body: some View { + EditButton() + .frame(maxWidth: .infinity, alignment: .trailing) + .overlay(Text(sectionTitle), alignment: .leading) + } + +} + + +struct SectionHeaderWithRightAlignedEditButton_Previews: PreviewProvider { + + static var previews: some View { + SectionHeaderWithRightAlignedEditButton("Section") + } + +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithRightAlignedEditButton.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithRightAlignedEditButton.swift deleted file mode 100644 index 7c46b4c4..00000000 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithRightAlignedEditButton.swift +++ /dev/null @@ -1,35 +0,0 @@ -import SwiftUI - - -struct SectionWithRightAlignedEditButton: View { - - private let sectionTitle: LocalizedStringKey - - private let content: Content - - - init(sectionTitle: LocalizedStringKey, @ViewBuilder content: () -> Content) { - self.sectionTitle = sectionTitle - self.content = content() - } - - - var body: some View { - Section(header: EditButton().frame(maxWidth: .infinity, alignment: .trailing) - .overlay(Text(sectionTitle), alignment: .leading)) { - content - } - } - -} - - -struct SectionWithRightAlignedEditButton_Previews: PreviewProvider { - - static var previews: some View { - SectionWithRightAlignedEditButton(sectionTitle: "Section") { - Text("Body") - } - } - -} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SettingsDialog.swift index 9f32d040..576b44f5 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 { - SectionWithRightAlignedEditButton(sectionTitle: "Bank Credentials") { + Section(header: SectionHeaderWithRightAlignedEditButton("Bank Credentials")) { ForEach(data.banksSorted) { bank in NavigationLink(destination: LazyView(BankSettingsDialog(bank))) { IconedTitleView(bank)