-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aheze/feature/embed-view-into-parent
Add VoiceOver and resizing support
- Loading branch information
Showing
12 changed files
with
298 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ struct Playground: View { | |
NestedView() | ||
SelectionView() | ||
} | ||
|
||
Group { | ||
AccessibilityView() | ||
} | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
Examples/PopoversXcodeApp/PopoversXcodeApp/PlaygroundFiles/AccessibilityView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// AccessibilityView.swift | ||
// PopoversXcodeApp | ||
// | ||
// Created by A. Zheng (github.com/aheze) on 1/16/22. | ||
// Copyright © 2022 A. Zheng. All rights reserved. | ||
// | ||
|
||
import Popovers | ||
import SwiftUI | ||
|
||
struct AccessibilityView: View { | ||
@State var present = false | ||
|
||
var body: some View { | ||
ExampleRow( | ||
image: "hand.point.up.braille", | ||
title: "Accessibility", | ||
color: 0x0021FF | ||
) { | ||
present.toggle() | ||
} | ||
.popover( | ||
present: $present, | ||
attributes: { | ||
$0.accessibility.shiftFocus = false | ||
$0.accessibility.dismissButtonLabel = AnyView( | ||
Text("Tap me to dismiss!") | ||
.foregroundColor(.white) | ||
.padding() | ||
.background(Color.black.opacity(0.5)) | ||
.cornerRadius(16) | ||
) | ||
} | ||
) { | ||
VStack { | ||
VStack(alignment: .leading) { | ||
Text("Popovers has full VoiceOver support!") | ||
|
||
HStack { | ||
ExampleImage("speaker.wave.2", color: 0x0021FF) | ||
|
||
Text("By default, VoiceOver will read out the popover when it's presented. You can change this with `attributes.accessibility.shiftFocus`.") | ||
} | ||
|
||
HStack { | ||
ExampleImage("hand.thumbsup", color: 0x0021FF) | ||
|
||
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: 500) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.