-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ import SwiftUI | |
import URLImage | ||
import Mcrich23_Toolkit | ||
import SwiftUIBackports | ||
import Introspect | ||
import Foundation | ||
|
||
struct ContentView: View { | ||
@StateObject var viewModel = ContentViewModel() | ||
|
@@ -96,7 +98,22 @@ struct ContentView: View { | |
.onAppear { | ||
viewModel.fetchData() | ||
} | ||
.navigationBarTitle("Bridges", displayMode: .large) | ||
.introspectNavigationController { navController in | ||
let bar = navController.navigationBar | ||
let hosting = UIHostingController(rootView: HelpMenu()) | ||
|
||
guard let hostingView = hosting.view else { return } | ||
// bar.addSubview(hostingView) // <--- OPTION 1 | ||
bar.subviews.first(where: \.clipsToBounds)?.addSubview(hostingView) // <--- OPTION 2 | ||
hostingView.backgroundColor = .clear | ||
|
||
hostingView.translatesAutoresizingMaskIntoConstraints = false | ||
NSLayoutConstraint.activate([ | ||
hostingView.trailingAnchor.constraint(equalTo: bar.trailingAnchor), | ||
hostingView.bottomAnchor.constraint(equalTo: bar.bottomAnchor, constant: -8) | ||
]) | ||
} | ||
.navigationBarTitle("Bridges", displayMode: .large) | ||
} | ||
.navigationViewStyle(.stack) | ||
.toolbar { | ||
|
@@ -120,3 +137,22 @@ struct ContentView_Previews: PreviewProvider { | |
ContentView() | ||
} | ||
} | ||
struct HelpMenu: View { | ||
|
||
var body: some View { | ||
Menu { | ||
Link(destination: URL(string: "mailto:feedback@[email protected]")!) { | ||
Text("Give Feedback") | ||
} | ||
Link(destination: URL(string: "mailto:support@[email protected]")!) { | ||
Text("Get Support") | ||
} | ||
} label: { | ||
Image(systemName: "ellipsis.circle") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 40, height: 40) | ||
.padding(.horizontal) | ||
} | ||
} | ||
} |