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(Snackbar): allow setting the accesibility identifier via SnackbarConfig #386

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 @@ -72,11 +72,19 @@ public enum SnackbarDismissInterval: Equatable {

public struct SnackbarConfig {
public let title: String
public let titleAccessibilityLabel: String?
public let titleAccessibilityIdentifier: String?
public let dismissInterval: SnackbarDismissInterval
public let forceDismiss: Bool

public init(title: String, dismissInterval: SnackbarDismissInterval, forceDismiss: Bool = false) {
public init(title: String,
titleAccessibilityLabel: String? = nil,
titleAccessibilityIdentifier: String? = nil,
dismissInterval: SnackbarDismissInterval,
forceDismiss: Bool = false) {
self.title = title
self.titleAccessibilityLabel = titleAccessibilityLabel
self.titleAccessibilityIdentifier = titleAccessibilityIdentifier
self.dismissInterval = dismissInterval
self.forceDismiss = forceDismiss
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/MisticaSwiftUI/Components/Snackbar/Snackbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public struct Snackbar: View {
Text(config.title)
.font(.textPreset2(weight: .regular))
.foregroundColor(.textPrimaryInverse)
.accessibilityLabel(titleAccessibilityLabel)
.accessibilityIdentifier(titleAccessibilityIdentifier)
.accessibilityLabel(config.titleAccessibilityLabel ?? titleAccessibilityLabel)
.accessibilityIdentifier(config.titleAccessibilityIdentifier ?? titleAccessibilityIdentifier)
.expandHorizontally(alignment: .leading)
if shouldShowCloseButton {
dismissView
Expand All @@ -71,8 +71,8 @@ public struct Snackbar: View {
Text(config.title)
.font(.textPreset2(weight: .regular))
.foregroundColor(.textPrimaryInverse)
.accessibilityLabel(titleAccessibilityLabel)
.accessibilityIdentifier(titleAccessibilityIdentifier)
.accessibilityLabel(config.titleAccessibilityLabel ?? titleAccessibilityLabel)
.accessibilityIdentifier(config.titleAccessibilityIdentifier ?? titleAccessibilityIdentifier)
.expandHorizontally(alignment: .leading)
alignedButton
if shouldShowCloseButton {
Expand Down
Loading