Created
December 28, 2025 03:00
-
-
Save AbodiDawoud/1f833d7882372c908f2e5a1835a402b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import CompactSlider | |
| @main | |
| struct IntelligenceDemoApp: App { | |
| @NSApplicationDelegateAdaptor var appDelegate: AppDelegate | |
| var body: some Scene { | |
| _EmptyScene() | |
| } | |
| } | |
| class AppDelegate: NSObject, NSApplicationDelegate { | |
| func applicationDidFinishLaunching(_ notification: Notification) { | |
| let window = NSWindow( | |
| contentRect: NSRect(x: 0, y: 0, width: 700.0, height: 624), | |
| styleMask: [.titled, .closable, .fullSizeContentView, .unifiedTitleAndToolbar], | |
| backing: .buffered, | |
| defer: false | |
| ) | |
| window.titleVisibility = .hidden | |
| window.titlebarAppearsTransparent = true | |
| window.standardWindowButton(.zoomButton)!.isEnabled = false | |
| window.standardWindowButton(.miniaturizeButton)!.isEnabled = false | |
| window.contentView = NSHostingView(rootView: ContentView()) | |
| window.makeKeyAndOrderFront(nil) | |
| window.center() | |
| } | |
| } | |
| struct ContentView: View { | |
| @StateObject private var settings = PlatterSettings() | |
| var body: some View { | |
| ZStack { | |
| VisualEffectBlur(material: .fullScreenUI, blendingMode: .behindWindow) | |
| VStack { | |
| IntelligencePlatterView(settings: settings) | |
| .frame(width: 400, height: 300) | |
| .padding(.top) | |
| VStack(alignment: .leading, spacing: 15) { | |
| VStack(alignment: .leading, spacing: 4) { | |
| Text("Interior Light Fraction") | |
| CompactSlider(value: $settings.interiorLightFraction, in: 0...1) | |
| } | |
| VStack(alignment: .leading, spacing: 4) { | |
| Text("Exterior Light Fraction") | |
| CompactSlider(value: $settings.exteriorLightFraction, in: 0...1) | |
| } | |
| VStack(alignment: .leading, spacing: 4) { | |
| Text("Indeterminate Indicator Fraction") | |
| CompactSlider(value: $settings.indeterminateIndicatorFraction, in: 0...100) | |
| } | |
| Toggle("Uses Audio Levels", isOn: $settings.usesAudioLevels) | |
| } | |
| .padding() | |
| .background(.thickMaterial) | |
| .cornerRadius(12) | |
| .padding() | |
| } | |
| } | |
| .toolbar { | |
| ToolbarItem(placement: .primaryAction) { | |
| HStack { | |
| Button(" Copy ", action: settings.copyViewToPasteboard) | |
| Button(" Reset ", action: settings.resetToDefaults) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| class PlatterSettings: ObservableObject { | |
| @Published var interiorLightFraction = 0.1 | |
| @Published var exteriorLightFraction = 1.0 | |
| @Published var indeterminateIndicatorFraction = 1.0 | |
| @Published var usesAudioLevels = false | |
| @Published var audioLevel = 1.0 | |
| func copyViewToPasteboard() { | |
| NSPasteboard.general.clearContents() | |
| NSPasteboard.general.setString(view_string, forType: .string) | |
| } | |
| func resetToDefaults() { | |
| self.interiorLightFraction = 0.1 | |
| self.exteriorLightFraction = 1.0 | |
| self.indeterminateIndicatorFraction = 1.0 | |
| self.usesAudioLevels = false | |
| } | |
| private var view_string: String { | |
| """ | |
| struct IntelligencePlatterView: NSViewRepresentable { | |
| func makeNSView(context: Context) -> NSView { | |
| let NSIntelligenceUIPlatterView = NSClassFromString("_NSIntelligenceUIPlatterView") as! NSView.Type | |
| return NSIntelligenceUIPlatterView.init() | |
| } | |
| func updateNSView(_ nsView: NSView, context: Context) { | |
| updateProperties(on: nsView) | |
| } | |
| private func updateProperties(on view: NSView) { | |
| view.perform(NSSelectorFromString("set_exteriorLightFraction:"), with: \(exteriorLightFraction)) | |
| view.perform(NSSelectorFromString("set_interiorLightFraction:"), with: \(interiorLightFraction)) | |
| view.perform(NSSelectorFromString("set_indeterminateIndicatorFraction:"), with: \(indeterminateIndicatorFraction)) | |
| view.setValue(\(usesAudioLevels), forKey: "usesAudioLevels") | |
| view.setValue(1.0, forKey: "audioLevel") | |
| } | |
| } | |
| """ | |
| } | |
| } | |
| struct IntelligencePlatterView: NSViewRepresentable { | |
| @ObservedObject var settings: PlatterSettings | |
| func makeNSView(context: Context) -> NSView { | |
| let NSIntelligenceUIPlatterView = NSClassFromString("_NSIntelligenceUIPlatterView") as! NSView.Type | |
| return NSIntelligenceUIPlatterView.init() | |
| } | |
| func updateNSView(_ nsView: NSView, context: Context) { | |
| updateProperties(on: nsView) | |
| } | |
| private func updateProperties(on view: NSView) { | |
| // Those values won't work if you enable the "exteriorLightFraction", "interiorLightFraction" and "indeterminateIndicatorFraction" | |
| //view.setValue(settings.hasInteriorLight, forKey: "hasInteriorLight") | |
| //view.setValue(settings.hasExteriorLight, forKey: "hasExteriorLight") | |
| //view.setValue(settings.indicatesIndeterminateProgress, forKey: "indicatesIndeterminateProgress") | |
| view.perform(NSSelectorFromString("set_exteriorLightFraction:"), with: settings.exteriorLightFraction) | |
| view.perform(NSSelectorFromString("set_interiorLightFraction:"), with: settings.interiorLightFraction) | |
| view.perform(NSSelectorFromString("set_indeterminateIndicatorFraction:"), with: settings.indeterminateIndicatorFraction) | |
| view.setValue(settings.usesAudioLevels, forKey: "usesAudioLevels") | |
| view.setValue(settings.audioLevel, forKey: "audioLevel") | |
| } | |
| } | |
| struct VisualEffectBlur: NSViewRepresentable { | |
| var material: NSVisualEffectView.Material | |
| var blendingMode: NSVisualEffectView.BlendingMode | |
| func makeNSView(context: Context) -> NSVisualEffectView { | |
| let view = NSVisualEffectView() | |
| view.material = material | |
| view.blendingMode = blendingMode | |
| view.state = .active | |
| return view | |
| } | |
| func updateNSView(_ nsView: NSVisualEffectView, context: Context) { | |
| nsView.material = material | |
| nsView.blendingMode = blendingMode | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment