Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CalenTask/DesignSystem/DSPalette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum DSPalette {
Swatch(name: "Ardesia", hex: "#64748B"),
]

static var randomHex: String { swatches.randomElement()!.hex }
static var randomHex: String { swatches.randomElement()?.hex ?? "#3E63DD" }
}

/// Griglia di scelta colore riusabile (spazi, progetti): swatch tondi,
Expand Down
2 changes: 1 addition & 1 deletion CalenTask/Features/Fields/CustomFieldValueRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct CustomFieldValueRow: View {
}
}
} label: {
Text(value?.valueRaw.isEmpty == false ? value!.valueRaw : "Scegli")
Text(value.flatMap { $0.valueRaw.isEmpty ? nil : $0.valueRaw } ?? "Scegli")
.font(.dsMeta)
.foregroundStyle(hasContent ? Color.indigo : Color.secondary)
.padding(.horizontal, DS.s)
Expand Down
8 changes: 5 additions & 3 deletions CalenTask/Features/Projects/Views/ProjectGanttView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,11 @@ private struct GanttHeader: View {
var bands: [MonthBand] = []
var offset = 0
while offset < days {
let day = calendar.date(byAdding: .day, value: offset, to: range.lowerBound)!
let monthEnd = calendar.dateInterval(of: .month, for: day)!.end
let remaining = calendar.dateComponents([.day], from: day, to: monthEnd).day ?? 1
// Niente force unwrap: se il calendario non risolve la data si chiude
// con una banda di un giorno invece di andare in crash.
guard let day = calendar.date(byAdding: .day, value: offset, to: range.lowerBound) else { break }
let monthEnd = calendar.dateInterval(of: .month, for: day)?.end
let remaining = monthEnd.flatMap { calendar.dateComponents([.day], from: day, to: $0).day } ?? 1
let span = min(remaining, days - offset)
bands.append(MonthBand(
id: offset,
Expand Down
Loading