44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
import SwiftUI
|
|
|
|
struct PrimaryButton: View {
|
|
let title: String
|
|
var icon: String? = nil
|
|
let action: () -> Void
|
|
var isEnabled: Bool = true
|
|
var localizeTitle: Bool = true
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
HStack(spacing: 8) {
|
|
Group {
|
|
if localizeTitle {
|
|
Text(LocalizedStringKey(title))
|
|
} else {
|
|
Text(verbatim: title)
|
|
}
|
|
}
|
|
.font(.mealMoodBodyBold)
|
|
if let icon = icon {
|
|
Text(icon)
|
|
}
|
|
}
|
|
.foregroundColor(.white)
|
|
.padding(.horizontal, 24)
|
|
.padding(.vertical, 14)
|
|
.frame(maxWidth: .infinity)
|
|
.background(
|
|
LinearGradient(
|
|
colors: isEnabled
|
|
? [Color.mealMoodCoral, Color.mealMoodMint]
|
|
: [Color.gray.opacity(0.3), Color.gray.opacity(0.3)],
|
|
startPoint: .leading,
|
|
endPoint: .trailing
|
|
)
|
|
)
|
|
.cornerRadius(14)
|
|
.shadow(color: isEnabled ? Color.mealMoodCoral.opacity(0.3) : .clear, radius: 8, y: 4)
|
|
}
|
|
.disabled(!isEnabled)
|
|
}
|
|
}
|