can now edit events, need to make it apply on the fly

added about window
This commit is contained in:
neon443 committed 2025-05-28 13:42:53 +01:00
1 parent 1179810ac2
commit 1902c5102c
9 files changed
+192 -28

No files matched your search

+31 -2
View File
@@ -10,6 +10,7 @@ import SwiftUI
@main
struct NearFutureApp: App {
@Environment(\.openWindow) var openWindow
@StateObject var viewModel: EventViewModel = EventViewModel()
@StateObject var settingsModel: SettingsViewModel = SettingsViewModel()
@@ -22,13 +23,41 @@ struct NearFutureApp: App {
}
.defaultSize(width: 550, height: 650)
.commands {
CommandGroup(replacing: CommandGroupPlacement.appInfo) {
Button("about nf") {
openWindow(id: "about")
}
}
NearFutureCommands()
}
Window("About Near Future", id: "about") {
WindowGroup("edit Event", for: Event.ID.self) { $eventID in
EditEventView(
viewModel: viewModel,
event: Binding(
get: {
viewModel.events.first(where: {$0.id == eventID})!
},
set: { newValue in
if let eventIndex = viewModel.events.firstIndex(where: {
$0.id == eventID
}) {
viewModel.events[eventIndex] = newValue
}
viewModel.saveEvents()
}
)
)
}
Window("About Near Future", id: "about") {
AboutView()
}
.windowBackgroundDragBehavior(.enabled)
.windowResizability(.contentSize)
.restorationBehavior(.disabled)
.defaultPosition(UnitPoint.center)
Settings {
Text("wip")
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.