BlueHuskyStudios/Howl

timeToLive, fadeOutAnimationDuration, afterHideCallback don't seem to be working

开放

#10 创建于 2023年10月3日

 (6 条评论) (0 个反应) (0 位负责人)Swift (9 个派生)auto 404
bughelp wanted

仓库指标

星标
 (34 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Have a really simple program where I am trying to show an HUD, but I can't seem to be able to get timeToLive, fadeOutAnimationDuration and afterHideCallback options to work, despite whatever value I set the HUD disappears with no animations, fadeInAnimationDuration seems to work though. also timeToLive does not seem to have any effect and the HUD disappears after the same time no matter what value I set. afterHideCallback does not seem to trigger either.

import AppKit
import BezelNotification

func after(_ delay: TimeInterval, perform block: @escaping ()->(), on queue: DispatchQueue = OperationQueue.current?.underlyingQueue ?? .main) { // So this `queue` preserves the current queue and defaulted to the `main`. Also the caller can pass in the desired queue explicitly
    queue.asyncAfter(deadline: .now() + delay, execute: block)
}

var showMuted: Bool = true

for argument in CommandLine.arguments {
    if (argument == "un-muted") {
        showMuted = false;
    }
}

let app = NSApplication.shared

class AppDelegate: NSObject, NSApplicationDelegate {
    func applicationDidFinishLaunching(_ notification: Notification) {
        var path: String?
        if (showMuted) {
            path = Bundle.module.path(forResource: "mic.slash.fill", ofType: "png")
        } else {
            path = Bundle.module.path(forResource: "mic.fill", ofType: "png")
        }
        let bezelIcon = NSImage(contentsOfFile: path!)
        BezelNotification.show(
            messageText: "",
            icon: bezelIcon,
            timeToLive: .exactly(seconds: 2),
            fadeInAnimationDuration: 0,
            fadeOutAnimationDuration: 0
        )
        after(2) {
            app.terminate(self)
        }
    }
}

let delegate = AppDelegate()
app.delegate = delegate
app.run()

贡献者指南