Skip to content

Commit de348f1

Browse files
authored
Open in browser (#323)
1 parent e5391b7 commit de348f1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ios/HackerNews/Web/WebView.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
import Foundation
99
import SwiftUI
10+
import UIKit
1011
import WebKit
1112

1213
struct WebViewContainer: View {
14+
@Environment(\.openURL) var openURL
15+
1316
let url: URL
1417
let title: String
1518

@@ -19,6 +22,19 @@ struct WebViewContainer: View {
1922
.navigationTitle(title)
2023
.toolbarBackground(.visible, for: .navigationBar)
2124
.toolbarBackground(Color(UIColor.systemBackground), for: .navigationBar)
25+
.toolbar {
26+
ToolbarItem(placement: .topBarTrailing) {
27+
Menu {
28+
Button {
29+
openURL(url)
30+
} label: {
31+
Label("Open in browser", systemImage: "safari")
32+
}
33+
} label: {
34+
Image(systemName: "ellipsis")
35+
}
36+
}
37+
}
2238
}
2339
}
2440

0 commit comments

Comments
 (0)