Files
divkit/client/ios/Samples/SwiftUIIntegration/DivKitSample/SampleDivActionHandler.swift
T
burstein 71f634bec4 DivKit SwiftUI Sample App
commit_hash:89fe30647b25dbbfb4349af0173ca6023d3a2e29
2025-07-04 00:17:17 +03:00

31 lines
723 B
Swift

import DivKit
import SwiftUI
final class SampleDivActionHandler: DivUrlHandler {
private let isPresented: Binding<Bool>
private let text: Binding<String>
init(isPresented: Binding<Bool>, text: Binding<String>) {
self.isPresented = isPresented
self.text = text
}
func handle(_ url: URL, info _: DivActionInfo, sender _: AnyObject?) {
guard let components = url.components, components.scheme == scheme else {
return
}
switch components.host {
case "toast":
if let text = components.queryItems?.first?.name {
self.text.wrappedValue = text
self.isPresented.wrappedValue = true
}
default:
return
}
}
}
private let scheme = "sample-action"