Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Showcase/EnvironmentPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ struct EnvironmentPlayground: View {
.environment(\.environmentPlaygroundCustomKey, "Custom!")
}
}
.onChange(of: tapCountObservable.tapCount) {
logger.log("onChange(of: tapCountObservable.tapCount): \($0)")
.onChange(of: tapCountObservable.tapCount) { oldTapCount, newTapCount in
logger.log("onChange(of: tapCountObservable.tapCount): \(newTapCount)")
}
.toolbar {
PlaygroundSourceLink(file: "EnvironmentPlayground.swift")
Expand Down
5 changes: 5 additions & 0 deletions Sources/Showcase/PlaygroundListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ enum PlaygroundType: CaseIterable, View {
case videoPlayer
case viewThatFits
case webAuthenticationSession
case webBrowser
case webView
case zIndex

Expand Down Expand Up @@ -242,6 +243,8 @@ enum PlaygroundType: CaseIterable, View {
return LocalizedStringResource("Video Player")
case .webAuthenticationSession:
return LocalizedStringResource("Web Authentication Session")
case .webBrowser:
return LocalizedStringResource("WebBrowser")
case .webView:
return LocalizedStringResource("WebView")
case .zIndex:
Expand Down Expand Up @@ -411,6 +414,8 @@ enum PlaygroundType: CaseIterable, View {
VideoPlayerPlayground()
case .webAuthenticationSession:
WebAuthenticationSessionPlayground()
case .webBrowser:
WebBrowserPlayground()
case .webView:
WebViewPlayground()
case .zIndex:
Expand Down
8 changes: 7 additions & 1 deletion Sources/Showcase/PlaygroundSourceLink.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// Copyright 2023–2025 Skip
import Foundation
import SwiftUI
import SkipWeb

/// Displays a link to the source code for the given playground type.
struct PlaygroundSourceLink : View {
@AppStorage("openLinksExternally") var openLinksExternally = false
@State var showSource = false
private let destination: URL

init(file: String) {
destination = URL(string: showcaseSourceURLString + playgroundPath + file)!
}

var body: some View {
Link("Source", destination: destination)
Button("Source") {
showSource = true
}.openWebBrowser(isPresented: $showSource, url: destination, mode: openLinksExternally ? .launchBrowser : .embeddedBrowser(params: nil))
}
}
36 changes: 36 additions & 0 deletions Sources/Showcase/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@
},
"Accessibility" : {

},
"Actions" : {

},
"Add" : {

Expand Down Expand Up @@ -711,6 +714,9 @@
},
"alignment: .topLeading" : {

},
"All Options" : {

},
"Also see the `Transition` playground for view enter/exit animations" : {

Expand Down Expand Up @@ -1127,6 +1133,9 @@
},
"Custom" : {

},
"Custom Actions" : {

},
"Custom Cancel" : {

Expand Down Expand Up @@ -1291,6 +1300,9 @@
},
"Email" : {

},
"Embedded Browser" : {

},
"Enter text" : {

Expand Down Expand Up @@ -1801,6 +1813,9 @@
},
"Last: %@" : {

},
"Launch Browser" : {

},
"Lazy Item %lld" : {

Expand Down Expand Up @@ -2134,6 +2149,15 @@
}
}
}
},
"Open in Embedded Browser" : {

},
"Open in System Browser" : {

},
"Open with No Params" : {

},
"Option" : {

Expand Down Expand Up @@ -2354,6 +2378,9 @@
},
"Present with item binding" : {

},
"Presentation Mode" : {

},
"Primary" : {

Expand Down Expand Up @@ -2770,6 +2797,9 @@
},
"Sheet" : {

},
"Sheet / Navigation" : {

},
"Short" : {

Expand Down Expand Up @@ -3553,6 +3583,9 @@
},
"Web Authentication Session" : {

},
"WebBrowser" : {

},
"WebView" : {

Expand Down Expand Up @@ -3708,6 +3741,9 @@
},
"width: 100, height: 100" : {

},
"With Custom Action" : {

},
"With prompt" : {

Expand Down
6 changes: 3 additions & 3 deletions Sources/Showcase/ScenePhasePlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ struct ScenePhasePlayground: View {
}
}
}
.onChange(of: scenePhase) { phase in
logger.log("onChange(of: schenePhase): \(String(describing: phase))")
history.append(phase)
.onChange(of: scenePhase) { oldPhase, newPhase in
logger.log("onChange(of: schenePhase): \(String(describing: newPhase))")
history.append(newPhase)

}
.toolbar {
Expand Down
12 changes: 6 additions & 6 deletions Sources/Showcase/StatePlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ struct StatePlayground: View {
}
}
}
.onChange(of: tapCount) {
logger.log("onChange(of: tapCount): \($0)")
.onChange(of: tapCount) { oldValue, newValue in
logger.log("onChange(of: tapCount): \(newValue)")
}
.onChange(of: tapCountObservable.tapCount) {
logger.log("onChange(of: tapCountObservable.tapCount): \($0)")
.onChange(of: tapCountObservable.tapCount) { oldValue, newValue in
logger.log("onChange(of: tapCountObservable.tapCount): \(newValue)")
}
.onChange(of: tapCountStruct.tapCount) {
logger.log("onChange(of: tapCountStruct.tapCount): \($0)")
.onChange(of: tapCountStruct.tapCount) { oldValue, newValue in
logger.log("onChange(of: tapCountStruct.tapCount): \(newValue)")
}
.toolbar {
PlaygroundSourceLink(file: "StatePlayground.swift")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Showcase/TextFieldPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct TextFieldPlayground: View {
#if !os(macOS) || os(Android)
.keyboardType(UIKeyboardType.phonePad)
#endif
.onChange(of: phone) { newValue in
.onChange(of: phone) { oldValue, newValue in
phone = formatPhone(newValue)
}
TextField("Email", text: $text)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Showcase/VideoPlayerPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct LoopingPlayerView: View {
}

Slider(value: $rate, in: 0.0...10.0, label: { Text("Rate") })
.onChange(of: rate) { newValue in
.onChange(of: rate) { oldValue, newValue in
player.rate = Float(newValue)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Showcase/WebAuthenticationSessionPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct WebAuthenticationSessionPlayground: View {
PlaygroundSourceLink(file: "WebAuthenticationSessionPlayground.swift")
}
}

private func signIn() {
errorMessage = nil
cancelled = false
Expand Down
78 changes: 78 additions & 0 deletions Sources/Showcase/WebBrowserPlayground.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2023–2025 Skip
import SwiftUI
import SkipWeb

struct WebBrowserPlayground: View {
let skipURL = URL(string: "https://skip.dev")!
@State var showEmbedded = false
@State var showEmbeddedNoParams = false
@State var showLaunchBrowser = false
@State var showCustomActions = false
@State var showAllOptions = false
@State var useNavigationPresentation = false

var presentationMode: WebBrowserPresentationMode {
useNavigationPresentation ? .navigation : .sheet
}

var body: some View {
List {
Section("Presentation Mode") {
Toggle("Sheet / Navigation", isOn: $useNavigationPresentation)
}

Section("Embedded Browser") {
Button("Open in Embedded Browser") {
showEmbedded = true
}
.openWebBrowser(isPresented: $showEmbedded, url: skipURL, mode: .embeddedBrowser(params: EmbeddedParams(presentationMode: presentationMode)))

Button("Open with No Params") {
showEmbeddedNoParams = true
}
.openWebBrowser(isPresented: $showEmbeddedNoParams, url: skipURL.appendingPathComponent("docs"), mode: .embeddedBrowser(params: EmbeddedParams(presentationMode: presentationMode)))
}

Section("Launch Browser") {
Button("Open in System Browser") {
showLaunchBrowser = true
}
.openWebBrowser(isPresented: $showLaunchBrowser, url: skipURL, mode: .launchBrowser)
}

Section("Custom Actions") {
Button("With Custom Action") {
showCustomActions = true
}
.openWebBrowser(isPresented: $showCustomActions, url: skipURL, mode: .embeddedBrowser(params: EmbeddedParams(
presentationMode: presentationMode,
customActions: [
WebBrowserAction(label: "Log URL") { url in
logger.info("Custom action URL: \(url)")
}
]
)))
}

Section("All Options") {
Button("Actions") {
showAllOptions = true
}
.openWebBrowser(isPresented: $showAllOptions, url: skipURL, mode: .embeddedBrowser(params: EmbeddedParams(
presentationMode: presentationMode,
customActions: [
WebBrowserAction(label: "Share URL") { url in
logger.info("Share: \(url)")
},
WebBrowserAction(label: "Bookmark") { url in
logger.info("Bookmark: \(url)")
}
]
)))
}
}
.toolbar {
PlaygroundSourceLink(file: "WebBrowserPlayground.swift")
}
}
}
2 changes: 1 addition & 1 deletion Sources/Showcase/WebViewPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct WebViewPlayground: View {

var body: some View {
VStack {
WebView(configuration: config, navigator: navigator, url: URL(string: "https://skip.tools")!, state: $state)
WebView(configuration: config, navigator: navigator, url: URL(string: "https://skip.dev")!, state: $state)
}
.toolbar {
Button {
Expand Down