mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
swift 6 migration complete
This commit is contained in:
@@ -11,7 +11,7 @@ struct CompleteEventButton: View {
|
||||
@ObservedObject var viewModel: EventViewModel
|
||||
@Binding var event: Event
|
||||
|
||||
@State var timer: Timer?
|
||||
@MainActor @State var timer: Timer?
|
||||
@State var largeTick: Bool = false
|
||||
@State var completeInProgress: Bool = false
|
||||
@State var completeStartTime: Date = .now
|
||||
@@ -35,24 +35,27 @@ struct CompleteEventButton: View {
|
||||
progress = 0
|
||||
|
||||
timer = Timer(timeInterval: 0.02, repeats: true) { timer in
|
||||
guard completeInProgress else { return }
|
||||
guard timer.isValid else { return }
|
||||
let elapsed = Date().timeIntervalSince(completeStartTime)
|
||||
progress = min(1, elapsed)
|
||||
#if canImport(UIKit)
|
||||
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||
#endif
|
||||
|
||||
if progress >= 1 {
|
||||
withAnimation { completeInProgress = false }
|
||||
viewModel.completeEvent(&event)
|
||||
DispatchQueue.main.sync {
|
||||
guard completeInProgress else { return }
|
||||
guard let timer = self.timer else { return }
|
||||
guard timer.isValid else { return }
|
||||
let elapsed = Date().timeIntervalSince(completeStartTime)
|
||||
progress = min(1, elapsed)
|
||||
#if canImport(UIKit)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now()+0.02) {
|
||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||
}
|
||||
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||
#endif
|
||||
timer.invalidate()
|
||||
progress = 0
|
||||
|
||||
if progress >= 1 {
|
||||
withAnimation { completeInProgress = false }
|
||||
viewModel.completeEvent(&event)
|
||||
#if canImport(UIKit)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now()+0.02) {
|
||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||
}
|
||||
#endif
|
||||
timer.invalidate()
|
||||
progress = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
RunLoop.main.add(timer!, forMode: .common)
|
||||
|
||||
@@ -496,6 +496,7 @@ func getBuildID() -> String {
|
||||
return "\(build)"
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func getDevice() -> (sf: String, label: String) {
|
||||
#if canImport(UIKit)
|
||||
let asi = ProcessInfo().isiOSAppOnMac
|
||||
|
||||
@@ -18,6 +18,7 @@ struct NFSettings: Codable, Equatable {
|
||||
var prevAppVersion: String = getVersion()+getBuildID()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
class SettingsViewModel: ObservableObject {
|
||||
@Published var settings: NFSettings = NFSettings()
|
||||
|
||||
@@ -36,7 +37,7 @@ class SettingsViewModel: ObservableObject {
|
||||
"pink"
|
||||
]
|
||||
|
||||
@Published var device: (sf: String, label: String)
|
||||
@Published var device: (sf: String, label: String) = ("", "")
|
||||
|
||||
init(load: Bool = true) {
|
||||
self.device = getDevice()
|
||||
|
||||
Reference in New Issue
Block a user