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

Improve accessibility for tiles view #56

Merged
merged 3 commits into from
Feb 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e",
"version" : "2.3.1"
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
},
{
"identity" : "researchkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/ResearchKit",
"state" : {
"revision" : "66f2fca769dc103de5801bb491b1d8ceafcd281e",
"version" : "2.2.23"
"revision" : "15f06cf7c1d2d22805b7b939823536bc78ad63a6",
"version" : "2.2.25"
}
},
{
"identity" : "researchkitonfhir",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordBDHG/ResearchKitOnFHIR",
"state" : {
"revision" : "ea4d9691591594177e7dfbc8c246324855d73eb5",
"version" : "1.0.1"
"revision" : "7f65fe3d94ed0bf44b681547944cc9657816edc5",
"version" : "1.1.0"
}
},
{
"identity" : "spezi",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/Spezi",
"state" : {
"revision" : "c8482d05efbd2ba93abefc309a86f7b77d10fca0",
"version" : "1.2.0"
"revision" : "0ced3efbc2af9513c07ac913ad762c773a00a6c8",
"version" : "1.2.1"
}
},
{
Expand Down Expand Up @@ -203,8 +203,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziQuestionnaire.git",
"state" : {
"revision" : "fac0bb02f7027b4c09bd7afdad55eb7b47ec67f3",
"version" : "1.0.1"
"revision" : "f25580e95bfdad02383980dcb94406cf97b08ea8",
"version" : "1.0.2"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions NAMS/Patients/CurrentPatientLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct CurrentPatientLabel: View {
.accessibilityHidden(true)
}
.foregroundColor(.primary)
.accessibilityAddTraits(.isHeader)
}

@ViewBuilder private var selectPatientText: some View {
Expand Down
1 change: 1 addition & 0 deletions NAMS/Patients/PatientInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct PatientInformation: View {
.listRowBackground(Color.clear)
.accessibilityRepresentation {
Text(verbatim: name)
.accessibilityAddTraits(.isHeader)
}

if let note = patient.note {
Expand Down
4 changes: 4 additions & 0 deletions NAMS/Patients/Tasks/ScreeningTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ struct ScreeningTask: PatientTask {
let tileType: TileType = .questionnaire
let expectedCompletionMinutes: String

var expectedCompletionMinutesSpoken: String {
expectedCompletionMinutes.replacingOccurrences(of: "-", with: " to ")
}

init(
id: String,
title: LocalizedStringResource,
Expand Down
3 changes: 3 additions & 0 deletions NAMS/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,9 @@
}
}
}
},
"takes %@ min" : {

},
"The Modified Checklist for Autism in Toddlers, Revised with Follow-Up." : {
"localizations" : {
Expand Down
18 changes: 7 additions & 11 deletions NAMS/Tiles/MeasurementTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ struct MeasurementTile: View {
.foregroundColor(.secondary)
.font(.subheadline)
.multilineTextAlignment(.center)
.accessibilityLabel("takes \(task.expectedCompletionMinutes) min")
} footer: {
tileDescription
} action: {
presentingEEGRecording = true
} actionLabel: {
Text("Start \(task.tileType.localizedStringResource)")
}
.tint(.pink)
.disabled(task.requiresConnectedDevice && !deviceConnected)
}
}

Expand All @@ -68,17 +75,6 @@ struct MeasurementTile: View {
.padding([.leading, .trailing])
.accessibilityLabel(Text(label))
}

Button(action: {
presentingEEGRecording = true
}) {
Text("Start \(task.tileType.localizedStringResource)")
.frame(maxWidth: .infinity, minHeight: 30)
}
.buttonStyle(.borderedProminent)
.padding(.top, 8)
.tint(.pink)
.disabled(task.requiresConnectedDevice && !deviceConnected)
}


Expand Down
15 changes: 5 additions & 10 deletions NAMS/Tiles/ScreeningTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,12 @@ struct ScreeningTile: View {
} footer: {
Text(task.description)
.font(.callout)

Button(action: {
presentingItem = task.questionnaire
}) {
Text("Start \(task.tileType.localizedStringResource)")
.frame(maxWidth: .infinity, minHeight: 30)
}
.buttonStyle(.borderedProminent)
.padding(.top, 8)
.tint(.mint)
} action: {
presentingItem = task.questionnaire
} actionLabel: {
Text("Start \(task.tileType.localizedStringResource)")
}
.tint(.mint)
}
}

