Skip to content

Commit

Permalink
Add tip in accessibility view example
Browse files Browse the repository at this point in the history
  • Loading branch information
aheze committed Jan 17, 2022
1 parent fae0167 commit 6027bc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ struct AccessibilityView: View {

Text("By default, a \(Image(systemName: "xmark.circle.fill")) button will appear next to popovers when VoiceOver is on. You can customize this with `attributes.accessibility.dismissButtonLabel`.")
}

HStack {
ExampleImage.tip

Text("If you already have a button that sets `present` to `false`, remove the default dismiss button with `dismissButtonLabel = nil`.")
}
}
}
.padding()
.background(.background)
.cornerRadius(12)
.shadow(radius: 1)
.frame(maxWidth: 300)
.frame(maxWidth: 500)
}
}
}
7 changes: 5 additions & 2 deletions Sources/PopoverContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ struct PopoverContainerView: View {
/// Have VoiceOver read the popover view first, before the dismiss button.
.accessibility(sortPriority: 1)

/// If a `dismissButtonLabel` was set, show it.
if let dismissButtonLabel = popover.attributes.accessibility.dismissButtonLabel {
/// If VoiceOver is on and a `dismissButtonLabel` was set, show it.
if
UIAccessibility.isVoiceOverRunning,
let dismissButtonLabel = popover.attributes.accessibility.dismissButtonLabel
{
Button {
popover.dismiss()
} label: {
Expand Down
6 changes: 2 additions & 4 deletions Sources/PopoverGestureContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ class PopoverGestureContainer: UIView {
override func layoutSubviews() {
super.layoutSubviews()

/// Orientation or screen bounds changed. Update popover frames.
/// Orientation or screen bounds changed, so update popover frames.
popoverModel.updateFrames()
}

override func didMoveToWindow() {
super.didMoveToWindow()

/// There might not be a window yet, but that's fine. Just wait until there's actually a window.
guard let window = window else {
return
}
guard let window = window else { return }

/// Create the SwiftUI view that contains all the popovers.
let popoverContainerView = PopoverContainerView(popoverModel: popoverModel)
Expand Down

0 comments on commit 6027bc6

Please sign in to comment.