Skip to content

Commit

Permalink
Merge pull request #46 from SchweizerischeBundesbahnen/develop
Browse files Browse the repository at this point in the history
SBBModalView
  • Loading branch information
fleuryj authored Nov 8, 2022
2 parents 2d39133 + d67d157 commit 2f8e423
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions SBBDesignSystemMobileSwiftUI/Views/SBBModalView/SBBModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public struct SBBModalView<Content>: View where Content: View {
private let style: Style
private let titleAlignment: SBBModalViewTitleAlignment
@Binding private var isPresented: Bool
private let closeButtonAccessibilityText: Text
private let hideCloseButtonAccessibility: Bool
private var showBackButton: Bool
private let actionOnBackButtonTouched: (() -> ())?
private let content: Content
Expand All @@ -89,11 +91,13 @@ public struct SBBModalView<Content>: View where Content: View {
- actionOnBackButtonTouched: An optional action to be performed open touch events on the back button.
- content: A custom VIew to be shown underneath the title.
*/
public init(title: Text, style: Style = .full, titleAlignment: SBBModalViewTitleAlignment = .leading, isPresented: Binding<Bool>, showBackButton: Bool = false, actionOnBackButtonTouched: (() -> ())? = nil, @ViewBuilder content: @escaping () -> Content) {
public init(title: Text, style: Style = .full, titleAlignment: SBBModalViewTitleAlignment = .leading, isPresented: Binding<Bool>, closeButtonAccessibilityText: Text? = nil, hideCloseButtonAccessibility: Bool = false, showBackButton: Bool = false, actionOnBackButtonTouched: (() -> ())? = nil, @ViewBuilder content: @escaping () -> Content) {
self.title = title
self.style = style
self.titleAlignment = titleAlignment
self._isPresented = isPresented
self.closeButtonAccessibilityText = closeButtonAccessibilityText ?? Text("close".localized)
self.hideCloseButtonAccessibility = hideCloseButtonAccessibility
self.showBackButton = showBackButton
self.actionOnBackButtonTouched = actionOnBackButtonTouched
self.content = content()
Expand All @@ -115,6 +119,7 @@ public struct SBBModalView<Content>: View where Content: View {
.accessibility(label: Text("back".localized))
}
.buttonStyle(SBBIconButtonStyle(size: .small))
.accessibilitySortPriority(2)
} else if titleAlignment == .center {
Spacer()
.frame(width: 32)
Expand All @@ -126,18 +131,22 @@ public struct SBBModalView<Content>: View where Content: View {
.padding(.top, 7)
.sbbFont(.titleModul)
.accessibility(addTraits: .isHeader)
.accessibilitySortPriority(2)
Spacer()
Button(action: {
self.isPresented = false
}) {
Image(sbbName: "cross", size: .small)
.accessibility(label: Text("close".localized))
.accessibility(hidden: hideCloseButtonAccessibility)
.accessibility(label: closeButtonAccessibilityText)
.accessibilitySortPriority(2)
}
.buttonStyle(SBBIconButtonStyle(size: .small))
}
.sbbScreenPadding()
content
.padding(.bottom, style == .popup ? 16 : 0)
.accessibilitySortPriority(1)
}
.background(Color.sbbColor(.modalBackground).edgesIgnoringSafeArea(.bottom))
.cornerRadius(style != .full ? 16 : 0, corners: [.topLeft, .topRight])
Expand Down

0 comments on commit 2f8e423

Please sign in to comment.