Added convenience method to set navigation bar title

This commit is contained in:
dankito 2020-07-23 23:20:29 +02:00
parent 87bf88153e
commit a7fedc4f05
4 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,13 @@ extension View {
func hideNavigationBar() -> some View {
return self
.navigationBarHidden(true)
.navigationBarTitle("Title")
.navigationBarTitle("", displayMode: .inline)
}
func showNavigationBarTitle(_ title: LocalizedStringKey, displayMode: NavigationBarItem.TitleDisplayMode = .inline) -> some View {
return self
.navigationBarHidden(false)
.navigationBarTitle(title, displayMode: displayMode)
}
}

View File

@ -31,7 +31,7 @@ struct AccountTransactionsDialog: View {
}
}
}
.navigationBarTitle(Text(title), displayMode: NavigationBarItem.TitleDisplayMode.inline)
.showNavigationBarTitle(LocalizedStringKey(title))
.navigationBarHidden(false)
}
}

View File

@ -47,7 +47,7 @@ struct AddAccountDialog: View {
.alert(item: $errorMessage) { message in
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
}
.navigationBarTitle(Text("Add account"), displayMode: NavigationBarItem.TitleDisplayMode.inline)
.showNavigationBarTitle("Add account")
.navigationBarHidden(false)
}

View File

@ -121,7 +121,7 @@ struct TransferMoneyDialog: View {
return Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
}
}
.navigationBarTitle("Transfer Money Dialog Title", displayMode: .inline)
.showNavigationBarTitle("Transfer Money Dialog Title")
}