This commit is contained in:
2025-07-17 09:30:42 -04:00
parent f63bb0ba41
commit 4f01a6445f
7 changed files with 248 additions and 14 deletions

View File

@ -30,21 +30,37 @@ struct SplitPickerView: View {
dismiss()
}) {
VStack {
ZStack {
ZStack(alignment: .bottom) {
// Golden ratio rectangle (1:1.618)
RoundedRectangle(cornerRadius: 12)
.fill(split.getColor())
.aspectRatio(1, contentMode: .fit)
.fill(
LinearGradient(
gradient: Gradient(colors: [split.getColor(), split.getColor().darker(by: 0.2)]),
startPoint: .topLeading,
endPoint: .bottomTrailing
)
)
.aspectRatio(1.618, contentMode: .fit)
.shadow(radius: 2)
Image(systemName: split.systemImage)
.font(.system(size: 30))
.foregroundColor(.white)
VStack {
// Icon in the center
Image(systemName: split.systemImage)
.font(.system(size: 40, weight: .medium))
.foregroundColor(.white)
.offset(y: -15)
// Name at the bottom inside the rectangle
Text(split.name)
.font(.headline)
.foregroundColor(.white)
.lineLimit(1)
.padding(.horizontal, 8)
.padding(.bottom, 8)
}
}
Text(split.name)
.font(.headline)
.lineLimit(1)
// Exercise count below the rectangle
Text("\(split.exercises?.count ?? 0) exercises")
.font(.caption)
.foregroundColor(.secondary)

View File

@ -40,11 +40,12 @@ struct WorkoutsView: View {
)
}
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
Button(role: .destructive) {
Button {
itemToDelete = workout
} label: {
Label("Delete", systemImage: "trash")
}
.tint(.red)
Button {
itemToEdit = workout
} label: {
@ -77,9 +78,11 @@ struct WorkoutsView: View {
) {
Button("Delete", role: .destructive) {
if let item = itemToDelete {
modelContext.delete(item)
try? modelContext.save()
itemToDelete = nil
withAnimation {
modelContext.delete(item)
try? modelContext.save()
itemToDelete = nil
}
}
}
Button("Cancel", role: .cancel) {