This commit is contained in:
neon443
2025-05-21 18:10:22 +01:00
parent 773a083682
commit 62318c5ddc
6 changed files with 71 additions and 13 deletions

View File

@@ -11,15 +11,46 @@ import SwiftUI
@main @main
struct NearFutureApp: App { struct NearFutureApp: App {
@StateObject var settingsModel: SettingsViewModel = SettingsViewModel() @StateObject var settingsModel: SettingsViewModel = SettingsViewModel()
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView( NavigationSplitView {
viewModel: EventViewModel(), List {
settingsModel: settingsModel NavigationLink {
)
} label: {
Image(systemName: "house")
Text("Home")
}
NavigationLink {
} label: {
Image(systemName: "tray.full")
Text("Archive")
}
}
} detail: {
ContentView(
viewModel: EventViewModel(),
settingsModel: settingsModel
)
}
.tint(settingsModel.settings.tint.color) .tint(settingsModel.settings.tint.color)
.frame(minWidth: 350, minHeight: 450) .frame(minWidth: 450, minHeight: 550)
.containerBackground(.ultraThinMaterial, for: .window)
}
.defaultSize(width: 550, height: 650)
.commands {
NearFutureCommands()
}
Window("About Near Future", id: "about") {
}
Settings {
Text("wip")
} }
.defaultSize(width: 450, height: 550)
} }
} }

View File

@@ -0,0 +1,15 @@
//
// NFCommands.swift
// MacNearFuture
//
// Created by neon443 on 21/05/2025.
//
import Foundation
import SwiftUI
struct NearFutureCommands: Commands {
var body: some Commands {
}
}

View File

@@ -16,7 +16,9 @@ struct ContentView: View {
ForEach(viewModel.events) { event in ForEach(viewModel.events) { event in
EventListView(viewModel: viewModel, event: event) EventListView(viewModel: viewModel, event: event)
} }
.padding(.trailing)
} }
.scrollContentBackground(.hidden)
} }
} }

View File

@@ -12,10 +12,11 @@ struct EventListView: View {
@State var event: Event @State var event: Event
@State var largeTick: Bool = false @State var largeTick: Bool = false
@State var hovering: Bool = false
var body: some View { var body: some View {
ZStack { ZStack {
Color.two Color.black.opacity(hovering ? 0.5 : 0.0)
HStack { HStack {
RoundedRectangle(cornerRadius: 5) RoundedRectangle(cornerRadius: 5)
.frame(width: 7) .frame(width: 7)
@@ -121,10 +122,13 @@ struct EventListView: View {
} }
} }
.transition(.opacity) .transition(.opacity)
.padding(.vertical, 5)
.background(.ultraThinMaterial)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
} }
.onHover { isHovering in
withAnimation {
hovering.toggle()
}
}
.contextMenu() { .contextMenu() {
Button(role: .destructive) { Button(role: .destructive) {
let eventToModify = viewModel.events.firstIndex() { currEvent in let eventToModify = viewModel.events.firstIndex() { currEvent in

View File

@@ -24,6 +24,8 @@
A90D49592DDE2DBD00781124 /* EventListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D49572DDE2DBD00781124 /* EventListView.swift */; }; A90D49592DDE2DBD00781124 /* EventListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D49572DDE2DBD00781124 /* EventListView.swift */; };
A90D495B2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */; }; A90D495B2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */; };
A90D495C2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */; }; A90D495C2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */; };
A90D495E2DDE3C7400781124 /* NFCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D495D2DDE3C7400781124 /* NFCommands.swift */; };
A90D495F2DDE3C7400781124 /* NFCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D495D2DDE3C7400781124 /* NFCommands.swift */; };
A914FA4B2DD26C6800856265 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4A2DD26C0F00856265 /* HomeView.swift */; }; A914FA4B2DD26C6800856265 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4A2DD26C0F00856265 /* HomeView.swift */; };
A914FA4D2DD2768900856265 /* WhatsNewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4C2DD2768900856265 /* WhatsNewView.swift */; }; A914FA4D2DD2768900856265 /* WhatsNewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4C2DD2768900856265 /* WhatsNewView.swift */; };
A914FA4F2DD276D200856265 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4E2DD276D200856265 /* AboutView.swift */; }; A914FA4F2DD276D200856265 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4E2DD276D200856265 /* AboutView.swift */; };
@@ -87,6 +89,7 @@
A90D49512DDE2D0000781124 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; }; A90D49512DDE2D0000781124 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
A90D49572DDE2DBD00781124 /* EventListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventListView.swift; sourceTree = "<group>"; }; A90D49572DDE2DBD00781124 /* EventListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventListView.swift; sourceTree = "<group>"; };
A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MacNearFutureApp.swift; path = MacNearFuture/MacNearFutureApp.swift; sourceTree = SOURCE_ROOT; }; A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MacNearFutureApp.swift; path = MacNearFuture/MacNearFutureApp.swift; sourceTree = SOURCE_ROOT; };
A90D495D2DDE3C7400781124 /* NFCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NFCommands.swift; sourceTree = "<group>"; };
A90FDE222DC0D4310012790C /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; }; A90FDE222DC0D4310012790C /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
A914FA4A2DD26C0F00856265 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; }; A914FA4A2DD26C0F00856265 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
A914FA4C2DD2768900856265 /* WhatsNewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WhatsNewView.swift; path = NearFuture/Views/Settings/WhatsNewView.swift; sourceTree = SOURCE_ROOT; }; A914FA4C2DD2768900856265 /* WhatsNewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WhatsNewView.swift; path = NearFuture/Views/Settings/WhatsNewView.swift; sourceTree = SOURCE_ROOT; };
@@ -158,6 +161,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */, A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */,
A90D495D2DDE3C7400781124 /* NFCommands.swift */,
A90D493F2DDE10EC00781124 /* Views */, A90D493F2DDE10EC00781124 /* Views */,
A90D49342DDE0FAF00781124 /* MacNearFuture.entitlements */, A90D49342DDE0FAF00781124 /* MacNearFuture.entitlements */,
); );
@@ -473,6 +477,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
A90D494B2DDE2C2900781124 /* AddEventView.swift in Sources */, A90D494B2DDE2C2900781124 /* AddEventView.swift in Sources */,
A90D495E2DDE3C7400781124 /* NFCommands.swift in Sources */,
A90D495B2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */, A90D495B2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */,
A90D49522DDE2D0000781124 /* Extensions.swift in Sources */, A90D49522DDE2D0000781124 /* Extensions.swift in Sources */,
A90D49422DDE114100781124 /* Event.swift in Sources */, A90D49422DDE114100781124 /* Event.swift in Sources */,
@@ -495,6 +500,7 @@
A949F84D2DCAABE00064DCA0 /* EditEventView.swift in Sources */, A949F84D2DCAABE00064DCA0 /* EditEventView.swift in Sources */,
A949F84E2DCAABE00064DCA0 /* ContentView.swift in Sources */, A949F84E2DCAABE00064DCA0 /* ContentView.swift in Sources */,
A90D495C2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */, A90D495C2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */,
A90D495F2DDE3C7400781124 /* NFCommands.swift in Sources */,
A949F84F2DCAABE00064DCA0 /* EventListView.swift in Sources */, A949F84F2DCAABE00064DCA0 /* EventListView.swift in Sources */,
A949F8502DCAABE00064DCA0 /* HelpView.swift in Sources */, A949F8502DCAABE00064DCA0 /* HelpView.swift in Sources */,
A949F85F2DCABB420064DCA0 /* Buttons.swift in Sources */, A949F85F2DCABB420064DCA0 /* Buttons.swift in Sources */,

