mirror of
https://github.com/yattee/yattee.git
synced 2025-10-16 04:18:13 +00:00
Rename button
This commit is contained in:
42
Shared/Views/AccentButton.swift
Normal file
42
Shared/Views/AccentButton.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
import SwiftUI
|
||||
|
||||
struct AccentButton: View {
|
||||
var text: String?
|
||||
var imageSystemName: String?
|
||||
var maxWidth: CGFloat? = .infinity
|
||||
var bold = true
|
||||
var action: () -> Void = {}
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack(spacing: 8) {
|
||||
if let imageSystemName {
|
||||
Image(systemName: imageSystemName)
|
||||
}
|
||||
if let text {
|
||||
Text(text.localized())
|
||||
.fontWeight(bold ? .bold : .regular)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 10)
|
||||
.frame(minHeight: 45)
|
||||
.frame(maxWidth: maxWidth)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.foregroundColor(.accentColor)
|
||||
.buttonStyle(.plain)
|
||||
.background(buttonBackground)
|
||||
}
|
||||
|
||||
var buttonBackground: some View {
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.foregroundColor(Color.accentColor.opacity(0.33))
|
||||
}
|
||||
}
|
||||
|
||||
struct OpenVideosButton_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AccentButton(text: "Open Videos", imageSystemName: "play.circle.fill")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user