Skip to content

Commit

Permalink
add A11y (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: Oguz Yuksel <oguz.yueksel@teufel.de>
  • Loading branch information
OguzYuuksel and Oguz Yuksel authored May 3, 2023
1 parent 9dbbdf2 commit 550f4fa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright © 2023 Lautsprecher Teufel GmbH. All rights reserved.

public protocol AccessibilityIdentifiable: TypePathConvertible { }
28 changes: 28 additions & 0 deletions Sources/FoundationExtensions/A11y/AccessibilityIdentifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright © 2023 Lautsprecher Teufel GmbH. All rights reserved.

/// A namespace for accessibility identifiers.
///
/// You could declare A11Y IDs like this
/// ```
/// extension AccessibilityIdentifier {
/// enum HomeScreen: AccessibilityIdentifiable {
/// enum MusicView: AccessibilityIdentifiable {
/// case sectionHeader
/// case recentlyPlayedScrollview
/// }
///
/// enum MiniPlayer: AccessibilityIdentifiable {
/// case muteButton
/// case coverImage
/// }
/// }
/// }
/// ```
/// Thanks to the TypePathConvertible conformance, you can use it on your views:
/// ```
/// Text("Podcasts")
/// .accessibilityIdentifier(AccessibilityIdentifier.HomeScreen.MusicView.sectionHeader.typePath)
/// ```
/// which adds the A11Y ID "MyApp.AccessibilityIdentifier.HomeScreen.MusicView.sectionHeader" to the View.
///
public enum AccessibilityIdentifier: AccessibilityIdentifiable { }

0 comments on commit 550f4fa

Please sign in to comment.