View File

@@ -132,7 +132,7 @@ func daysUntilEvent(_ eventDate: Date) -> (long: String, short: String) {
} }
} }
struct Settings: Codable, Equatable { struct NFSettings: Codable, Equatable {
var showCompletedInHome: Bool var showCompletedInHome: Bool
var tint: ColorCodable var tint: ColorCodable
var showWhatsNew: Bool var showWhatsNew: Bool
@@ -182,7 +182,7 @@ class SettingsViewModel: ObservableObject {
prevAppVersion: getVersion()+getBuildID() prevAppVersion: getVersion()+getBuildID()
) )
#elseif canImport(AppKit) #elseif canImport(AppKit)
@Published var settings: Settings = Settings( @Published var settings: NFSettings = NFSettings(
showCompletedInHome: false, showCompletedInHome: false,
tint: ColorCodable(nsColor: NSColor(named: "AccentColor")!), tint: ColorCodable(nsColor: NSColor(named: "AccentColor")!),
showWhatsNew: true, showWhatsNew: true,
@@ -239,11 +239,11 @@ class SettingsViewModel: ObservableObject {
func loadSettings() { func loadSettings() {
let decoder = JSONDecoder() let decoder = JSONDecoder()
if let icSettings = icSettStore.data(forKey: "settings") { if let icSettings = icSettStore.data(forKey: "settings") {
if let decodedSetts = try? decoder.decode(Settings.self, from: icSettings) { if let decodedSetts = try? decoder.decode(NFSettings.self, from: icSettings) {
self.settings = decodedSetts self.settings = decodedSetts
} }
} else if let savedData = appGroupSettingsStore.data(forKey: "settings") { } else if let savedData = appGroupSettingsStore.data(forKey: "settings") {
if let decodedSetts = try? decoder.decode(Settings.self, from: savedData) { if let decodedSetts = try? decoder.decode(NFSettings.self, from: savedData) {
self.settings = decodedSetts self.settings = decodedSetts
} }
} }