Closed gitultra75848 closed 2 months ago
When you add DynamicNotchKit into the project, you will need to add the scheme itself as a target.
As for the Expressions are not allowed at the top level.
, it means that you cannot simply call DynamicNotchKit from the top level. Since you are using SwiftUI, you will need to put it inside a view.
Anyways, if this is your first time using Swift, I would highly recommend going through some tutorials to get used to Swift before trying to use DynamicNotchKit :)
my bad, i figured out how to fix the expression error after posting this. also, i've watched some swift tutorials after this and still can't figure out how to add "the scheme itself as a target", am i watching the wrong tutorial or? though, i do have the add target window up, and i don't really understand which to select, since originally i selected as a macos app. is that the wrong thing?
Make sure that when adding the package, you have selected the target (sorry not scheme) as so:
okay, that fixed it, but of course with every good thing theres a bad thing, lol.. when i did that, this error came out of nowhere, i searched reddit, stackoverflow, hacking with swift, etc and cant find a fix that would suit this.
my bad if im asking too many questions.
Since you are using SwiftUI, you will need to wrap it inside something like a button:
Button {
let notch = DynamicNotchInfo(
systemImage: "figure",
title: "Figure",
description: "Looks like a person"
)
notch.show(for: 2)
}, label: {
Text("Show")
}
(there may be typos here)
er, yeah soo..
fun, is there a different way?
Yes, you will need to wrap the button in a SwiftUI view
Check these (just from a quick search):
appears im not understanding something, neither of these really make me understand what im supposed to do here, do you mind explaining?
It will look something like this.
import SwiftUI
import DynamicNotchKit
struct ContentView: View {
var body: some View {
Button {
let notch = DynamicNotchInfo(
systemImage: "figure",
title: "Figure",
description: "Looks like a person"
)
notch.show(for: 2)
}, label: {
Text("Show")
}
}
}
Again, I would highly recommend getting comfortable with using SwiftUI by itself before trying to learn how to use DynamicNotchKit :)
i got it working, but just a question. how do i stop it from sliding in from the left and make it emerge only from the notch?
That shouldn't be happening.. would you be able to send your code?
yeah, it's really just normal code. just was testing, if you want i can send a screen recording too. summary; i made a project, imported DNK, made a playground in the project, put the code, and it didn't give me any errors except for this glitch. though, it doesn't happen 100% of the time, it happens randomly. more when it says "build (2)" and then runs, but it changes between the expected and unexpected behaviour.
`import SwiftUI import DynamicNotchKit
let notch = DynamicNotchInfo( systemImage: "sparkles", title: "testing", description: "working" ) notch.show(for: 2) `
I haven't tried using DynamicNotchKit from a swift playground, but maybe it might work if you make it run asynchronously using DispatchQueue.main.async { <DynamicNotchKit code> }
? But I'm not sure, since I never intended for this to be run from a playground.
awesome, it works now. question though, can i make it topmost above all windows? when i switch windows (stage manager) while it's showing, the window infront overlaps the dynamic notch and goes over it.
Ohh that's interesting.. Right here, the dynamicNotch is set to be on the screensaver level (one of the highest levels for a window), so I'm not exactly sure why that would be happening.
This would be a super hacky solution atm, but try adding this right after initializing the dynamicNotch, but before showing it:
notch.windowController?.window?.level = window.Level(rawValue: NSWindow.Level.RawValue(CGShieldingWindowLevel()))
This would set the window to be on the highest possible level, which might fix the stage manager issue.
Ohh that's interesting.. Right here, the dynamicNotch is set to be on the screensaver level (one of the highest levels for a window), so I'm not exactly sure why that would be happening.
"This would be a super hacky solution atm, but try adding this right after initializing the dynamicNotch, but before showing it:"
notch.windowController?.window?.level = window.Level(rawValue: NSWindow.Level.RawValue(CGShieldingWindowLevel()))
This would set the window to be on the highest possible level, which might fix the stage manager issue.
and where would this go? before "notch.show(for: 2)"?
Yup!
Yup!
alright, i'll try it.
hmm, doesn't seem to work. do i have to import something?
Hmm.. try typing the windowController
then the .
, and see what autocompletion options come up. Maybe there's something similar to window
that comes up?
Hmm.. try typing the
windowController
then the.
, and see what autocompletion options come up. Maybe there's something similar towindow
that comes up?
like this?
import SwiftUI import DynamicNotchKit
DispatchQueue.main.async { let notch = DynamicNotchInfo( systemImage: "sparkles", title: "testing", description: "working" ) notch.windowController.window?.level = window.Level(rawValue: NSWindow.Level.RawValue(CGShieldingWindowLevel())) notch.show(for: 5) }
seems good to me!
seems good to me!
mm, okay. it gives me this.
Try chaining the optional using the ?
and see what happens
you mean this?
Yes, and then remove window?.level
and see what autocompletion can give you as an equivalent
same thing.
ohhh whoops I had a typo :P
It's NSWindow.Level
, not window.Level
Try NSWindow.Level(.init(CGShieldingWindowLevel()))
instead of window.Level(rawValue: RawValue(CGShieldingWindowLevel()))
cheers!
Try
NSWindow.Level(.init(CGShieldingWindowLevel()))
instead ofwindow.Level(rawValue: RawValue(CGShieldingWindowLevel()))
nevermind. 😄
https://github.com/MrKai77/DynamicNotchKit/assets/157659892/b164a12e-c4c9-47ee-98c3-4081e103c07c
Nooo 😭
But it works correctly without stage manager when switching windows right? In that case, I'm confident that this is a MacOS bug.
Nooo 😭
But it works correctly without stage manager when switching windows right? In that case, I'm confident that this is a MacOS bug.
nope, doesn't work without stage manager either..
Alright, then it might be something with the project being a playground? Maybe since the popup is treated as an app window rather than a popuver.
Try putting the code inside a SwiftUI button and activate it from there maybe?
Alright, then it might be something with the project being a playground? Maybe since the popup is treated as an app window rather than a popuver.
Try putting the code inside a SwiftUI button and activate it from there maybe?
what should i put it as instead of a project? like, do i put it in a project? a workspace? and what do i put the code in? contentview.swift or?
Yes, the code would be put in ContentView (or any other SwiftUI view).
I haven't tried using DynamicNotchKit from a swift playground, but maybe it might work if you make it run asynchronously using
DispatchQueue.main.async { <DynamicNotchKit code> }
? But I'm not sure, since I never intended for this to be run from a playground.
quick question, is it possible to have the dynamic notch appear when my cursor goes into it? (similar to mediamate.)
Yes, you can call notch.checkIfMouseIsInNotch() to check if the mouse is inside the notch.
sup, i have this code so far
`import SwiftUI import DynamicNotchKit
let notch = DynamicNotchInfo( systemImage: "figure", title: "Figure", description: "Looks like a person" ) notch.show(for: 2)`
this is basically my first time using swift/swiftui so my bad if this is an easy fix. on "notch.show(for: 2)" it says
Expressions are not allowed at the top level.
and on "import DynamicNotchKit" it saysNo such module "DymanicNotchKit"
(yeah, i added it as a dependancy.) how do i fix this?