From 3988e7ebac1ead0848a8bfd4ef6a7a77d197ec62 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 23 Sep 2020 23:13:29 +0200 Subject: [PATCH] Extracted SectionWithoutBackground --- .../BankingiOSApp.xcodeproj/project.pbxproj | 4 +++ .../dialogs/AccountTransactionsDialog.swift | 4 +-- .../ui/dialogs/AccountsDialog.swift | 3 +- .../ui/views/SectionWithoutBackground.swift | 35 +++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithoutBackground.swift diff --git a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj index c2a3fa8f..ccc73bf1 100644 --- a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj +++ b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 361116A62505430500315620 /* KeychainPasswordItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 361116A52505430400315620 /* KeychainPasswordItem.swift */; }; 361116A8250562BE00315620 /* FaceIDButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 361116A7250562BE00315620 /* FaceIDButton.swift */; }; 361116AA250562CF00315620 /* TouchIDButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 361116A9250562CF00315620 /* TouchIDButton.swift */; }; + 36428CFF251BEC4C009DE1AE /* SectionWithoutBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36428CFE251BEC4C009DE1AE /* SectionWithoutBackground.swift */; }; 3642F00A2500F5AE005186FE /* Divider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3642F0092500F5AE005186FE /* Divider.swift */; }; 3642F00C25010021005186FE /* UIKitActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3642F00B25010021005186FE /* UIKitActivityIndicator.swift */; }; 3642F01425018BA9005186FE /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3642F01325018BA9005186FE /* TabBarController.swift */; }; @@ -168,6 +169,7 @@ 361116A52505430400315620 /* KeychainPasswordItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainPasswordItem.swift; sourceTree = ""; }; 361116A7250562BE00315620 /* FaceIDButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaceIDButton.swift; sourceTree = ""; }; 361116A9250562CF00315620 /* TouchIDButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchIDButton.swift; sourceTree = ""; }; + 36428CFE251BEC4C009DE1AE /* SectionWithoutBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionWithoutBackground.swift; sourceTree = ""; }; 3642F0092500F5AE005186FE /* Divider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Divider.swift; sourceTree = ""; }; 3642F00B25010021005186FE /* UIKitActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitActivityIndicator.swift; sourceTree = ""; }; 3642F01325018BA9005186FE /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = ""; }; @@ -560,6 +562,7 @@ 361116A9250562CF00315620 /* TouchIDButton.swift */, 3684EB8A2508F6F00001139E /* SearchBarWithLabel.swift */, 3684EB91250FD4AF0001139E /* LabelledValue.swift */, + 36428CFE251BEC4C009DE1AE /* SectionWithoutBackground.swift */, ); path = views; sourceTree = ""; @@ -735,6 +738,7 @@ 36BE068D24CE41E700CBBB68 /* Styles.swift in Sources */, 3642F00C25010021005186FE /* UIKitActivityIndicator.swift in Sources */, 36E21ECB24D88DF000649DC8 /* UIKitExtensions.swift in Sources */, + 36428CFF251BEC4C009DE1AE /* SectionWithoutBackground.swift in Sources */, 360782C524E541970098FEFE /* ScaleImageView.swift in Sources */, 366FA4E224C4ED6C0094F009 /* EnterTanDialog.swift in Sources */, 361116AA250562CF00315620 /* TouchIDButton.swift in Sources */, diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift index 80c8018e..7c6b8024 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift @@ -91,7 +91,7 @@ struct AccountTransactionsDialog: View { } if showFetchAllTransactionsView { - Section { + SectionWithoutBackground { HStack(alignment: .center) { Spacer() @@ -101,8 +101,6 @@ struct AccountTransactionsDialog: View { } .padding(.horizontal, 6) } - .frame(maxWidth: .infinity, minHeight: 44) // has to have at least a height of 44 (iOS 14; iOS 13: 40), otherwise a white line at bottom gets displayed - .removeListInsets() } if showTransactionsList { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift index 01bee9e4..711cd436 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift @@ -26,10 +26,9 @@ struct AccountsDialog: View { BankListItem(bank: bank) } - Section { + SectionWithoutBackground { AddAccountButtonView() } - .removeSectionBackground() } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithoutBackground.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithoutBackground.swift new file mode 100644 index 00000000..197484c3 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/SectionWithoutBackground.swift @@ -0,0 +1,35 @@ +import SwiftUI + + +struct SectionWithoutBackground: View { + + private let content: () -> Content + + + init(@ViewBuilder _ content: @escaping () -> Content) { + self.content = content + } + + + var body: some View { + Section { + content() + } + .frame(maxWidth: .infinity, minHeight: 44) // has to have at least a height of 44 (iOS 14; iOS 13: 40), otherwise a white line at bottom gets displayed + .removeSectionBackground() + } + +} + + +struct SectionWithoutBackground_Previews: PreviewProvider { + + static var previews: some View { + Form { + SectionWithoutBackground { + Text("Hello") + } + } + } + +}