52 lines
1.8 KiB
Swift
52 lines
1.8 KiB
Swift
import SwiftUI
|
|
|
|
struct PriorityPicker: View {
|
|
@Binding var selectedPriority: Priority
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("Priority")
|
|
.font(.subheadline)
|
|
.fontWeight(.semibold)
|
|
|
|
HStack(spacing: 8) {
|
|
ForEach(Priority.allCases) { priority in
|
|
let isSelected = selectedPriority == priority
|
|
|
|
Button {
|
|
selectedPriority = priority
|
|
} label: {
|
|
HStack(spacing: 6) {
|
|
Circle()
|
|
.fill(colorForPriority(priority))
|
|
.frame(width: 10, height: 10)
|
|
Text(priority.displayName)
|
|
.font(.subheadline)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical, 10)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.fill(isSelected ? colorForPriority(priority).opacity(0.15) : Color(.systemGray6))
|
|
)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.stroke(isSelected ? colorForPriority(priority) : Color.clear, lineWidth: 2)
|
|
)
|
|
.foregroundStyle(isSelected ? colorForPriority(priority) : .primary)
|
|
}
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func colorForPriority(_ priority: Priority) -> Color {
|
|
switch priority {
|
|
case .low: return .green
|
|
case .medium: return .orange
|
|
case .high: return .red
|
|
}
|
|
}
|
|
}
|