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,7 +9,6 @@ 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)
@@ -17,7 +16,7 @@ struct MainView: View {
NavigationLink("Privacy Policy") { NavigationLink("Privacy Policy") {
PrivacyPolicyView() PrivacyPolicyView()
} }
#if macOS #if os(macOS)
.buttonStyle(.link) .buttonStyle(.link)
#endif #endif
.padding(.all, 3.0) .padding(.all, 3.0)
@@ -25,7 +24,7 @@ struct MainView: View {
NavigationLink("Getting Started: iPhone") { NavigationLink("Getting Started: iPhone") {
GettingStartediPhone() GettingStartediPhone()
} }
#if macOS #if os(macOS)
.buttonStyle(.link) .buttonStyle(.link)
#endif #endif
.padding(.all, 3.0) .padding(.all, 3.0)
@@ -33,7 +32,7 @@ struct MainView: View {
NavigationLink("Getting Started: iPad") { NavigationLink("Getting Started: iPad") {
GettingStartediPad() GettingStartediPad()
} }
#if macOS #if os(macOS)
.buttonStyle(.link) .buttonStyle(.link)
#endif #endif
.padding(.all, 3.0) .padding(.all, 3.0)
@@ -41,7 +40,7 @@ struct MainView: View {
NavigationLink("Getting Started: Mac") { NavigationLink("Getting Started: Mac") {
GettingStartedMac() GettingStartedMac()
} }
#if macOS #if os(macOS)
.buttonStyle(.link) .buttonStyle(.link)
#endif #endif
.padding(.all, 3.0) .padding(.all, 3.0)
@@ -49,11 +48,15 @@ struct MainView: View {
NavigationLink("Tips and Tricks") { NavigationLink("Tips and Tricks") {
TipsAndTricks() TipsAndTricks()
} }
#if macOS #if os(macOS)
.buttonStyle(.link) .buttonStyle(.link)
#endif #endif
.padding(.all, 3.0) .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,10 +10,10 @@ 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
} }