Files
Pulse/Sources/PulseUI/Features/Console/Views/ConsoleTaskCellViewModel.swift
T
2023-01-22 08:32:26 -05:00

39 lines
902 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The MIT License (MIT)
//
// Copyright (c) 20202023 Alexander Grebenyuk (github.com/kean).
import SwiftUI
import Pulse
import Combine
import CoreData
final class ConsoleTaskCellViewModel: Pinnable, ObservableObject {
private(set) lazy var progress = ProgressViewModel(task: task)
let task: NetworkTaskEntity
private var cancellable: AnyCancellable?
init(task: NetworkTaskEntity) {
self.task = task
self.progress = ProgressViewModel(task: task)
self.cancellable = task.objectWillChange.sink { [weak self] in
withAnimation {
self?.objectWillChange.send()
}
}
}
// MARK: Pins
lazy var pinViewModel = PinButtonViewModel(task)
// MARK: Context Menu
#if os(iOS) || os(macOS)
func share(as output: ShareOutput) -> ShareItems {
ShareService.share(task, as: output)
}
#endif
}