chore: adiciona .gitignore e commit.command
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
import Combine
|
||||
import ComposableArchitecture
|
||||
import Inject
|
||||
import Sparkle
|
||||
import SwiftUI
|
||||
|
||||
@Observable
|
||||
@MainActor
|
||||
final class CheckForUpdatesViewModel {
|
||||
init() {
|
||||
anyCancellable = controller.updater.publisher(for: \.canCheckForUpdates)
|
||||
.sink(receiveValue: { self.canCheckForUpdates = $0 })
|
||||
}
|
||||
|
||||
static let shared = CheckForUpdatesViewModel()
|
||||
|
||||
let controller = SPUStandardUpdaterController(
|
||||
startingUpdater: true,
|
||||
updaterDelegate: nil,
|
||||
userDriverDelegate: nil
|
||||
)
|
||||
|
||||
var anyCancellable: AnyCancellable?
|
||||
|
||||
var canCheckForUpdates = false
|
||||
|
||||
func checkForUpdates() {
|
||||
controller.updater.checkForUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckForUpdatesView: View {
|
||||
@State var viewModel = CheckForUpdatesViewModel.shared
|
||||
@ObserveInjection var inject
|
||||
|
||||
var body: some View {
|
||||
Button("Check for Updates…", action: viewModel.checkForUpdates)
|
||||
.disabled(!viewModel.canCheckForUpdates)
|
||||
.enableInjection()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user