Disabling EditButton if no account has been added yet
This commit is contained in:
parent
eac6ec7d62
commit
5d29a12f02
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue