Renamed SectionWithRightAlignedEditButton to SectionHeaderWithRightAlignedEditButton and building now Section in View.body
This commit is contained in:
parent
0133787ee4
commit
eac6ec7d62
|
@ -74,7 +74,7 @@ struct BankSettingsDialog: View {
|
||||||
LabelledUIKitTextField(label: "FinTS server address", value: bank.finTsServerAddress) // TODO: senseful?
|
LabelledUIKitTextField(label: "FinTS server address", value: bank.finTsServerAddress) // TODO: senseful?
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionWithRightAlignedEditButton(sectionTitle: "Accounts") {
|
Section(header: SectionHeaderWithRightAlignedEditButton("Accounts")) {
|
||||||
ForEach(accountsSorted) { account in
|
ForEach(accountsSorted) { account in
|
||||||
NavigationLink(destination: LazyView(BankAccountSettingsDialog(account))) {
|
NavigationLink(destination: LazyView(BankAccountSettingsDialog(account))) {
|
||||||
Text(account.displayName)
|
Text(account.displayName)
|
||||||
|
|
|
@ -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")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,35 +0,0 @@
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
|
|
||||||
struct SectionWithRightAlignedEditButton<Content: View>: 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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -14,7 +14,7 @@ struct SettingsDialog: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
SectionWithRightAlignedEditButton(sectionTitle: "Bank Credentials") {
|
Section(header: SectionHeaderWithRightAlignedEditButton("Bank Credentials")) {
|
||||||
ForEach(data.banksSorted) { bank in
|
ForEach(data.banksSorted) { bank in
|
||||||
NavigationLink(destination: LazyView(BankSettingsDialog(bank))) {
|
NavigationLink(destination: LazyView(BankSettingsDialog(bank))) {
|
||||||
IconedTitleView(bank)
|
IconedTitleView(bank)
|
||||||
|
|
Loading…
Reference in New Issue