Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

902 B
Raw Blame
import Foundation
import AppIntents
#if !WIDGET_EXTENSION
import UIKit
#endif

@available(iOS 18.0, *)
struct OpenTaskIntent: AppIntent {
    static let title: LocalizedStringResource = "Open Task"
    static let isDiscoverable = false
    static let openAppWhenRun = true

    @Parameter(title: "URL")
    var urlString: String

    init() {
        urlString = "taskview://open"
    }

    init(urlString: String) {
        self.urlString = urlString
    }

    private var resolvedURL: URL {
        URL(string: urlString) ?? URL(string: "taskview://open")!
    }

    #if WIDGET_EXTENSION
    func perform() async throws -> some IntentResult & OpensIntent {
        .result(opensIntent: OpenURLIntent(resolvedURL))
    }
    #else
    @MainActor
    func perform() async throws -> some IntentResult {
        await UIApplication.shared.open(resolvedURL)
        return .result()
    }
    #endif
}