chat we cooked
events can now be completed
widgets now acc have a bg and a nicer title
settings now says that there are widgets
also small ux improvements
This commit is contained in:
neon443
2025-03-28 18:32:09 +00:00
parent 1e36d15184
commit 68484da44f
8 changed files with 246 additions and 755 deletions

View File

@@ -22,6 +22,8 @@ import WidgetKit
struct Event: Identifiable, Codable {
var id = UUID()
var name: String
var complete: Bool
var completeDesc: String
var symbol: String
var color: ColorCodable
var description: String
@@ -65,7 +67,7 @@ struct ColorCodable: Codable {
}
}
func daysUntilEvent(_ eventDate: Date, short: Bool) -> String {
func daysUntilEvent(_ eventDate: Date, short: Bool, sepLines: Bool = false) -> String {
let calendar = Calendar.current
let currentDate = Date()
let components = calendar.dateComponents([.day], from: currentDate, to: eventDate)
@@ -74,7 +76,7 @@ func daysUntilEvent(_ eventDate: Date, short: Bool) -> String {
if short {
return "\(days)d"
} else {
return "\(-days) day\(-days == 1 ? "" : "s") ago"
return "\(-days)\(sepLines ? "\n" : " ")day\(-days == 1 ? "" : "s") ago"
}
}
guard days != 0 else {
@@ -83,7 +85,7 @@ func daysUntilEvent(_ eventDate: Date, short: Bool) -> String {
if short {
return "\(days)d"
} else {
return "\(days) day\(days == 1 ? "" : "s")"
return "\(days)\(sepLines ? "\n" : " ")day\(days == 1 ? "" : "s")"
}
}
@@ -156,6 +158,8 @@ class EventViewModel: ObservableObject {
func addEvent(
name: String,
complete: Bool,
completedDesc: String,
symbol: String,
color: ColorCodable,
description: String,
@@ -165,6 +169,8 @@ class EventViewModel: ObservableObject {
) {
let newEvent = Event(
name: name,
complete: complete,
completeDesc: completedDesc,
symbol: symbol,
color: color,
description: description,