Files
letro-ios/ElementX/Sources/Other/VoiceMessage/PlaybackSpeedButton.swift
Mauro Romito 5e5fb19f42 pr suggestions
2026-02-19 22:40:31 +01:00

46 lines
1.3 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import SwiftUI
struct PlaybackSpeedButton: View {
let speed: AudioPlaybackSpeed
let onTap: () -> Void
var body: some View {
Button(action: onTap) {
ZStack {
Text(speed.placeholder)
.font(.compound.bodyXSSemibold)
.hidden()
Text(speed.label)
.font(.compound.bodyXSSemibold)
.foregroundColor(.compound.iconSecondary)
}
.padding(.horizontal, 8)
.padding(.vertical, 2)
.background(.compound.bgCanvasDefault, in: RoundedRectangle(cornerRadius: 12))
}
.buttonStyle(.plain)
.accessibilityLabel(L10n.a11yPlaybackSpeed)
.accessibilityValue(speed.label)
}
}
struct PlaybackSpeedButton_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
HStack(spacing: 8) {
ForEach(AudioPlaybackSpeed.allCases, id: \.self) { speed in
PlaybackSpeedButton(speed: speed) { }
}
}
.padding()
.background(Color.gray)
}
}