diff --git a/Config.xcconfig b/Config.xcconfig index c26cd98..6326991 100644 --- a/Config.xcconfig +++ b/Config.xcconfig @@ -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 diff --git a/Images/NearFutureIcon.png b/Images/NearFutureIcon.png deleted file mode 100644 index 2684ae9..0000000 Binary files a/Images/NearFutureIcon.png and /dev/null differ diff --git a/Images/NearFutureIcon.pxd b/Images/NearFutureIcon.pxd index 8318185..d7e64af 100644 Binary files a/Images/NearFutureIcon.pxd and b/Images/NearFutureIcon.pxd differ diff --git a/Images/NearFutureIconDark.png b/Images/NearFutureIconDark.png deleted file mode 100644 index 78e92c3..0000000 Binary files a/Images/NearFutureIconDark.png and /dev/null differ diff --git a/Images/NearFutureIconDark.pxd b/Images/NearFutureIconDark.pxd index 0337169..605466c 100644 Binary files a/Images/NearFutureIconDark.pxd and b/Images/NearFutureIconDark.pxd differ diff --git a/Images/NearFutureIconTint.png b/Images/NearFutureIconTint.png deleted file mode 100644 index 935ff7b..0000000 Binary files a/Images/NearFutureIconTint.png and /dev/null differ diff --git a/Images/NearFutureIconTint.pxd b/Images/NearFutureIconTint.pxd index d769db8..1a12cf8 100644 Binary files a/Images/NearFutureIconTint.pxd and b/Images/NearFutureIconTint.pxd differ diff --git a/NearFuture/AddEventView.swift b/NearFuture/AddEventView.swift index c28fdea..a0bfbe4 100644 --- a/NearFuture/AddEventView.swift +++ b/NearFuture/AddEventView.swift @@ -60,6 +60,7 @@ struct AddEventView: View { title: "Choose a Symbol", searchLabel: "Search...", autoDismiss: true) + .presentationBackground(.ultraThinMaterial) } ColorPicker("", selection: $eventColor, supportsOpacity: false) .fixedSize() diff --git a/NearFuture/ArchiveView.swift b/NearFuture/ArchiveView.swift index 923fcdd..e26aaa4 100644 --- a/NearFuture/ArchiveView.swift +++ b/NearFuture/ArchiveView.swift @@ -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) } } } diff --git a/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIcon.png b/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIcon.png index 2684ae9..ffb231f 100644 Binary files a/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIcon.png and b/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIcon.png differ diff --git a/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconDark.png b/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconDark.png index 78e92c3..7a11f5e 100644 Binary files a/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconDark.png and b/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconDark.png differ diff --git a/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconTint.png b/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconTint.png index 935ff7b..329c3d5 100644 Binary files a/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconTint.png and b/NearFuture/Assets.xcassets/AppIcon.appiconset/NearFutureIconTint.png differ diff --git a/NearFuture/EventListView.swift b/NearFuture/EventListView.swift index 74b830e..3ae31d2 100644 --- a/NearFuture/EventListView.swift +++ b/NearFuture/EventListView.swift @@ -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 } diff --git a/NearFuture/Item.swift b/NearFuture/Item.swift index d9d3e6b..1cc69df 100644 --- a/NearFuture/Item.swift +++ b/NearFuture/Item.swift @@ -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")" +} diff --git a/NearFutureWidgets/NearFutureWidgets.swift b/NearFutureWidgets/NearFutureWidgets.swift index 5008ba7..402063f 100644 --- a/NearFutureWidgets/NearFutureWidgets.swift +++ b/NearFutureWidgets/NearFutureWidgets.swift @@ -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()