Merge pull request 'Bind url to WebView's uri property' (#1) from david-swift/AdwaitaWebViewSwift:main into main

Reviewed-on: #1
This commit is contained in:
Zaph 2024-12-08 14:27:38 +01:00
commit f40a1c569f

View File

@ -14,6 +14,11 @@ public struct WebView: AdwaitaWidget {
public func container<Data>(data: WidgetData, type: Data.Type) -> ViewStorage where Data: ViewRenderData {
let storage = ViewStorage(webkit_web_view_new()?.opaque())
update(storage, data: data, updateProperties: true, type: type)
storage.notify(name: "uri") {
if let url = webkit_web_view_get_uri(storage.opaquePointer?.cast()) {
self.url = String(cString: url)
}
}
return storage
}