Fix accessibility label for VoiceMessageButton

This commit is contained in:
Alfonso Grillo 2023-11-03 16:04:03 +01:00 committed by Alfonso Grillo
parent 5823af6a91
commit 1780b58e58

View File

@ -56,6 +56,7 @@ struct VoiceMessageButton: View {
.buttonStyle(VoiceMessageButtonStyle())
.disabled(state == .loading)
.background(Circle().foregroundColor(.compound.bgCanvasDefault))
.accessibilityLabel(accessibilityLabel)
}
@ViewBuilder
@ -65,7 +66,6 @@ struct VoiceMessageButton: View {
ProgressView()
case .playing, .paused:
let imageAsset = state == .playing ? Asset.Images.mediaPause : Asset.Images.mediaPlay
let accessibilityLabel = state == .playing ? L10n.a11yPause : L10n.a11yPlay
let offset: CGFloat = state == .playing ? 0 : 2
Image(asset: imageAsset)
@ -73,7 +73,17 @@ struct VoiceMessageButton: View {
.scaledToFit()
.frame(width: imageWidth, height: imageHeight)
.offset(x: offset)
.accessibilityLabel(accessibilityLabel)
}
}
private var accessibilityLabel: String {
switch state {
case .loading:
return ""
case .playing:
return L10n.a11yPause
case .paused:
return L10n.a11yPlay
}
}
}