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