Commit a6d77364 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][WidgetKit] A11y improvements

Add missing strings in the generated files.
Set keys type as LocalizedStringKey to enable lookups.
Wrap small widgets so they act as one whole tap target.

Bug: N/A
Change-Id: Ife034a1913d4417a71352acabf99c2f77a324d13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2539401Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Javier Flores <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827779}
parent 5389b4a8
...@@ -26,6 +26,10 @@ struct DinoGameWidgetEntryView: View { ...@@ -26,6 +26,10 @@ struct DinoGameWidgetEntryView: View {
var entry: Provider.Entry var entry: Provider.Entry
@Environment(\.redactionReasons) var redactionReasons @Environment(\.redactionReasons) var redactionReasons
var body: some View { var body: some View {
// We wrap this widget in a link on top of using `widgetUrl` so that the voice over will treat
// the widget as one tap target. Without the wrapping, voice over treats the content within
// the widget as multiple tap targets.
Link(destination: WidgetConstants.DinoGameWidget.url) {
ZStack { ZStack {
Image(redactionReasons.isEmpty ? background : backgroundPlaceholder) Image(redactionReasons.isEmpty ? background : backgroundPlaceholder)
.resizable() .resizable()
...@@ -44,7 +48,9 @@ struct DinoGameWidgetEntryView: View { ...@@ -44,7 +48,9 @@ struct DinoGameWidgetEntryView: View {
.padding([.leading, .bottom], 16) .padding([.leading, .bottom], 16)
} }
} }
}
.widgetURL(WidgetConstants.DinoGameWidget.url) .widgetURL(WidgetConstants.DinoGameWidget.url)
.accessibility(label: Text("IDS_IOS_WIDGET_KIT_EXTENSION_GAME_A11Y_LABEL")) .accessibility(
label: Text("IDS_IOS_WIDGET_KIT_EXTENSION_GAME_A11Y_LABEL"))
} }
} }
...@@ -26,11 +26,11 @@ struct QuickActionsWidgetEntryView: View { ...@@ -26,11 +26,11 @@ struct QuickActionsWidgetEntryView: View {
@Environment(\.redactionReasons) var redactionReasons @Environment(\.redactionReasons) var redactionReasons
private let searchAreaHeight: CGFloat = 92 private let searchAreaHeight: CGFloat = 92
private let separatorHeight: CGFloat = 32 private let separatorHeight: CGFloat = 32
private let incognitoA11yLabel = private let incognitoA11yLabel: LocalizedStringKey =
"IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_INCOGNITO_A11Y_LABEL" "IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_INCOGNITO_A11Y_LABEL"
private let voiceSearchA11yLabel = private let voiceSearchA11yLabel: LocalizedStringKey =
"IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_VOICE_SEARCH_A11Y_LABEL" "IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_VOICE_SEARCH_A11Y_LABEL"
private let qrA11yLabel = private let qrA11yLabel: LocalizedStringKey =
"IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_QR_SCAN_A11Y_LABEL" "IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_QR_SCAN_A11Y_LABEL"
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
...@@ -75,10 +75,10 @@ struct QuickActionsWidgetEntryView: View { ...@@ -75,10 +75,10 @@ struct QuickActionsWidgetEntryView: View {
Rectangle() Rectangle()
.foregroundColor(Color("widget_actions_row_background_color")) .foregroundColor(Color("widget_actions_row_background_color"))
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
HStack() { HStack {
// Show interactive buttons if the widget is fully loaded, and show // Show interactive buttons if the widget is fully loaded, and show
// the custom placeholder otherwise. // the custom placeholder otherwise.
if (redactionReasons.isEmpty) { if redactionReasons.isEmpty {
Link(destination: WidgetConstants.QuickActionsWidget.incognitoUrl) { Link(destination: WidgetConstants.QuickActionsWidget.incognitoUrl) {
Image("widget_incognito_icon") Image("widget_incognito_icon")
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
......
...@@ -24,6 +24,10 @@ struct SearchWidgetEntryView: View { ...@@ -24,6 +24,10 @@ struct SearchWidgetEntryView: View {
var entry: Provider.Entry var entry: Provider.Entry
var body: some View { var body: some View {
// We wrap this widget in a link on top of using `widgetUrl` so that the voice over will treat
// the widget as one tap target. Without the wrapping, voice over treats the content within
// the widget as multiple tap targets.
Link(destination: WidgetConstants.SearchWidget.url) {
ZStack { ZStack {
Color("widget_background_color") Color("widget_background_color")
.unredacted() .unredacted()
...@@ -51,9 +55,9 @@ struct SearchWidgetEntryView: View { ...@@ -51,9 +55,9 @@ struct SearchWidgetEntryView: View {
.padding([.leading, .bottom, .trailing], 16) .padding([.leading, .bottom, .trailing], 16)
} }
} }
}
.widgetURL(WidgetConstants.SearchWidget.url) .widgetURL(WidgetConstants.SearchWidget.url)
.accessibility( .accessibility(
label: Text("IDS_IOS_WIDGET_KIT_EXTENSION_SEARCH_A11Y_LABEL") label: Text("IDS_IOS_WIDGET_KIT_EXTENSION_SEARCH_A11Y_LABEL"))
)
} }
} }
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
<string>IDS_IOS_WIDGET_KIT_EXTENSION_GAME_DESCRIPTION</string> <string>IDS_IOS_WIDGET_KIT_EXTENSION_GAME_DESCRIPTION</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_GAME_DISPLAY_NAME</string> <string>IDS_IOS_WIDGET_KIT_EXTENSION_GAME_DISPLAY_NAME</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_GAME_TITLE</string> <string>IDS_IOS_WIDGET_KIT_EXTENSION_GAME_TITLE</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_VOICE_SEARCH_A11Y_LABEL</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_QR_SCAN_A11Y_LABEL</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_INCOGNITO_A11Y_LABEL</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_SEARCH_A11Y_LABEL</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_DESCRIPTION</string> <string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_DESCRIPTION</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_DISPLAY_NAME</string> <string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_DISPLAY_NAME</string>
<string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_TITLE</string> <string>IDS_IOS_WIDGET_KIT_EXTENSION_QUICK_ACTIONS_TITLE</string>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment