From 576e929e06c0362bb4050931ec3b6132842c20f7 Mon Sep 17 00:00:00 2001 From: Marco Eidinger Date: Thu, 10 Mar 2022 19:55:30 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Card=20Details:=20crash?= =?UTF-8?q?=20if=20clicking=20on=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `MessagingViewModel` is needed/expected by `ButtonView` and needs to be passed as environment object to the details paeg as `NavigationLink` --- Sources/SAPCAI/UI/Common/SwiftUI/ListItemView.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/SAPCAI/UI/Common/SwiftUI/ListItemView.swift b/Sources/SAPCAI/UI/Common/SwiftUI/ListItemView.swift index 8daf7f0..35e3335 100644 --- a/Sources/SAPCAI/UI/Common/SwiftUI/ListItemView.swift +++ b/Sources/SAPCAI/UI/Common/SwiftUI/ListItemView.swift @@ -2,11 +2,15 @@ import Foundation import SwiftUI struct ListItemView: View { + @EnvironmentObject private var viewModel: MessagingViewModel + var model: ObjectMessageData var body: some View { NavigationLink(destination: CardPageView(card: model) - .environmentObject(ThemeManager.shared)) { + .environmentObject(ThemeManager.shared) + .environmentObject(self.viewModel) + ) { ObjectMessageView(model: model) } } @@ -18,6 +22,7 @@ struct ListItemView: View { ListItemView(model: PreviewData.objectMessage.first!) .previewLayout(.sizeThatFits) .environmentObject(ThemeManager.shared) + .environmentObject(testData) } } #endif