From 2cf256d87cfb46694bcebfbc34e10141b41f0aa6 Mon Sep 17 00:00:00 2001 From: Roman Schlagowsky Date: Thu, 29 Feb 2024 12:23:28 +0100 Subject: [PATCH] Add MainActor to KeyView initializer --- .../StreamDeckKit/Layout/StreamDeckKeyView.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/StreamDeckKit/Layout/StreamDeckKeyView.swift b/Sources/StreamDeckKit/Layout/StreamDeckKeyView.swift index 8ef90d68..5186a47f 100644 --- a/Sources/StreamDeckKit/Layout/StreamDeckKeyView.swift +++ b/Sources/StreamDeckKit/Layout/StreamDeckKeyView.swift @@ -29,22 +29,25 @@ import SwiftUI public struct StreamDeckKeyView: View { + public typealias KeyAction = @MainActor (_ isPressed: Bool) -> Void + public typealias ContentProvider = @MainActor () -> Content + @Environment(\.streamDeckViewContext) var context - let action: @MainActor (Bool) -> Void - @ViewBuilder let content: @MainActor () -> Content + let action: KeyAction + @ViewBuilder let content: ContentProvider public init( - action: @escaping (Bool) -> Void, - @ViewBuilder content: @escaping () -> Content + action: @escaping KeyAction, + @ViewBuilder content: @escaping ContentProvider ) { self.action = action self.content = content } public init( - action: @escaping () -> Void, - @ViewBuilder content: @escaping () -> Content + action: @escaping @MainActor () -> Void, + @ViewBuilder content: @escaping ContentProvider ) { self.init( action: { if $0 { action() } },