fix day count being wrong, minor updates
@@ -12,6 +12,6 @@ TEAM_ID = 8JGND254B7
|
|||||||
BUNDLE_ID = com.neon443.NearFuture
|
BUNDLE_ID = com.neon443.NearFuture
|
||||||
BUNDLE_ID_WIDGETS = com.neon443.NearFuture.widgets
|
BUNDLE_ID_WIDGETS = com.neon443.NearFuture.widgets
|
||||||
GROUP_ID = group.NearFuture
|
GROUP_ID = group.NearFuture
|
||||||
VERSION = 3.0.1
|
VERSION = 3.1.0
|
||||||
NAME = Near Future
|
NAME = Near Future
|
||||||
BUILD_NUMBER = 1
|
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",
|
title: "Choose a Symbol",
|
||||||
searchLabel: "Search...",
|
searchLabel: "Search...",
|
||||||
autoDismiss: true)
|
autoDismiss: true)
|
||||||
|
.presentationBackground(.ultraThinMaterial)
|
||||||
}
|
}
|
||||||
ColorPicker("", selection: $eventColor, supportsOpacity: false)
|
ColorPicker("", selection: $eventColor, supportsOpacity: false)
|
||||||
.fixedSize()
|
.fixedSize()
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ struct ArchiveView: View {
|
|||||||
@ObservedObject var viewModel: EventViewModel
|
@ObservedObject var viewModel: EventViewModel
|
||||||
@State var showAddEvent: Bool = false
|
@State var showAddEvent: Bool = false
|
||||||
@State var hey: UUID = UUID()
|
@State var hey: UUID = UUID()
|
||||||
init(viewModel: EventViewModel) {
|
|
||||||
self.viewModel = viewModel
|
|
||||||
}
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
ZStack {
|
ZStack {
|
||||||
@@ -55,6 +52,7 @@ struct ArchiveView: View {
|
|||||||
adding: true
|
adding: true
|
||||||
)
|
)
|
||||||
.presentationDragIndicator(.visible)
|
.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()
|
Spacer()
|
||||||
VStack {
|
VStack {
|
||||||
Text("\(daysUntilEvent(event.date, short: false))")
|
Text("\(daysUntilEvent(event.date).long)")
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
.foregroundStyle(.one)
|
.foregroundStyle(.one)
|
||||||
}
|
}
|
||||||
Button() {
|
Button() {
|
||||||
withAnimation {
|
event.complete.toggle()
|
||||||
event.complete.toggle()
|
|
||||||
}
|
|
||||||
let eventToModify = viewModel.events.firstIndex() { currEvent in
|
let eventToModify = viewModel.events.firstIndex() { currEvent in
|
||||||
currEvent.id == event.id
|
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 calendar = Calendar.current
|
||||||
let currentDate = Date()
|
let currentDate = Date()
|
||||||
let components = calendar.dateComponents([.day], from: currentDate, to: eventDate)
|
let components = calendar.dateComponents([.day, .hour, .minute], from: currentDate, to: eventDate)
|
||||||
guard let days = components.day else { return "N/A" }
|
guard let days = components.day else {
|
||||||
guard days >= 0 else {
|
return ("N/A", "N/A")
|
||||||
if short {
|
}
|
||||||
return "\(days)d"
|
guard let hours = components.hour else {
|
||||||
} else {
|
return ("N/A", "N/A")
|
||||||
return "\(-days)\(sepLines ? "\n" : " ")day\(-days == 1 ? "" : "s") ago"
|
}
|
||||||
|
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 {
|
switch eventDate > Date() {
|
||||||
return "Today"
|
case true:
|
||||||
}
|
//future
|
||||||
if short {
|
if days == 0 {
|
||||||
return "\(days)d"
|
if hours == 0 {
|
||||||
} else {
|
//less than 1h
|
||||||
return "\(days)\(sepLines ? "\n" : " ")day\(days == 1 ? "" : "s")"
|
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)
|
let b = Double.random(in: 0...1)
|
||||||
return Color(red: r, green: g, blue: b)
|
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()
|
Spacer()
|
||||||
|
|
||||||
//short days till if not large widget
|
//short days till if not large widget
|
||||||
Text(daysUntilEvent(event.date, short: !isLarge, sepLines: true))
|
if isLarge {
|
||||||
.font(.caption)
|
Text(daysUntilEvent(event.date).long)
|
||||||
.multilineTextAlignment(.trailing)
|
.font(.caption)
|
||||||
.foregroundColor(event.color.color)
|
.multilineTextAlignment(.trailing)
|
||||||
.padding(.trailing, -12)
|
.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()
|
Spacer()
|
||||||
|
|||||||