Expand Down
1 change: 1 addition & 0 deletions NAMS/Tiles/ScreeningTileHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct ScreeningTileHeader: View {
}

Text("\(task.expectedCompletionMinutes) min", comment: "Expected task completion in minutes.")
.accessibilityLabel("takes \(task.expectedCompletionMinutesSpoken) min")
}
.font(.subheadline)
.foregroundColor(.secondary)
Expand Down
73 changes: 63 additions & 10 deletions NAMS/Tiles/SimpleTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,86 @@
import SwiftUI


struct SimpleTile<Header: View, Footer: View>: View {
struct SimpleTile<Header: View, Footer: View, ActionLabel: View>: View {
private struct Action {
let action: () -> Void
let label: ActionLabel
}

private let alignment: HorizontalAlignment
private let header: Header
private let footer: Footer
private let action: Action?

var body: some View {
VStack(alignment: alignment) {
header
tileLabel

if Footer.self != EmptyView.self {
Divider()
.padding(.bottom, 4)

footer
if let action {
Button(action: action.action) {
action.label
.frame(maxWidth: .infinity, minHeight: 30)
}
.buttonStyle(.borderedProminent)
.padding(.top, 8)
}
}
.containerShape(Rectangle())
#if !TEST // it's easier to UI test for us without the accessibility representation
.accessibilityRepresentation {
if let action {
Button(action: action.action) {
tileLabel
}
} else {
tileLabel
.accessibilityElement(children: .combine)
}
}
#endif
}

init(
alignment: HorizontalAlignment = .leading,

@ViewBuilder var tileLabel: some View {
header

if Footer.self != EmptyView.self || Action.self != EmptyView.self {
Divider()
.padding(.bottom, 4)
}

footer
}

private init(
alignment: HorizontalAlignment,
@ViewBuilder header: () -> Header,
@ViewBuilder footer: () -> Footer = { EmptyView() }
@ViewBuilder footer: () -> Footer,
action: Action?
) {
self.alignment = alignment
self.header = header()
self.footer = footer()
self.action = action
}


init(
alignment: HorizontalAlignment = .leading,
@ViewBuilder header: () -> Header,
@ViewBuilder footer: () -> Footer = { EmptyView() },

Check warning on line 79 in NAMS/Tiles/SimpleTile.swift

View check run for this annotation

Codecov / codecov/patch

NAMS/Tiles/SimpleTile.swift#L79

Added line #L79 was not covered by tests
action: @escaping () -> Void,
@ViewBuilder actionLabel: () -> ActionLabel
) {
self.init(alignment: alignment, header: header, footer: footer, action: Action(action: action, label: actionLabel()))
}

init(
alignment: HorizontalAlignment = .leading,
@ViewBuilder header: () -> Header,
@ViewBuilder footer: () -> Footer = { EmptyView() }

Check warning on line 89 in NAMS/Tiles/SimpleTile.swift

View check run for this annotation

Codecov / codecov/patch

NAMS/Tiles/SimpleTile.swift#L89

Added line #L89 was not covered by tests
) where ActionLabel == EmptyView {
self.init(alignment: alignment, header: header, footer: footer, action: nil)
}
}

Expand Down
2 changes: 1 addition & 1 deletion NAMSUITests/QuestionnaireTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QuestionnaireTests: XCTestCase {

XCTAssertTrue(app.staticTexts["SCREENING"].waitForExistence(timeout: 2.0))
XCTAssertTrue(app.staticTexts["M-CHAT R/F"].waitForExistence(timeout: 0.5))
XCTAssertTrue(app.staticTexts["Questionnaire, 5-10 min"].waitForExistence(timeout: 0.5))
XCTAssertTrue(app.staticTexts["Questionnaire, takes 5 to 10 min"].waitForExistence(timeout: 0.5))

XCTAssertTrue(app.buttons["Start Questionnaire"].waitForExistence(timeout: 0.5))
app.buttons["Start Questionnaire"].tap()
Expand Down
Loading