Skip to content

Commit 3590cdf

Browse files
Bugfix FXIOS-13915 [New first run onboarding] [Device specific] Links in Terms of Service card are not accessible with VoiceOver (#30204)
1 parent 1744bdb commit 3590cdf

File tree

6 files changed

+27
-35
lines changed

6 files changed

+27
-35
lines changed

BrowserKit/Sources/ComponentLibrary/SwiftUI/AttributedLinkText.swift

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public struct AttributedLinkText<Action: RawRepresentable>: View where Action.Ra
1212
let action: Action
1313
let linkAction: (Action) -> Void
1414

15-
@State private var attributedString: AttributedString
16-
1715
public init(
1816
theme: Theme,
1917
fullText: String,
@@ -26,24 +24,17 @@ public struct AttributedLinkText<Action: RawRepresentable>: View where Action.Ra
2624
self.linkText = linkText
2725
self.action = action
2826
self.linkAction = linkAction
29-
30-
var attrString = AttributedString(fullText)
31-
attrString.foregroundColor = Color(uiColor: theme.colors.textSecondary)
32-
33-
let actionURL = URL(string: "action://\(action.rawValue)")!
34-
if let range = attrString.range(of: linkText) {
35-
attrString[range].underlineStyle = .single
36-
attrString[range].foregroundColor = Color(uiColor: theme.colors.actionPrimary)
37-
attrString[range].link = actionURL
38-
}
39-
40-
self._attributedString = State(initialValue: attrString)
4127
}
4228

4329
public var body: some View {
4430
Text(attributedString)
4531
.fixedSize(horizontal: false, vertical: true)
46-
.accessibilityAddTraits([.isStaticText, .isButton])
32+
.accessibilityElement(children: .combine)
33+
.accessibilityAddTraits(.isLink)
34+
.accessibilityLabel(fullText)
35+
.accessibilityAction {
36+
linkAction(action)
37+
}
4738
.font(.caption)
4839
.multilineTextAlignment(.center)
4940
.environment(\.openURL, OpenURLAction { url in
@@ -56,4 +47,18 @@ public struct AttributedLinkText<Action: RawRepresentable>: View where Action.Ra
5647
return .systemAction
5748
})
5849
}
50+
51+
private var attributedString: AttributedString {
52+
var attrString = AttributedString(fullText)
53+
attrString.foregroundColor = Color(uiColor: theme.colors.textSecondary)
54+
55+
let actionURL = URL(string: "action://\(action.rawValue)")!
56+
if let range = attrString.range(of: linkText) {
57+
attrString[range].underlineStyle = .single
58+
attrString[range].foregroundColor = Color(uiColor: theme.colors.actionPrimary)
59+
attrString[range].link = actionURL
60+
}
61+
62+
return attrString
63+
}
5964
}

BrowserKit/Sources/OnboardingKit/Preview/PreviewModel.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ extension PreviewModel {
250250
onComplete: {}
251251
),
252252
windowUUID: .DefaultUITestingUUID,
253-
themeManager: DefaultThemeManager(sharedContainerIdentifier: ""),
254-
onEmbededLinkAction: { _ in }
253+
themeManager: DefaultThemeManager(sharedContainerIdentifier: "")
255254
)
256255
}
257256

BrowserKit/Sources/OnboardingKit/Views/Common/TermsOfServiceView.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ public struct TermsOfServiceView<ViewModel: OnboardingCardInfoModelProtocol>: Vi
1212
private var horizontalSizeClass
1313
let windowUUID: WindowUUID
1414
var themeManager: ThemeManager
15-
public let onEmbededLinkAction: (TosAction) -> Void
1615

1716
public init(
1817
viewModel: TosFlowViewModel<ViewModel>,
1918
windowUUID: WindowUUID,
20-
themeManager: ThemeManager,
21-
onEmbededLinkAction: @escaping (TosAction) -> Void
19+
themeManager: ThemeManager
2220
) {
2321
self._viewModel = StateObject(wrappedValue: viewModel)
2422
self.windowUUID = windowUUID
2523
self.themeManager = themeManager
26-
self.onEmbededLinkAction = onEmbededLinkAction
2724
}
2825

2926
// MARK: - Body
@@ -43,8 +40,7 @@ public struct TermsOfServiceView<ViewModel: OnboardingCardInfoModelProtocol>: Vi
4340
TermsOfServiceRegularView(
4441
viewModel: viewModel,
4542
windowUUID: windowUUID,
46-
themeManager: themeManager,
47-
onEmbededLinkAction: onEmbededLinkAction
43+
themeManager: themeManager
4844
)
4945
}
5046

@@ -53,8 +49,7 @@ public struct TermsOfServiceView<ViewModel: OnboardingCardInfoModelProtocol>: Vi
5349
TermsOfServiceCompactView(
5450
viewModel: viewModel,
5551
windowUUID: windowUUID,
56-
themeManager: themeManager,
57-
onEmbededLinkAction: onEmbededLinkAction
52+
themeManager: themeManager
5853
)
5954
}
6055
}

BrowserKit/Sources/OnboardingKit/Views/TermsOfServiceView/TermsOfServiceCompactView.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ public struct TermsOfServiceCompactView<ViewModel: OnboardingCardInfoModelProtoc
1111
@StateObject private var viewModel: TosFlowViewModel<ViewModel>
1212
public let windowUUID: WindowUUID
1313
public var themeManager: ThemeManager
14-
public let onEmbededLinkAction: (TosAction) -> Void
1514

1615
public init(
1716
viewModel: TosFlowViewModel<ViewModel>,
1817
windowUUID: WindowUUID,
19-
themeManager: ThemeManager,
20-
onEmbededLinkAction: @escaping (TosAction) -> Void
18+
themeManager: ThemeManager
2119
) {
2220
self._viewModel = StateObject(wrappedValue: viewModel)
2321
self.windowUUID = windowUUID
2422
self.themeManager = themeManager
25-
self.onEmbededLinkAction = onEmbededLinkAction
2623
self.theme = themeManager.getCurrentTheme(for: windowUUID)
2724
}
2825

BrowserKit/Sources/OnboardingKit/Views/TermsOfServiceView/TermsOfServiceRegularView.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ public struct TermsOfServiceRegularView<ViewModel: OnboardingCardInfoModelProtoc
1111
@StateObject private var viewModel: TosFlowViewModel<ViewModel>
1212
public let windowUUID: WindowUUID
1313
public var themeManager: ThemeManager
14-
public let onEmbededLinkAction: (TosAction) -> Void
1514

1615
public init(
1716
viewModel: TosFlowViewModel<ViewModel>,
1817
windowUUID: WindowUUID,
19-
themeManager: ThemeManager,
20-
onEmbededLinkAction: @escaping (TosAction) -> Void
18+
themeManager: ThemeManager
2119
) {
2220
self._viewModel = StateObject(wrappedValue: viewModel)
2321
self.windowUUID = windowUUID
2422
self.themeManager = themeManager
25-
self.onEmbededLinkAction = onEmbededLinkAction
2623
self.theme = themeManager.getCurrentTheme(for: windowUUID)
2724
}
2825

firefox-ios/Client/Coordinators/Launch/LaunchCoordinator.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ final class LaunchCoordinator: BaseCoordinator,
173173
let view = TermsOfServiceView(
174174
viewModel: viewModel,
175175
windowUUID: windowUUID,
176-
themeManager: themeManager,
177-
onEmbededLinkAction: { _ in }
176+
themeManager: themeManager
178177
)
179178

180179
let viewController = PortraitOnlyHostingController(rootView: view)

0 commit comments

Comments
 (0)