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

#I Add missing accessibility identifier and introduce new view modifier #780

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
4 changes: 4 additions & 0 deletions GliaWidgets.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
AF10ED8F29BF849A00E85309 /* UnreadMessageDividerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF10ED8E29BF849A00E85309 /* UnreadMessageDividerView.swift */; };
AF10ED9129BF85C700E85309 /* UnreadMessageDividerStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF10ED9029BF85C700E85309 /* UnreadMessageDividerStyle.swift */; };
AF11F30728BE6F0C002ACEB4 /* UIAlertController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF11F30628BE6F0C002ACEB4 /* UIAlertController+Extensions.swift */; };
AF18F1D52ABD954500121627 /* View+Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF18F1D42ABD954500121627 /* View+Accessibility.swift */; };
AF22C8852A6154780004BF3C /* AlertViewControllerLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF22C8842A6154780004BF3C /* AlertViewControllerLayoutTests.swift */; };
AF22C8872A6182AF0004BF3C /* BubbleViewLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF22C8862A6182AF0004BF3C /* BubbleViewLayoutTests.swift */; };
AF22C8892A6184C50004BF3C /* CallViewControllerLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF22C8882A6184C50004BF3C /* CallViewControllerLayoutTests.swift */; };
Expand Down Expand Up @@ -1256,6 +1257,7 @@
AF10ED8E29BF849A00E85309 /* UnreadMessageDividerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnreadMessageDividerView.swift; sourceTree = "<group>"; };
AF10ED9029BF85C700E85309 /* UnreadMessageDividerStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnreadMessageDividerStyle.swift; sourceTree = "<group>"; };
AF11F30628BE6F0C002ACEB4 /* UIAlertController+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+Extensions.swift"; sourceTree = "<group>"; };
AF18F1D42ABD954500121627 /* View+Accessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Accessibility.swift"; sourceTree = "<group>"; };
AF22C8842A6154780004BF3C /* AlertViewControllerLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertViewControllerLayoutTests.swift; sourceTree = "<group>"; };
AF22C8862A6182AF0004BF3C /* BubbleViewLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BubbleViewLayoutTests.swift; sourceTree = "<group>"; };
AF22C8882A6184C50004BF3C /* CallViewControllerLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallViewControllerLayoutTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3530,6 +3532,7 @@
isa = PBXGroup;
children = (
C06152D42AB1BC1300063BF8 /* Font+Extensions.swift */,
AF18F1D42ABD954500121627 /* View+Accessibility.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -4523,6 +4526,7 @@
845876B1282A9EAF007AC3DF /* CheckboxView.Props.Accessibility.swift in Sources */,
1A4AF5CD25AEF4A0002CD0F4 /* AlertViewController+Message.swift in Sources */,
AFCF8A5C2A02AB3000B7ABB3 /* OutgoingMessage.Mock.swift in Sources */,
AF18F1D52ABD954500121627 /* View+Accessibility.swift in Sources */,
C0D2F08F29A61A8D00803B47 /* VideoCallViewController.Mock.swift in Sources */,
1A7CA8242574D68E0047CBBE /* ConnectStatusView.swift in Sources */,
845E2F78283E2D4200C04D56 /* PoweredByStyle.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ extension SecureConversations.ConfirmationViewSwiftUI.Model {
self?.delegate?(.closeTapped)
}),
style: style.header.closeButton,
accessibilityIdentifier: "header_close_button",
isEnabled: true,
isHidden: false
)

let endScreenShareButtonProps: HeaderButtonSwiftUI.Model = .init(
style: style.header.endScreenShareButton,
accessibilityIdentifier: "header_end_screen_sharing_button",
isEnabled: false,
isHidden: true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@ struct HeaderButtonSwiftUI: View {
.accessibility(label: Text(model.style.accessibility.label))
.accessibility(addTraits: .isButton)
.accessibility(removeTraits: .isImage)
.onTapGesture(perform: model.tap.callAsFunction)
.onTapGesture(perform: model.tap.execute)
.migrationAccessibilityIdentifier(model.accessibilityIdentifier)
}
}

extension HeaderButtonSwiftUI {
final class Model: ObservableObject {
var tap: Cmd
var style: HeaderButtonStyle
var accessibilityIdentifier: String
var size: CGSize
var isEnabled: Bool
var isHidden: Bool

init(
tap: Cmd = .nop,
style: HeaderButtonStyle,
accessibilityIdentifier: String,
size: CGSize = CGSize(width: 14, height: 14),
isEnabled: Bool,
isHidden: Bool
Expand All @@ -43,6 +46,7 @@ extension HeaderButtonSwiftUI {
self.size = size
self.isEnabled = isEnabled
self.isHidden = isHidden
self.accessibilityIdentifier = accessibilityIdentifier
}
}
}
22 changes: 22 additions & 0 deletions GliaWidgets/SwiftUI/Extensions/View+Accessibility.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SwiftUI

/// Accessibility identifier view modifier for resolving between
/// deprecated and new method to specify accessibility identifier.
struct MigrationAccessibilityIdentifierModifier: ViewModifier {
let identifier: String

func body(content: Content) -> some View {
if #available(iOS 14, *) {
content.accessibilityIdentifier(identifier)
} else {
content.accessibility(identifier: identifier)
}
}
}

/// Modifier for specifying accessibility identifier for avoiding deprecation warning.
extension View {
func migrationAccessibilityIdentifier(_ identifier: String) -> some View {
self.modifier(MigrationAccessibilityIdentifierModifier(identifier: identifier))
}
}