add new buttons

This commit is contained in:
neon443
2025-06-10 15:09:10 +01:00
parent a7e09692f6
commit 5ce48a4bc2
2 changed files with 110 additions and 92 deletions

View File

@@ -36,7 +36,7 @@ struct NearFutureApp: App {
viewModel: viewModel, viewModel: viewModel,
event: Binding( event: Binding(
get: { get: {
viewModel.events.first(where: {$0.id == eventID})! viewModel.events.first(where: {$0.id == eventID}) ?? viewModel.template
}, },
set: { newValue in set: { newValue in
if let eventIndex = viewModel.events.firstIndex(where: { if let eventIndex = viewModel.events.firstIndex(where: {
@@ -49,6 +49,7 @@ struct NearFutureApp: App {
) )
) )
} }
.restorationBehavior(.disabled)
Window("About Near Future", id: "about") { Window("About Near Future", id: "about") {
AboutView() AboutView()

View File

@@ -40,6 +40,7 @@ struct AddEventView: View {
} }
NavigationStack { NavigationStack {
Form { Form {
LazyVStack {
Section( Section(
header: header:
Text("Event Details") Text("Event Details")
@@ -141,24 +142,40 @@ struct AddEventView: View {
) )
} }
} }
}
.scrollContentBackground(.hidden) .scrollContentBackground(.hidden)
.navigationTitle("\(adding ? "Add Event" : "")") .navigationTitle("\(adding ? "Add Event" : "")")
// .navigationBarTitleDisplayMode(.inline) // .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
ToolbarItem(/*placement: .topBarLeading*/) { #if canImport(UIKit)
ToolbarItem(placement: .topBarLeading) {
if adding { if adding {
Button() { Button() {
resetAddEventView() resetAddEventView()
dismiss() dismiss()
} label: { } label: {
Image(systemName: "xmark") Image(systemName: "xmark")
.symbolRenderingMode(.hierarchical)
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.frame(width: 30) .frame(width: 30)
} }
} }
} }
#else
ToolbarItem() {
if adding {
Button() {
resetAddEventView()
dismiss()
} label: {
Image(systemName: "xmark")
.resizable()
.scaledToFit()
.frame(width: 30)
}
}
}
#endif
ToolbarItem/*(placement: .topBarTrailing)*/ { ToolbarItem/*(placement: .topBarTrailing)*/ {
if adding { if adding {
Button { Button {