feat: Resolving concurrency warnings
This commit is contained in:
@@ -26,6 +26,7 @@ public struct FlaggedEquipmentMeasurementView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public protocol FlaggedEquipmentMeasurementStyle {
|
||||
associatedtype Body: View
|
||||
typealias Configuration = FlaggedEquipmentMeasurementStyleConfiguration
|
||||
@@ -39,6 +40,8 @@ public struct FlaggedEquipmentMeasurementStyleConfiguration {
|
||||
public let ignoreIfZero: [EquipmentMeasurement.FlaggedMeasurement.FieldKey]
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@preconcurrency
|
||||
public struct AnyFlaggedEquipmentMeasurementStyle: FlaggedEquipmentMeasurementStyle {
|
||||
private var _makeBody: (Configuration) -> AnyView
|
||||
|
||||
@@ -46,6 +49,7 @@ public struct AnyFlaggedEquipmentMeasurementStyle: FlaggedEquipmentMeasurementSt
|
||||
self._makeBody = makeBody
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public init<S: FlaggedEquipmentMeasurementStyle>(_ style: S) {
|
||||
self.init { configuration in
|
||||
AnyView(style.makeBody(configuration: configuration))
|
||||
@@ -57,6 +61,7 @@ public struct AnyFlaggedEquipmentMeasurementStyle: FlaggedEquipmentMeasurementSt
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct GridFlaggedEquipmentMeasurementStyle: FlaggedEquipmentMeasurementStyle {
|
||||
|
||||
public func makeBody(configuration: Configuration) -> some View {
|
||||
@@ -82,15 +87,13 @@ extension FlaggedEquipmentMeasurementStyle where Self == GridFlaggedEquipmentMea
|
||||
public static var grid: Self { .init() }
|
||||
}
|
||||
|
||||
private struct FlaggedEquipmentMeasurementStyleKey: EnvironmentKey {
|
||||
static let defaultValue = AnyFlaggedEquipmentMeasurementStyle(GridFlaggedEquipmentMeasurementStyle())
|
||||
}
|
||||
//fileprivate struct FlaggedEquipmentMeasurementStyleKey: @preconcurrency EnvironmentKey {
|
||||
//
|
||||
// static let defaultValue = AnyFlaggedEquipmentMeasurementStyle(.grid)
|
||||
//}
|
||||
|
||||
extension EnvironmentValues {
|
||||
public var flaggedEquipmentMeasurementStyle: AnyFlaggedEquipmentMeasurementStyle {
|
||||
get { self[FlaggedEquipmentMeasurementStyleKey.self] }
|
||||
set { self[FlaggedEquipmentMeasurementStyleKey.self] = newValue }
|
||||
}
|
||||
@Entry var flaggedEquipmentMeasurementStyle = AnyFlaggedEquipmentMeasurementStyle(.grid)
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
||||
@@ -23,7 +23,7 @@ public struct FlaggedMessageLabel: View {
|
||||
}
|
||||
|
||||
private struct FlaggedMessageLabelStyleKey: EnvironmentKey {
|
||||
static var defaultValue = AnyTextLabelStyle(style: .font(.caption))
|
||||
static let defaultValue = AnyTextLabelStyle(style: .font(.caption))
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
|
||||
@@ -27,6 +27,8 @@ extension FlaggedMessageView {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@preconcurrency
|
||||
public protocol FlaggedMessageViewStyle {
|
||||
associatedtype Body: View
|
||||
typealias Configuration = FlaggedMessageViewStyleConfiguration
|
||||
@@ -117,8 +119,10 @@ extension FlaggedMessageViewStyle where Self == AutomaticFlaggedMessageViewStyle
|
||||
}
|
||||
}
|
||||
|
||||
private struct FlaggedMessageViewStyleKey: EnvironmentKey {
|
||||
static var defaultValue = AnyFlaggedMessageViewStyle(
|
||||
@MainActor
|
||||
private struct FlaggedMessageViewStyleKey: @preconcurrency EnvironmentKey {
|
||||
|
||||
static let defaultValue = AnyFlaggedMessageViewStyle(
|
||||
AutomaticFlaggedMessageViewStyle(horizontalSizeClass: nil)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -23,22 +23,24 @@ public struct FlaggedStatusLabel: View {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public protocol FlaggedStatusLabelStyle {
|
||||
@MainActor
|
||||
@preconcurrency
|
||||
public protocol FlaggedStatusLabelStyle: Sendable {
|
||||
associatedtype Body: View
|
||||
typealias Configuration = FlaggedStatusLabelStyleConfiguration
|
||||
|
||||
func makeBody(configuration: Self.Configuration) -> Self.Body
|
||||
}
|
||||
|
||||
public struct FlaggedStatusLabelStyleConfiguration {
|
||||
public struct FlaggedStatusLabelStyleConfiguration : Sendable{
|
||||
public let status: Flagged.CheckResult.Status
|
||||
}
|
||||
|
||||
public struct AnyFlaggedStatusLabelStyle: FlaggedStatusLabelStyle {
|
||||
private let _makeBody: (Configuration) -> AnyView
|
||||
|
||||
internal init(makeBody: @escaping (Configuration) -> AnyView) {
|
||||
@MainActor
|
||||
public struct AnyFlaggedStatusLabelStyle: FlaggedStatusLabelStyle, Sendable {
|
||||
private let _makeBody: @Sendable (Configuration) -> AnyView
|
||||
|
||||
internal init(makeBody: @escaping @Sendable (Configuration) -> AnyView) {
|
||||
self._makeBody = makeBody
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@ public struct FlaggedStatusTextLabelStyle: FlaggedStatusLabelStyle {
|
||||
|
||||
let textLabelStyle: AnyTextLabelStyle?
|
||||
|
||||
public func makeBody(configuration: Configuration) -> some View {
|
||||
@MainActor public func makeBody(configuration: Configuration) -> some View {
|
||||
TextLabel(configuration.status.title)
|
||||
.textLabelStyle(
|
||||
textLabelStyle
|
||||
@@ -68,8 +70,8 @@ public struct FlaggedStatusTextLabelStyle: FlaggedStatusLabelStyle {
|
||||
}
|
||||
}
|
||||
|
||||
private struct FlaggedStatusLabelStyleKey: EnvironmentKey {
|
||||
static var defaultValue = AnyFlaggedStatusLabelStyle(
|
||||
private struct FlaggedStatusLabelStyleKey: @preconcurrency EnvironmentKey {
|
||||
@MainActor static let defaultValue = AnyFlaggedStatusLabelStyle(
|
||||
FlaggedStatusTextLabelStyle(
|
||||
textLabelStyle: AnyTextLabelStyle(
|
||||
style: .font(.callout, fontWeight: .bold)
|
||||
|
||||
@@ -42,6 +42,7 @@ extension FlaggedView where Label == EmptyView {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public protocol FlaggedViewStyle {
|
||||
associatedtype Body: View
|
||||
typealias Configuration = FlaggedViewStyleConfiguration
|
||||
@@ -50,6 +51,7 @@ public protocol FlaggedViewStyle {
|
||||
func makeBody(configuration: Self.Configuration) -> Self.Body
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct FlaggedViewStyleConfiguration {
|
||||
public let flagged: Flagged
|
||||
public let label: Label
|
||||
@@ -82,6 +84,7 @@ public struct AnyFlaggedViewStyle: FlaggedViewStyle {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct DefaultFlagViewStyle: FlaggedViewStyle {
|
||||
|
||||
let alignment: HorizontalAlignment
|
||||
@@ -202,6 +205,7 @@ extension Flagged {
|
||||
.foregroundStyle(statusColor)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public var messageView: some View {
|
||||
FlaggedMessageView(flagged: self)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user