Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dismiss gesture guide #20

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Accessibility Handbook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
3F25391328DBE05A00B089EA /* CircularProgressionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F25391228DBE05A00B089EA /* CircularProgressionView.swift */; };
3F41C11728E49CBB0092CF28 /* UIFontMetricsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F41C11628E49CBB0092CF28 /* UIFontMetricsPage.swift */; };
3F41C11928E4A4BB0092CF28 /* AdjustLayoutToScaledFontPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F41C11828E4A4BB0092CF28 /* AdjustLayoutToScaledFontPage.swift */; };
3F41C11B28E5F0D60092CF28 /* DismissPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F41C11A28E5F0D60092CF28 /* DismissPage.swift */; };
3F41C11D28E5FC980092CF28 /* DismissGesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F41C11C28E5FC980092CF28 /* DismissGesture.swift */; };
3F41DB0E28E2553E00E0B056 /* HorizontalSwipe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F41DB0D28E2553E00E0B056 /* HorizontalSwipe.swift */; };
3F4E7F8828DC97E100710F18 /* ContentHierarchySection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E7F8728DC97E100710F18 /* ContentHierarchySection.swift */; };
3F4E7F8B28DC980700710F18 /* ModalViewPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F4E7F8A28DC980700710F18 /* ModalViewPage.swift */; };
Expand Down Expand Up @@ -131,6 +133,8 @@
3F25391228DBE05A00B089EA /* CircularProgressionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressionView.swift; sourceTree = "<group>"; };
3F41C11628E49CBB0092CF28 /* UIFontMetricsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFontMetricsPage.swift; sourceTree = "<group>"; };
3F41C11828E4A4BB0092CF28 /* AdjustLayoutToScaledFontPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdjustLayoutToScaledFontPage.swift; sourceTree = "<group>"; };
3F41C11A28E5F0D60092CF28 /* DismissPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissPage.swift; sourceTree = "<group>"; };
3F41C11C28E5FC980092CF28 /* DismissGesture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissGesture.swift; sourceTree = "<group>"; };
3F41DB0D28E2553E00E0B056 /* HorizontalSwipe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalSwipe.swift; sourceTree = "<group>"; };
3F4E7F8728DC97E100710F18 /* ContentHierarchySection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentHierarchySection.swift; sourceTree = "<group>"; };
3F4E7F8A28DC980700710F18 /* ModalViewPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalViewPage.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -264,6 +268,7 @@
3FC3E5EE28E3334A00B7C0D7 /* MultiTap.swift */,
3F6C5AB928E3748A00B12065 /* MultiFingerSwipe.swift */,
3F6C5ABB28E37FED00B12065 /* MultiFingerTap.swift */,
3F41C11C28E5FC980092CF28 /* DismissGesture.swift */,
);
path = Gestures;
sourceTree = "<group>";
Expand All @@ -282,6 +287,7 @@
children = (
3F4E7F8A28DC980700710F18 /* ModalViewPage.swift */,
3F4E7F8C28DC981700710F18 /* GroupingPage.swift */,
3F41C11A28E5F0D60092CF28 /* DismissPage.swift */,
);
path = Pages;
sourceTree = "<group>";
Expand Down Expand Up @@ -801,6 +807,7 @@
3FF4A29128DF540D005D291A /* SyntaxHighlight.swift in Sources */,
3FBF058F28DA9E3E00DA5BF5 /* ActivatePage.swift in Sources */,
3F4E7F9128DCA6AC00710F18 /* ChangeCursorPositionPage.swift in Sources */,
3F41C11B28E5F0D60092CF28 /* DismissPage.swift in Sources */,
3FC73ECE28DDDFB900D89F64 /* TheUpsideDown.swift in Sources */,
3F25390F28DBCF1200B089EA /* SecretActions.swift in Sources */,
3FBF059128DA9E4600DA5BF5 /* LongPressPage.swift in Sources */,
Expand All @@ -822,6 +829,7 @@
3FBF05E628DB639300DA5BF5 /* InvertColorsPage.swift in Sources */,
3F6C5ABC28E37FED00B12065 /* MultiFingerTap.swift in Sources */,
3FBF05E428DB602000DA5BF5 /* NotifyScreenChangesPage.swift in Sources */,
3F41C11D28E5FC980092CF28 /* DismissGesture.swift in Sources */,
3FF4A29D28DF93F3005D291A /* String+Extensions.swift in Sources */,
3FBF05A228DAB94800DA5BF5 /* GameCell.swift in Sources */,
3FBF059528DA9E5500DA5BF5 /* CustomActionsPage.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct ContentHierarchySectionSection: Section {
let title: String = L10n.contentHiererachy
let pages: [Page] = [
ModalViewPage(),
GroupingPage()
GroupingPage(),
DismissPage()
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// DismissPage.swift
// Accessibility Handbook
//
// Created by Giovani Nascimento Pereira on 29/09/22.
//

import SwiftUI

struct DismissPage: View, Page {
let title: String = L10n.DismissPage.title

var body: some View {
PageContent(next: nil) {
Group {
intro
handling
}
.toAny()
}
}
}

private extension DismissPage {
var intro: some View {
Group {
Text(L10n.DismissPage.text1)
VerticalSpace(.regular)
DismissGesture()
.frame(width: nil, height: 100.0)
VerticalSpace(.regular)
Comment(L10n.DismissPage.comment1)
InternalLink(page: GesturesPage().page, title: L10n.Navigation.gesturesLink)
}
}

var handling: some View {
Group {
Text(L10n.DismissPage.Handle.text1)
Code.uikit(
"""
override func accessibilityPerformEscape() -> Bool {
// Handle escape
// Returns true if the content was dismissed
return true
}
"""
)
Text(L10n.DismissPage.Handle.text2)
Code.swiftUI(
"""
View()
.accessibilityAction(.escape) {
// Handle escape
}
"""
)
DocButton(link: "https://developer.apple.com/documentation/objectivec/nsobject/1615091-accessibilityperformescape", title: title)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct GroupingPage: View, Page {
let title: String = L10n.Grouping.title

var body: some View {
PageContent(next: nil) {
PageContent(next: DismissPage()) {
Group {
content
VerticalSpace(.large)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ private extension GesturesPage {
animation: ThreeFingerSwipeDown().toAny(),
description: L10n.Gestures.ThreeFingersSwipeDown.description
)
item(
title: L10n.Gesture.dismiss,
animation: DismissGesture().toAny(),
description: L10n.Gestures.Dismiss.description
)
}
}

Expand Down
21 changes: 21 additions & 0 deletions Accessibility Handbook/Strings/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,21 @@ internal enum L10n {
}
}

internal enum DismissPage {
/// Try it out! Enable the VoiceOver and perform a 'Z' with 2 fingers.
internal static let comment1 = L10n.tr("Localizable", "DismissPage.comment1")
/// The VoiceOver has a dedicated 'dismiss gesture', the Escape, which is used to close modals or pop the current view on the navigation stack.
internal static let text1 = L10n.tr("Localizable", "DismissPage.text1")
/// Escape
internal static let title = L10n.tr("Localizable", "DismissPage.title")
internal enum Handle {
/// On UIKit, you can add a custom handling to this gesture by implementing the 'perform escape' method.
internal static let text1 = L10n.tr("Localizable", "DismissPage.Handle.text1")
/// On SwiftUI, it's the same as adding a 'Magic Tap' action, but using the escape type.
internal static let text2 = L10n.tr("Localizable", "DismissPage.Handle.text2")
}
}

internal enum DynamicFonts {
/// Implementing Dynamic Fonts
internal static let implementing = L10n.tr("Localizable", "DynamicFonts.implementing")
Expand Down Expand Up @@ -893,6 +908,8 @@ internal enum L10n {
internal static func accessible(_ p1: Any) -> String {
return L10n.tr("Localizable", "Gesture.accessible", String(describing: p1))
}
/// 'Z' with 2 fingers.
internal static let dismiss = L10n.tr("Localizable", "Gesture.dismiss")
/// Double Tap
internal static let doubleTap = L10n.tr("Localizable", "Gesture.doubleTap")
/// Four fingers double tap.
Expand Down Expand Up @@ -942,6 +959,10 @@ internal enum L10n {
internal static let text1 = L10n.tr("Localizable", "Gestures.text1")
/// Gestures Guide
internal static let title = L10n.tr("Localizable", "Gestures.title")
internal enum Dismiss {
/// Gesture to dismiss modals and pop to preview view on navigation stack.
internal static let description = L10n.tr("Localizable", "Gestures.dismiss.description")
}
internal enum DoubleTap {
/// Activate element, the same as tapping it when the VoicOver is disabled.
internal static let description = L10n.tr("Localizable", "Gestures.doubleTap.description")
Expand Down
11 changes: 11 additions & 0 deletions Accessibility Handbook/Strings/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@
"Gestures.fourFingersDoubleTap.description" = "Start/Stop gesture helper. When enabled, it will tell every gesture performed and what it does.";
"Gestures.helper" = "Gesture Helper";
"Gestures.reading" = "Reading";
"Gestures.dismiss.description" = "Gesture to dismiss modals and pop to preview view on navigation stack.";

"Gesture.swipeRight" = "Swipe Right";
"Gesture.swipeLeft" = "Swipe Left";
Expand All @@ -797,6 +798,7 @@
"Gesture.threeFingersDoubleTap" = "Three fingers double tap";
"Gesture.threeFingersTripleTap" = "Three fingers triple tap";
"Gesture.fourFingersDoubleTap" = "Four fingers double tap.";
"Gesture.dismiss" = "'Z' with 2 fingers.";

"Gesture.accessible" = "Animation representing the gesture for %@";

Expand Down Expand Up @@ -890,3 +892,12 @@
"AdjustLayoutToScaledFontPage.Example.title" = "Content title";
"AdjustLayoutToScaledFontPage.Example.body" = "Content body some content";
"AdjustLayoutToScaledFontPage.Example.description" = "Content description";

// Dismiss

"DismissPage.title" = "Escape";
"DismissPage.text1" = "The VoiceOver has a dedicated 'dismiss gesture', the Escape, which is used to close modals or pop the current view on the navigation stack.";
"DismissPage.comment1" = "Try it out! Enable the VoiceOver and perform a 'Z' with 2 fingers.";

"DismissPage.Handle.text1" = "On UIKit, you can add a custom handling to this gesture by implementing the 'perform escape' method.";
"DismissPage.Handle.text2" = "On SwiftUI, it's the same as adding a 'Magic Tap' action, but using the escape type.";
11 changes: 11 additions & 0 deletions Accessibility Handbook/Strings/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@
"Gestures.fourFingersDoubleTap.description" = "Ajuda de Gestos. Quando ativo, irá descrever cada gesto performado.";
"Gestures.helper" = "Ajuda de gestos";
"Gestures.reading" = "Leitura";
"Gestures.dismiss.description" = "Gesto de fechar conteúdo. Fecha modais ou volta pra página anterior na navegação.";

"Gesture.swipeRight" = "Swipe para direita";
"Gesture.swipeLeft" = "Swipe para esquerda";
Expand All @@ -797,6 +798,7 @@
"Gesture.threeFingersDoubleTap" = "Toque duplo com 3 dedos";
"Gesture.threeFingersTripleTap" = "Toque triplo com 3 dedos";
"Gesture.fourFingersDoubleTap" = "Toque duplo com 4 dedos";
"Gesture.dismiss" = "'Z' with 2 fingers.";

"Gesture.accessible" = "Animation representing the gesture for %@";

Expand Down Expand Up @@ -890,3 +892,12 @@
"AdjustLayoutToScaledFontPage.Example.title" = "Título do conteúdo";
"AdjustLayoutToScaledFontPage.Example.body" = "Corpo do texto com mais conteúdo";
"AdjustLayoutToScaledFontPage.Example.description" = "Descrição aqui embaixo";

// Dismiss

"DismissPage.title" = "Escape";
"DismissPage.text1" = "O VoiceOver tem um gesto dedicado para fechar Modais e outros conteúdos: O 'Ecape'.";
"DismissPage.comment1" = "Você pode tentar executar esse gesto aqui mesmo! Faça um 'Z' com 2 dedos na tela.";

"DismissPage.Handle.text1" = "No UIKit, você pode adicionar um tratamento customizado implementando o método de 'perform escape'.";
"DismissPage.Handle.text2" = "Já em SwiftUI, é a mesma maneira de adicionar um 'Magic Tap', mas usando o tipo `escape`.";
Loading