Fixed view for iOS 14

This commit is contained in:
dankito 2020-10-17 19:51:22 +02:00
parent cf0d721a1b
commit 8b8067be71
2 changed files with 18 additions and 6 deletions

View File

@ -30,16 +30,25 @@ extension View {
func customNavigationBarBackButton(_ onBackButtonPressed: @escaping () -> Void) -> some View { func customNavigationBarBackButton(_ onBackButtonPressed: @escaping () -> Void) -> some View {
return self return self
.navigationBarHidden(false) .setLeadingNavigationBarButton(createCancelButton(onBackButtonPressed))
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: createCancelButton(onBackButtonPressed))
} }
func setCancelAndDoneNavigationBarButtons(onCancelPressed: @escaping () -> Void, onDonePressed: @escaping () -> Void) -> some View { func setCancelAndDoneNavigationBarButtons(onCancelPressed: @escaping () -> Void, onDonePressed: @escaping () -> Void) -> some View {
return self
.customizeToSetLeadingNavigationBarButton()
.navigationBarItems(leading: createCancelButton(onCancelPressed), trailing: createDoneButton(onDonePressed))
}
func setLeadingNavigationBarButton<Button: View>(_ leadingButton: Button) -> some View {
return self
.customizeToSetLeadingNavigationBarButton()
.navigationBarItems(leading: leadingButton)
}
func customizeToSetLeadingNavigationBarButton() -> some View {
return self return self
.navigationBarHidden(false) .navigationBarHidden(false)
.navigationBarBackButtonHidden(true) .navigationBarBackButtonHidden(true)
.navigationBarItems(leading: createCancelButton(onCancelPressed), trailing: createDoneButton(onDonePressed))
} }
func createDoneButton(_ onDoneButtonPressed: @escaping () -> Void) -> some View { func createDoneButton(_ onDoneButtonPressed: @escaping () -> Void) -> some View {

View File

@ -68,8 +68,11 @@ struct LoginDialog: View {
Spacer() Spacer()
} }
.fixKeyboardCoversLowerPart()
.systemGroupedBackground()
.edgesIgnoringSafeArea(.all)
.showNavigationBarTitle("Login Dialog title") .showNavigationBarTitle("Login Dialog title")
.navigationBarItems(leading: allowCancellingLogin == false ? nil : createCancelButton { .setLeadingNavigationBarButton(allowCancellingLogin == false ? nil : createCancelButton {
self.closeDialogAndDispatchLoginResult(false) self.closeDialogAndDispatchLoginResult(false)
}) })
} }