Skip to content

Commit

Permalink
added ellipsis icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcrich23 committed Aug 25, 2022
1 parent 333d0b1 commit 8ab5a21
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Seattle Bridge Tracker/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import SwiftUI
import URLImage
import Mcrich23_Toolkit
import SwiftUIBackports
import Introspect
import Foundation

struct ContentView: View {
@StateObject var viewModel = ContentViewModel()
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
}
}

0 comments on commit 8ab5a21

Please sign in to comment.