From 62318c5ddcdba87df555de2ce36daa97ac8a55e7 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 21 May 2025 18:10:22 +0100 Subject: [PATCH] mac ui --- MacNearFuture/MacNearFutureApp.swift | 43 +++++++++++++++++++++---- MacNearFuture/NFCommands.swift | 15 +++++++++ MacNearFuture/Views/ContentView.swift | 2 ++ MacNearFuture/Views/EventListView.swift | 10 ++++-- NearFuture.xcodeproj/project.pbxproj | 6 ++++ Shared/Model/Event.swift | 8 ++--- 6 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 MacNearFuture/NFCommands.swift diff --git a/MacNearFuture/MacNearFutureApp.swift b/MacNearFuture/MacNearFutureApp.swift index 312e479..3744356 100644 --- a/MacNearFuture/MacNearFutureApp.swift +++ b/MacNearFuture/MacNearFutureApp.swift @@ -11,15 +11,46 @@ import SwiftUI @main struct NearFutureApp: App { @StateObject var settingsModel: SettingsViewModel = SettingsViewModel() + var body: some Scene { WindowGroup { - ContentView( - viewModel: EventViewModel(), - settingsModel: settingsModel - ) + NavigationSplitView { + List { + 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) - .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) } } diff --git a/MacNearFuture/NFCommands.swift b/MacNearFuture/NFCommands.swift new file mode 100644 index 0000000..b54851b --- /dev/null +++ b/MacNearFuture/NFCommands.swift @@ -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 { + + } +} diff --git a/MacNearFuture/Views/ContentView.swift b/MacNearFuture/Views/ContentView.swift index 0c53c5b..b475e5c 100644 --- a/MacNearFuture/Views/ContentView.swift +++ b/MacNearFuture/Views/ContentView.swift @@ -16,7 +16,9 @@ struct ContentView: View { ForEach(viewModel.events) { event in EventListView(viewModel: viewModel, event: event) } + .padding(.trailing) } + .scrollContentBackground(.hidden) } } diff --git a/MacNearFuture/Views/EventListView.swift b/MacNearFuture/Views/EventListView.swift index 4d9b62b..eadd0fd 100644 --- a/MacNearFuture/Views/EventListView.swift +++ b/MacNearFuture/Views/EventListView.swift @@ -12,10 +12,11 @@ struct EventListView: View { @State var event: Event @State var largeTick: Bool = false + @State var hovering: Bool = false var body: some View { ZStack { - Color.two + Color.black.opacity(hovering ? 0.5 : 0.0) HStack { RoundedRectangle(cornerRadius: 5) .frame(width: 7) @@ -121,10 +122,13 @@ struct EventListView: View { } } .transition(.opacity) - .padding(.vertical, 5) - .background(.ultraThinMaterial) .fixedSize(horizontal: false, vertical: true) } + .onHover { isHovering in + withAnimation { + hovering.toggle() + } + } .contextMenu() { Button(role: .destructive) { let eventToModify = viewModel.events.firstIndex() { currEvent in diff --git a/NearFuture.xcodeproj/project.pbxproj b/NearFuture.xcodeproj/project.pbxproj index 59fbb15..35ba0ec 100644 --- a/NearFuture.xcodeproj/project.pbxproj +++ b/NearFuture.xcodeproj/project.pbxproj @@ -24,6 +24,8 @@ A90D49592DDE2DBD00781124 /* EventListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90D49572DDE2DBD00781124 /* EventListView.swift */; }; A90D495B2DDE2EDB00781124 /* 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 */; }; A914FA4D2DD2768900856265 /* WhatsNewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A914FA4C2DD2768900856265 /* WhatsNewView.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 = ""; }; A90D49572DDE2DBD00781124 /* EventListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventListView.swift; sourceTree = ""; }; 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 = ""; }; A90FDE222DC0D4310012790C /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; A914FA4A2DD26C0F00856265 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; 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; children = ( A90D495A2DDE2EDB00781124 /* MacNearFutureApp.swift */, + A90D495D2DDE3C7400781124 /* NFCommands.swift */, A90D493F2DDE10EC00781124 /* Views */, A90D49342DDE0FAF00781124 /* MacNearFuture.entitlements */, ); @@ -473,6 +477,7 @@ buildActionMask = 2147483647; files = ( A90D494B2DDE2C2900781124 /* AddEventView.swift in Sources */, + A90D495E2DDE3C7400781124 /* NFCommands.swift in Sources */, A90D495B2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */, A90D49522DDE2D0000781124 /* Extensions.swift in Sources */, A90D49422DDE114100781124 /* Event.swift in Sources */, @@ -495,6 +500,7 @@ A949F84D2DCAABE00064DCA0 /* EditEventView.swift in Sources */, A949F84E2DCAABE00064DCA0 /* ContentView.swift in Sources */, A90D495C2DDE2EDB00781124 /* MacNearFutureApp.swift in Sources */, + A90D495F2DDE3C7400781124 /* NFCommands.swift in Sources */, A949F84F2DCAABE00064DCA0 /* EventListView.swift in Sources */, A949F8502DCAABE00064DCA0 /* HelpView.swift in Sources */, A949F85F2DCABB420064DCA0 /* Buttons.swift in Sources */, diff --git a/Shared/Model/Event.swift b/Shared/Model/Event.swift index 96e7767..9608cbc 100644 --- a/Shared/Model/Event.swift +++ b/Shared/Model/Event.swift @@ -132,7 +132,7 @@ func daysUntilEvent(_ eventDate: Date) -> (long: String, short: String) { } } -struct Settings: Codable, Equatable { +struct NFSettings: Codable, Equatable { var showCompletedInHome: Bool var tint: ColorCodable var showWhatsNew: Bool @@ -182,7 +182,7 @@ class SettingsViewModel: ObservableObject { prevAppVersion: getVersion()+getBuildID() ) #elseif canImport(AppKit) - @Published var settings: Settings = Settings( + @Published var settings: NFSettings = NFSettings( showCompletedInHome: false, tint: ColorCodable(nsColor: NSColor(named: "AccentColor")!), showWhatsNew: true, @@ -239,11 +239,11 @@ class SettingsViewModel: ObservableObject { func loadSettings() { let decoder = JSONDecoder() 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 } } 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 } }