feat: Resolving concurrency warnings
This commit is contained in:
@@ -93,7 +93,9 @@ extension FlaggedEquipmentMeasurementStyle where Self == GridFlaggedEquipmentMea
|
||||
//}
|
||||
|
||||
extension EnvironmentValues {
|
||||
@Entry var flaggedEquipmentMeasurementStyle = AnyFlaggedEquipmentMeasurementStyle(.grid)
|
||||
@Entry var flaggedEquipmentMeasurementStyle = MainActor.assumeIsolated {
|
||||
AnyFlaggedEquipmentMeasurementStyle(.grid)
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
|
||||
@@ -23,7 +23,9 @@ public struct FlaggedMessageLabel: View {
|
||||
}
|
||||
|
||||
private struct FlaggedMessageLabelStyleKey: EnvironmentKey {
|
||||
static let defaultValue = AnyTextLabelStyle(style: .font(.caption))
|
||||
static let defaultValue = MainActor.assumeIsolated {
|
||||
AnyTextLabelStyle(style: .font(.caption))
|
||||
}
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
|
||||
@@ -25,25 +25,26 @@ public struct FlaggedStatusLabel: View {
|
||||
|
||||
@MainActor
|
||||
@preconcurrency
|
||||
public protocol FlaggedStatusLabelStyle: Sendable {
|
||||
public protocol FlaggedStatusLabelStyle {
|
||||
associatedtype Body: View
|
||||
typealias Configuration = FlaggedStatusLabelStyleConfiguration
|
||||
|
||||
@ViewBuilder
|
||||
func makeBody(configuration: Self.Configuration) -> Self.Body
|
||||
}
|
||||
|
||||
public struct FlaggedStatusLabelStyleConfiguration : Sendable{
|
||||
public struct FlaggedStatusLabelStyleConfiguration {
|
||||
public let status: Flagged.CheckResult.Status
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct AnyFlaggedStatusLabelStyle: FlaggedStatusLabelStyle, Sendable {
|
||||
private let _makeBody: @Sendable (Configuration) -> AnyView
|
||||
public struct AnyFlaggedStatusLabelStyle: FlaggedStatusLabelStyle {
|
||||
private let _makeBody: (Configuration) -> AnyView
|
||||
|
||||
internal init(makeBody: @escaping @Sendable (Configuration) -> AnyView) {
|
||||
internal init(makeBody: @escaping (Configuration) -> AnyView) {
|
||||
self._makeBody = makeBody
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public init<Style: FlaggedStatusLabelStyle>(_ style: Style) {
|
||||
self.init { configuration in
|
||||
AnyView(style.makeBody(configuration: configuration))
|
||||
@@ -59,7 +60,8 @@ public struct FlaggedStatusTextLabelStyle: FlaggedStatusLabelStyle {
|
||||
|
||||
let textLabelStyle: AnyTextLabelStyle?
|
||||
|
||||
@MainActor public func makeBody(configuration: Configuration) -> some View {
|
||||
@MainActor
|
||||
public func makeBody(configuration: Configuration) -> some View {
|
||||
TextLabel(configuration.status.title)
|
||||
.textLabelStyle(
|
||||
textLabelStyle
|
||||
|
||||
@@ -180,7 +180,9 @@ extension FlaggedViewStyle where Self == FlaggedGridRowStyle {
|
||||
}
|
||||
|
||||
private struct FlaggedViewStyleKey: EnvironmentKey {
|
||||
static let defaultValue = AnyFlaggedViewStyle(style: DefaultFlagViewStyle())
|
||||
static let defaultValue = MainActor.assumeIsolated {
|
||||
AnyFlaggedViewStyle(style: DefaultFlagViewStyle())
|
||||
}
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
|
||||
@@ -9,22 +9,6 @@ public enum NextButtonType { }
|
||||
/// A name space for info button styles.
|
||||
public enum ResetButtonType { }
|
||||
|
||||
/// A type erased button style, used to style buttons in a namespace.
|
||||
//@MainActor
|
||||
//public struct AnyButtonStyle<ButtonType>: ButtonStyle, Sendable {
|
||||
// private let _makeBody: @Sendable (Configuration) -> AnyView
|
||||
//
|
||||
// public init<S: ButtonStyle>(_ style: S) where S: Sendable, S.Body: Sendable {
|
||||
// self._makeBody = { configuration in
|
||||
// AnyView(style.makeBody(configuration: configuration))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public func makeBody(configuration: Configuration) -> some View {
|
||||
// self._makeBody(configuration)
|
||||
// }
|
||||
//}
|
||||
|
||||
/// A type erased primitive button style, used to style buttons in a namespace.
|
||||
@MainActor
|
||||
public struct AnyPrimitiveButtonStyle<ButtonType>: PrimitiveButtonStyle {
|
||||
@@ -113,16 +97,6 @@ extension AnyPrimitiveButtonStyle<NextButtonType> {
|
||||
public static var toolbar: Self { .init(ToolbarNextButtonStyle()) }
|
||||
}
|
||||
|
||||
//extension AnyButtonStyle where ButtonType == InfoButtonType {
|
||||
// public static var `default`: Self {
|
||||
// .init(DefaultInfoButtonStyle<IconOnlyLabelStyle>(labelStyle: .iconOnly))
|
||||
// }
|
||||
//
|
||||
// public static func `default`<S: LabelStyle>(color: Color, font: Font, labelStyle: S) -> Self {
|
||||
// .init(DefaultInfoButtonStyle<S>(color: color, font: font, labelStyle: labelStyle))
|
||||
// }
|
||||
//}
|
||||
|
||||
private struct InfoButtonStyleKey: @preconcurrency EnvironmentKey {
|
||||
@MainActor
|
||||
static var defaultValue: AnyPrimitiveButtonStyle<InfoButtonType> {
|
||||
@@ -131,16 +105,19 @@ private struct InfoButtonStyleKey: @preconcurrency EnvironmentKey {
|
||||
}
|
||||
|
||||
private struct NextButtonStyleKey: EnvironmentKey {
|
||||
@MainActor
|
||||
static var defaultValue: AnyPrimitiveButtonStyle<NextButtonType> {
|
||||
MainActor.assumeIsolated {
|
||||
AnyPrimitiveButtonStyle<NextButtonType>(
|
||||
DefaultNextButtonStyle<BorderedProminentButtonStyle, NextLabelStyle>()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ResetButtonStyleKey: EnvironmentKey {
|
||||
static let defaultValue = AnyPrimitiveButtonStyle<ResetButtonType>(.borderedProminent)
|
||||
static let defaultValue = MainActor.assumeIsolated {
|
||||
AnyPrimitiveButtonStyle<ResetButtonType>(.borderedProminent)
|
||||
}
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
public protocol TextLabelStyle {
|
||||
|
||||
associatedtype Body: View
|
||||
typealias Configuration = TextLabelConfiguration
|
||||
|
||||
@MainActor
|
||||
func makeBody(configuration: Self.Configuration) -> Self.Body
|
||||
}
|
||||
|
||||
extension TextLabelStyle {
|
||||
@MainActor
|
||||
public func combining<Other: TextLabelStyle>(_ style: Other) -> AnyTextLabelStyle {
|
||||
AnyTextLabelStyle(style: self).combining(style)
|
||||
}
|
||||
@@ -31,7 +32,7 @@ public struct TextLabelConfiguration {
|
||||
|
||||
@MainActor
|
||||
public struct AnyTextLabelStyle: TextLabelStyle {
|
||||
private var _makeBody: (Configuration) -> AnyView
|
||||
private let _makeBody: (Configuration) -> AnyView
|
||||
|
||||
internal init(makeBody: @escaping (Configuration) -> AnyView) {
|
||||
self._makeBody = makeBody
|
||||
@@ -59,22 +60,28 @@ public struct AnyTextLabelStyle: TextLabelStyle {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct AutomaticTextLabelStyle: TextLabelStyle {
|
||||
@MainActor
|
||||
public func makeBody(configuration: Configuration) -> some View {
|
||||
configuration.label
|
||||
}
|
||||
}
|
||||
|
||||
private struct TextLabelStyleKey: EnvironmentKey {
|
||||
static let defaultValue = AnyTextLabelStyle(style: AutomaticTextLabelStyle())
|
||||
static let defaultValue = MainActor.assumeIsolated {
|
||||
AnyTextLabelStyle(style: AutomaticTextLabelStyle())
|
||||
}
|
||||
}
|
||||
|
||||
private struct SectionHeaderLabelStyleKey: EnvironmentKey {
|
||||
static let defaultValue = AnyTextLabelStyle(style: AutomaticTextLabelStyle())
|
||||
static let defaultValue = MainActor.assumeIsolated {
|
||||
AnyTextLabelStyle(style: AutomaticTextLabelStyle())
|
||||
}
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
|
||||
|
||||
public var textLabelStyle: AnyTextLabelStyle {
|
||||
get { self[TextLabelStyleKey.self] }
|
||||
set { self[TextLabelStyleKey.self] = newValue }
|
||||
@@ -117,6 +124,7 @@ public struct ColoredTextLabelStyle: TextLabelStyle {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public func font(_ font: Font? = nil, fontWeight: Font.Weight? = nil) -> AnyTextLabelStyle {
|
||||
self.combining(.font(font, fontWeight: fontWeight))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user