39 lines
1013 B
Swift
39 lines
1013 B
Swift
//
|
|
// MacBackendView.swift
|
|
// MacBackend
|
|
//
|
|
// Created by david-swift on 27.11.2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Display a view inside a SwiftUI view which is defined in the parent `MacBackend` widget.
|
|
struct MacBackendView: NSViewRepresentable {
|
|
|
|
/// The views defined in the parent `MacBackend` widget.
|
|
@SwiftUI.Environment(\.views)
|
|
var views
|
|
/// The view's identifier.
|
|
var id: String
|
|
|
|
/// Initialize a SwiftUI view displaying a view which is defined in the parent `MacBackend` widget.
|
|
/// - Parameter id: The identifier.
|
|
init(_ id: String) {
|
|
self.id = id
|
|
}
|
|
|
|
/// Initialize the `NSView`.
|
|
/// - Parameter context: The view context.
|
|
/// - Returns: The view.
|
|
func makeNSView(context: Context) -> NSView {
|
|
views?[id]?.pointer as? NSView ?? .init()
|
|
}
|
|
|
|
/// Update the `NSView`.
|
|
/// - Parameters:
|
|
/// - nsView: The view.
|
|
/// - context: The view context.
|
|
func updateNSView(_ nsView: NSViewType, context: Context) { }
|
|
|
|
}
|