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

feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-2707]RatingControl: accessibility updates #801

Merged
merged 1 commit into from
Sep 16, 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 @@ -51,7 +51,7 @@ public extension RatingControl {
}

internal static func getAccessibilityLabelString(_ rating: Int, ratingBounds: ClosedRange<Int>) -> String {
let labelFormat = NSLocalizedString("%d out of %d stars", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
let labelFormat = NSLocalizedString("Rating Control %d of %d", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: labelFormat, rating, ratingBounds.count - 1)
}
}
Expand Down Expand Up @@ -184,4 +184,42 @@ extension RatingControlConfiguration {
return self.ratingBounds.lowerBound + n
}
}

func getAccessbilityLabelString() -> String {
switch ratingControlStyle {
case .editable, .editableDisabled:
let format = NSLocalizedString("Rating Control %d of %d", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: format, rating, ratingBounds.count - 1)
default:
// read-only
if let averageRating {
if let reviewCount {
if let reviewCountCeiling, reviewCount > reviewCountCeiling {
// review count > review count ceiling
let format = NSLocalizedString("Rating Control, average rating %.1f of %d, %d plus reviews", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: format, averageRating, ratingBounds.count - 1, reviewCountCeiling)
} else {
// review count < review count ceiling
let format = NSLocalizedString("Rating Control, average rating %.1f of %d, %d reviews", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: format, averageRating, ratingBounds.count - 1, reviewCount)
}
} else {
// no review count
let format = NSLocalizedString("Rating Control, average rating %.1f of %d", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: format, averageRating, ratingBounds.count - 1)
}
} else {
// no average rating
if let reviewCount {
// has review count
let format = NSLocalizedString("Rating Control, rating %d of %d, %d reviews", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: format, rating, ratingBounds.count - 1, reviewCount)
} else {
// no review count
let format = NSLocalizedString("Rating Control %d of %d", tableName: "FioriSwiftUICore", bundle: Bundle.accessor, comment: "")
return String(format: format, rating, ratingBounds.count - 1)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public struct RatingControlFormViewBaseStyle: RatingControlFormViewStyle {
}
}
}
.disabled(configuration.ratingControlStyle == .editableDisabled)
}

func setRatingValue(_ configuration: RatingControlFormViewConfiguration, newRating: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct RatingControlBaseStyle: RatingControlStyle {
}
)
.accessibilityElement()
.accessibilityLabel(self.getAccessibilityLabel(configuration))
.accessibilityLabel(configuration.getAccessbilityLabelString())
.setAccessibilityAdjustable(configuration.ratingControlStyle == .editable) { direction in
if configuration.ratingControlStyle == .editable {
switch direction {
Expand All @@ -39,6 +39,7 @@ public struct RatingControlBaseStyle: RatingControlStyle {
}
}
}
.disabled(configuration.ratingControlStyle == .editableDisabled)
}

@ViewBuilder func getMainBody(_ configuration: RatingControlConfiguration) -> some View {
Expand Down Expand Up @@ -111,14 +112,10 @@ public struct RatingControlBaseStyle: RatingControlStyle {
func setRatingValue(_ configuration: RatingControlConfiguration, newRating: Int) {
if configuration.rating != newRating {
configuration.rating = newRating
UIAccessibility.post(notification: .announcement, argument: self.getAccessibilityLabel(configuration))
UIAccessibility.post(notification: .announcement, argument: RatingControl.getAccessibilityLabelString(newRating, ratingBounds: configuration.ratingBounds))
}
}

func getAccessibilityLabel(_ configuration: RatingControlConfiguration) -> String {
RatingControl.getAccessibilityLabelString(configuration.rating, ratingBounds: configuration.ratingBounds)
}

func getReadOnly(_ configuration: RatingControlConfiguration) -> Bool {
switch configuration.ratingControlStyle {
case .editable, .editableDisabled:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/* XMSG: Placeholder text in chart when there is no data */
"No Data" = "No Data";

Check warning on line 2 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "No Data" is unused (unused)

/* XBUT: Save action in inline signature form cell, see https://experience.sap.com/fiori-design-ios/article/in-line-signature-form-cell/#behavior-and-interaction */
"Save" = "Save";

Check warning on line 5 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Save" is unused (unused)

/* XBUT: Re-enter action available in saved state of inline signature form cell, see https://experience.sap.com/fiori-design-ios/article/in-line-signature-form-cell/#behavior-and-interaction */
"Re-enter Signature" = "Re-enter Signature";

Check warning on line 8 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Re-enter Signature" is unused (unused)

/* XBUT: Clear action of inline signature form cell, see https://experience.sap.com/fiori-design-ios/article/in-line-signature-form-cell/#behavior-and-interaction */
"Clear" = "Clear";

Check warning on line 11 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Clear" is unused (unused)

/* XBUT: Cancel action of inline signature form cell, see https://experience.sap.com/fiori-design-ios/article/in-line-signature-form-cell/#behavior-and-interaction */
"Cancel" = "Cancel";

Check warning on line 14 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Cancel" is unused (unused)

/* XTIT: Title of inline signature form cell, see https://experience.sap.com/fiori-design-ios/article/in-line-signature-form-cell/#behavior-and-interaction */
"Signature" = "Signature";

Check warning on line 17 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Signature" is unused (unused)

/* XBUT: Action available in inactive state of inline signature form cell, see https://experience.sap.com/fiori-design-ios/article/in-line-signature-form-cell/#behavior-and-interaction */
"Tap to Sign" = "Tap to Sign";

Check warning on line 20 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Tap to Sign" is unused (unused)

/* XACT: The accessibility label for the signature area */
"Signature Area" = "Signature Area";

Check warning on line 23 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Signature Area" is unused (unused)

/* XACT: The accessibility hint for the signature area */
"Double tap and drag to sign" = "Double tap and drag to sign";

Check warning on line 26 in Sources/FioriSwiftUICore/_localization/en.lproj/FioriSwiftUICore.strings

View workflow job for this annotation

GitHub Actions / LocalizableTextCommentsCheck

Unused Violation: Localized string "Double tap and drag to sign" is unused (unused)

/* XACT: The accessibility label for the signature image */
"Signature Image" = "Signature Image";
Expand Down Expand Up @@ -201,3 +201,18 @@

/* XFLD: RatingControl review count over ceiling format */
"%d+ reviews" = "%d+ reviews";

/* XACT: RatingControl accessibility label */
"Rating Control %d of %d" = "Rating Control %d of %d";

/* XACT: read-only RatingControl accessibility label: rating with review count */
"Rating Control, rating %d of %d, %d reviews" = "Rating Control, rating %d of %d, %d reviews";

/* XACT: read-only RatingControl accessibility label: average rating only */
"Rating Control, average rating %.1f of %d" = "Rating Control, average rating %.1f of %d";

/* XACT: read-only RatingControl accessibility label: average rating with review count */
"Rating Control, average rating %.1f of %d, %d reviews" = "Rating Control, average rating %.1f of %d, %d reviews";

/* XACT: read-only RatingControl accessibility label: average rating with review count over ceiling */
"Rating Control, average rating %.1f of %d, %d plus reviews" = "Rating Control, average rating %.1f of %d, %d plus reviews";
Loading