feat: Resolving concurrency warnings

This commit is contained in:
2024-06-11 10:34:19 -04:00
parent e07df0e426
commit bf2e65fb8f
15 changed files with 156 additions and 130 deletions

View File

@@ -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)