mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-04 02:46:35 -06:00
30 lines
826 B
Swift
30 lines
826 B
Swift
import SwiftUI
|
|
|
|
public struct TextButton: ButtonStyle {
|
|
private let backgroundColor = Color.haPrimary
|
|
|
|
public func makeBody(configuration: Configuration) -> some View {
|
|
configuration.label
|
|
.frame(minHeight: 40)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.horizontal, 22)
|
|
.padding(.vertical, 10)
|
|
.foregroundColor(Color.haPrimary)
|
|
.background(configuration.isPressed ? backgroundColor.opacity(0.08) : backgroundColor.opacity(0.12))
|
|
.clipShape(RoundedRectangle(cornerRadius: .infinity))
|
|
}
|
|
}
|
|
|
|
public extension ButtonStyle where Self == TextButton {
|
|
static var textButton: some ButtonStyle {
|
|
TextButton()
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
Button(action: {}) {
|
|
Text("Hello World")
|
|
}
|
|
.buttonStyle(.textButton)
|
|
}
|