swift 6 migration complete

This commit is contained in:
neon443
2025-06-23 20:10:54 +01:00
parent 899304833c
commit 9841574d37
5 changed files with 48 additions and 41 deletions

View File

@@ -652,7 +652,7 @@
REGISTER_APP_GROUPS = YES; REGISTER_APP_GROUPS = YES;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 6.0;
}; };
name = Debug; name = Debug;
}; };
@@ -684,7 +684,7 @@
REGISTER_APP_GROUPS = YES; REGISTER_APP_GROUPS = YES;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 6.0;
}; };
name = Release; name = Release;
}; };
@@ -866,7 +866,8 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Debug; name = Debug;
@@ -916,7 +917,8 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Release; name = Release;

View File

@@ -154,25 +154,25 @@ struct EventWidgetView: View {
.foregroundColor(event.date < Date() ? .red : .primary) .foregroundColor(event.date < Date() ? .red : .primary)
.padding(.trailing, -12) .padding(.trailing, -12)
} else { } else {
Button( // Button(
intent: CompleteEvent( // intent: CompleteEvent(
eventID: IntentParameter( // eventID: IntentParameter(
title: LocalizedStringResource( // title: LocalizedStringResource(
stringLiteral: event.id.uuidString // stringLiteral: event.id.uuidString
) // )
) // )
) // )
) { // ) {
if event.complete { // if event.complete {
Circle() // Circle()
.frame(width: 10) // .frame(width: 10)
.foregroundStyle(.green) // .foregroundStyle(.green)
} else { // } else {
Circle() // Circle()
.frame(width: 10) // .frame(width: 10)
.foregroundStyle(.gray) // .foregroundStyle(.gray)
} // }
} // }
Text(daysUntilEvent(event.date).long) Text(daysUntilEvent(event.date).long)
.font(.caption) .font(.caption)
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)

View File

@@ -11,7 +11,7 @@ struct CompleteEventButton: View {
@ObservedObject var viewModel: EventViewModel @ObservedObject var viewModel: EventViewModel
@Binding var event: Event @Binding var event: Event
@State var timer: Timer? @MainActor @State var timer: Timer?
@State var largeTick: Bool = false @State var largeTick: Bool = false
@State var completeInProgress: Bool = false @State var completeInProgress: Bool = false
@State var completeStartTime: Date = .now @State var completeStartTime: Date = .now
@@ -35,24 +35,27 @@ struct CompleteEventButton: View {
progress = 0 progress = 0
timer = Timer(timeInterval: 0.02, repeats: true) { timer in timer = Timer(timeInterval: 0.02, repeats: true) { timer in
guard completeInProgress else { return } DispatchQueue.main.sync {
guard timer.isValid else { return } guard completeInProgress else { return }
let elapsed = Date().timeIntervalSince(completeStartTime) guard let timer = self.timer else { return }
progress = min(1, elapsed) guard timer.isValid else { return }
#if canImport(UIKit) let elapsed = Date().timeIntervalSince(completeStartTime)
UIImpactFeedbackGenerator(style: .light).impactOccurred() progress = min(1, elapsed)
#endif
if progress >= 1 {
withAnimation { completeInProgress = false }
viewModel.completeEvent(&event)
#if canImport(UIKit) #if canImport(UIKit)
DispatchQueue.main.asyncAfter(deadline: .now()+0.02) { UIImpactFeedbackGenerator(style: .light).impactOccurred()
UINotificationFeedbackGenerator().notificationOccurred(.success)
}
#endif #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) RunLoop.main.add(timer!, forMode: .common)

View File

@@ -496,6 +496,7 @@ func getBuildID() -> String {
return "\(build)" return "\(build)"
} }
@MainActor
func getDevice() -> (sf: String, label: String) { func getDevice() -> (sf: String, label: String) {
#if canImport(UIKit) #if canImport(UIKit)
let asi = ProcessInfo().isiOSAppOnMac let asi = ProcessInfo().isiOSAppOnMac

View File

@@ -18,6 +18,7 @@ struct NFSettings: Codable, Equatable {
var prevAppVersion: String = getVersion()+getBuildID() var prevAppVersion: String = getVersion()+getBuildID()
} }
@MainActor
class SettingsViewModel: ObservableObject { class SettingsViewModel: ObservableObject {
@Published var settings: NFSettings = NFSettings() @Published var settings: NFSettings = NFSettings()
@@ -36,7 +37,7 @@ class SettingsViewModel: ObservableObject {
"pink" "pink"
] ]
@Published var device: (sf: String, label: String) @Published var device: (sf: String, label: String) = ("", "")
init(load: Bool = true) { init(load: Bool = true) {
self.device = getDevice() self.device = getDevice()