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,25 +26,31 @@ struct DinoGameWidgetEntryView: View { ...@@ -26,25 +26,31 @@ 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 {
ZStack { // We wrap this widget in a link on top of using `widgetUrl` so that the voice over will treat
Image(redactionReasons.isEmpty ? background : backgroundPlaceholder) // the widget as one tap target. Without the wrapping, voice over treats the content within
.resizable() // the widget as multiple tap targets.
.unredacted() Link(destination: WidgetConstants.DinoGameWidget.url) {
VStack(alignment: .leading, spacing: 0) { ZStack {
Spacer() Image(redactionReasons.isEmpty ? background : backgroundPlaceholder)
.frame(minWidth: 0, maxWidth: .infinity) .resizable()
HStack { .unredacted()
Text("IDS_IOS_WIDGET_KIT_EXTENSION_GAME_TITLE") VStack(alignment: .leading, spacing: 0) {
.foregroundColor(Color("widget_text_color"))
.fontWeight(.semibold)
.font(.subheadline)
.lineLimit(1)
Spacer() Spacer()
.frame(minWidth: 0, maxWidth: .infinity)
HStack {
Text("IDS_IOS_WIDGET_KIT_EXTENSION_GAME_TITLE")
.foregroundColor(Color("widget_text_color"))
.fontWeight(.semibold)
.font(.subheadline)
.lineLimit(1)
Spacer()
}
.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,36 +24,40 @@ struct SearchWidgetEntryView: View { ...@@ -24,36 +24,40 @@ struct SearchWidgetEntryView: View {
var entry: Provider.Entry var entry: Provider.Entry
var body: some View { var body: some View {
ZStack { // We wrap this widget in a link on top of using `widgetUrl` so that the voice over will treat
Color("widget_background_color") // the widget as one tap target. Without the wrapping, voice over treats the content within
.unredacted() // the widget as multiple tap targets.
VStack(alignment: .leading, spacing: 0) { Link(destination: WidgetConstants.SearchWidget.url) {
ZStack { ZStack {
RoundedRectangle(cornerRadius: 26) Color("widget_background_color")
.frame(height: 52) .unredacted()
.foregroundColor(Color("widget_search_bar_color")) VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 0) { ZStack {
Image("widget_chrome_logo") RoundedRectangle(cornerRadius: 26)
.clipShape(Circle()) .frame(height: 52)
.padding(.leading, 8) .foregroundColor(Color("widget_search_bar_color"))
.unredacted() HStack(spacing: 0) {
Spacer() Image("widget_chrome_logo")
.clipShape(Circle())
.padding(.leading, 8)
.unredacted()
Spacer()
}
} }
.frame(minWidth: 0, maxWidth: .infinity)
.padding([.leading, .trailing], 11)
.padding(.top, 16)
Spacer()
Text("IDS_IOS_WIDGET_KIT_EXTENSION_SEARCH_TITLE")
.foregroundColor(Color("widget_text_color"))
.fontWeight(.semibold)
.font(.subheadline)
.padding([.leading, .bottom, .trailing], 16)
} }
.frame(minWidth: 0, maxWidth: .infinity)
.padding([.leading, .trailing], 11)
.padding(.top, 16)
Spacer()
Text("IDS_IOS_WIDGET_KIT_EXTENSION_SEARCH_TITLE")
.foregroundColor(Color("widget_text_color"))
.fontWeight(.semibold)
.font(.subheadline)
.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