fix day count being wrong, minor updates
@@ -12,6 +12,6 @@ TEAM_ID = 8JGND254B7
|
||||
BUNDLE_ID = com.neon443.NearFuture
|
||||
BUNDLE_ID_WIDGETS = com.neon443.NearFuture.widgets
|
||||
GROUP_ID = group.NearFuture
|
||||
VERSION = 3.0.1
|
||||
VERSION = 3.1.0
|
||||
NAME = Near Future
|
||||
BUILD_NUMBER = 1
|
||||
|
||||
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 609 KiB |
|
Before Width: | Height: | Size: 534 KiB |
@@ -60,6 +60,7 @@ struct AddEventView: View {
|
||||
title: "Choose a Symbol",
|
||||
searchLabel: "Search...",
|
||||
autoDismiss: true)
|
||||
.presentationBackground(.ultraThinMaterial)
|
||||
}
|
||||
ColorPicker("", selection: $eventColor, supportsOpacity: false)
|
||||
.fixedSize()
|
||||
|
||||
@@ -11,9 +11,6 @@ struct ArchiveView: View {
|
||||
@ObservedObject var viewModel: EventViewModel
|
||||
@State var showAddEvent: Bool = false
|
||||
@State var hey: UUID = UUID()
|
||||
init(viewModel: EventViewModel) {
|
||||
self.viewModel = viewModel
|
||||
}
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
@@ -55,6 +52,7 @@ struct ArchiveView: View {
|
||||
adding: true
|
||||
)
|
||||
.presentationDragIndicator(.visible)
|
||||
.presentationBackground(.ultraThinMaterial)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 609 KiB After Width: | Height: | Size: 729 KiB |
|
Before Width: | Height: | Size: 534 KiB After Width: | Height: | Size: 632 KiB |
@@ -71,14 +71,12 @@ struct EventListView: View {
|
||||
}
|
||||
Spacer()
|
||||
VStack {
|
||||
Text("\(daysUntilEvent(event.date, short: false))")
|
||||
Text("\(daysUntilEvent(event.date).long)")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.one)
|
||||
}
|
||||
Button() {
|
||||
withAnimation {
|
||||
event.complete.toggle()
|
||||
}
|
||||
event.complete.toggle()
|
||||
let eventToModify = viewModel.events.firstIndex() { currEvent in
|
||||
currEvent.id == event.id
|
||||
}
|
||||
|
||||
@@ -75,25 +75,73 @@ struct ColorCodable: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
func daysUntilEvent(_ eventDate: Date, short: Bool, sepLines: Bool = false) -> String {
|
||||
func daysUntilEvent(_ eventDate: Date) -> (short: String, long: String) {
|
||||
let calendar = Calendar.current
|
||||
let currentDate = Date()
|
||||
let components = calendar.dateComponents([.day], from: currentDate, to: eventDate)
|
||||
guard let days = components.day else { return "N/A" }
|
||||
guard days >= 0 else {
|
||||
if short {
|
||||
return "\(days)d"
|
||||
} else {
|
||||
return "\(-days)\(sepLines ? "\n" : " ")day\(-days == 1 ? "" : "s") ago"
|
||||
let components = calendar.dateComponents([.day, .hour, .minute], from: currentDate, to: eventDate)
|
||||
guard let days = components.day else {
|
||||
return ("N/A", "N/A")
|
||||
}
|
||||
guard let hours = components.hour else {
|
||||
return ("N/A", "N/A")
|
||||
}
|
||||
guard let minutes = components.minute else {
|
||||
return ("N/A", "N/A")
|
||||
}
|
||||
|
||||
enum RetUnit {
|
||||
case days
|
||||
case hours
|
||||
case minutes
|
||||
}
|
||||
func ret(days: Int = 0, hours: Int = 0, minutes: Int = 0, unit: RetUnit, future: Bool = true) -> (String, String) {
|
||||
switch unit {
|
||||
case .days:
|
||||
return (
|
||||
"\(days)d",
|
||||
"\(days) day\(plu(-hours))"
|
||||
)
|
||||
case .hours:
|
||||
return (
|
||||
"\(hours)h",
|
||||
"\(hours) hour\(plu(-hours))"
|
||||
)
|
||||
case .minutes:
|
||||
return (
|
||||
"\(minutes)m",
|
||||
"\(minutes) min\(plu(-minutes))"
|
||||
)
|
||||
}
|
||||
}
|
||||
guard days != 0 else {
|
||||
return "Today"
|
||||
}
|
||||
if short {
|
||||
return "\(days)d"
|
||||
} else {
|
||||
return "\(days)\(sepLines ? "\n" : " ")day\(days == 1 ? "" : "s")"
|
||||
switch eventDate > Date() {
|
||||
case true:
|
||||
//future
|
||||
if days == 0 {
|
||||
if hours == 0 {
|
||||
//less than 1h
|
||||
return ret(minutes: minutes, unit: .minutes)
|
||||
} else {
|
||||
//less than 24h
|
||||
return ret(hours: hours, unit: .hours)
|
||||
}
|
||||
} else {
|
||||
//grater than 24h
|
||||
return ret(days: days, unit: .days)
|
||||
}
|
||||
case false:
|
||||
//past
|
||||
if days == 0 {
|
||||
if hours == 0 {
|
||||
//less than 1h
|
||||
return ret(minutes: minutes, unit: .minutes, future: false)
|
||||
} else {
|
||||
//less than 24h
|
||||
return ret(hours: hours, unit: .hours, future: false)
|
||||
}
|
||||
} else {
|
||||
//grater than 24h
|
||||
return ret(days: days, unit: .days, future: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,3 +438,9 @@ func randomColor() -> Color {
|
||||
let b = Double.random(in: 0...1)
|
||||
return Color(red: r, green: g, blue: b)
|
||||
}
|
||||
|
||||
func plu(_ inp: Int) -> String {
|
||||
var input = inp
|
||||
if inp < 0 { input.negate() }
|
||||
return "\(input == 1 ? "" : "s")"
|
||||
}
|
||||
|
||||
@@ -128,11 +128,19 @@ struct EventWidgetView: View {
|
||||
Spacer()
|
||||
|
||||
//short days till if not large widget
|
||||
Text(daysUntilEvent(event.date, short: !isLarge, sepLines: true))
|
||||
.font(.caption)
|
||||
.multilineTextAlignment(.trailing)
|
||||
.foregroundColor(event.color.color)
|
||||
.padding(.trailing, -12)
|
||||
if isLarge {
|
||||
Text(daysUntilEvent(event.date).long)
|
||||
.font(.caption)
|
||||
.multilineTextAlignment(.trailing)
|
||||
.foregroundColor(event.color.color)
|
||||
.padding(.trailing, -12)
|
||||
} else {
|
||||
Text(daysUntilEvent(event.date).short)
|
||||
.font(.caption)
|
||||
.multilineTextAlignment(.trailing)
|
||||
.foregroundColor(event.color.color)
|
||||
.padding(.trailing, -12)
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
|
||||