Fix macOS bug where the navigation title interferes with back button

This commit is contained in:
2025-05-27 19:41:34 -04:00
parent 9e4baf1517
commit 4e8907d52d
2 changed files with 50 additions and 47 deletions

View File

@@ -9,51 +9,54 @@ import SwiftUI
struct MainView: View { struct MainView: View {
var body: some View { var body: some View {
VStack { NavigationStack {
NavigationStack { Image("bigicon").resizable().frame(width: 150.0, height: 150.0)
Image("bigicon").resizable().frame(width: 150.0, height: 150.0) Text("Nostash").font(.title)
Text("Nostash").font(.title) Text("A Safari Nostr Extension").font(.title2)
Text("A Safari Nostr Extension").font(.title2) NavigationLink("Privacy Policy") {
NavigationLink("Privacy Policy") { PrivacyPolicyView()
PrivacyPolicyView()
}
#if macOS
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Getting Started: iPhone") {
GettingStartediPhone()
}
#if macOS
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Getting Started: iPad") {
GettingStartediPad()
}
#if macOS
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Getting Started: Mac") {
GettingStartedMac()
}
#if macOS
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Tips and Tricks") {
TipsAndTricks()
}
#if macOS
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
} }
#if os(macOS)
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Getting Started: iPhone") {
GettingStartediPhone()
}
#if os(macOS)
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Getting Started: iPad") {
GettingStartediPad()
}
#if os(macOS)
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Getting Started: Mac") {
GettingStartedMac()
}
#if os(macOS)
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
NavigationLink("Tips and Tricks") {
TipsAndTricks()
}
#if os(macOS)
.buttonStyle(.link)
#endif
.padding(.all, 3.0)
}
.toolbar {
// There is a macOS bug where the back button overlaps the title in the navigation bar.
// Adding an empty Text element fixes the issue apparently.
Text("")
} }
} }
} }

View File

@@ -10,11 +10,11 @@ import SwiftUI
@main @main
struct NostashApp: App { struct NostashApp: App {
var body: some Scene { var body: some Scene {
WindowGroup("Nostash") { WindowGroup {
MainView() MainView()
} }
#if macOS #if os(macOS)
.defaultSize(width: 400, height: 500) .defaultSize(width: 400, height: 500)
#endif #endif
} }
} }