diff --git a/DemoApp/Sources/Components/DemoAppViewFactory.swift b/DemoApp/Sources/Components/DemoAppViewFactory.swift index 58c107d50..674dac6ae 100644 --- a/DemoApp/Sources/Components/DemoAppViewFactory.swift +++ b/DemoApp/Sources/Components/DemoAppViewFactory.swift @@ -12,6 +12,7 @@ final class DemoAppViewFactory: ViewFactory { static let shared = DemoAppViewFactory() @Injected(\.colors) var colors + @Injected(\.microphoneChecker) var microphoneChecker func makeWaitingLocalUserView(viewModel: CallViewModel) -> some View { DemoWaitingLocalUserView(viewFactory: self, viewModel: viewModel) diff --git a/DemoApp/Sources/Views/CustomCallView.swift b/DemoApp/Sources/Views/CustomCallView.swift index 24a2d3a20..22d564515 100644 --- a/DemoApp/Sources/Views/CustomCallView.swift +++ b/DemoApp/Sources/Views/CustomCallView.swift @@ -9,11 +9,11 @@ import SwiftUI struct CustomCallView: View { @Injected(\.colors) var colors + @Injected(\.microphoneChecker) var microphoneChecker var viewFactory: Factory @ObservedObject var viewModel: CallViewModel - - @StateObject var microphoneChecker = MicrophoneChecker() + @State var mutedIndicatorShown = false var body: some View { diff --git a/Sources/StreamVideo/Utils/ThermalStateObserver.swift b/Sources/StreamVideo/Utils/ThermalStateObserver.swift index 4a71a087c..696398c97 100644 --- a/Sources/StreamVideo/Utils/ThermalStateObserver.swift +++ b/Sources/StreamVideo/Utils/ThermalStateObserver.swift @@ -90,7 +90,7 @@ final class ThermalStateObserver: ObservableObject, ThermalStateObserving { } } -/// Provides the default value of the `Appearance` class. +/// Provides the default value of the `ThermalStateObserving` protocol. public struct ThermalStateObserverKey: InjectionKey { public static var currentValue: any ThermalStateObserving = ThermalStateObserver.shared } diff --git a/Sources/StreamVideoSwiftUI/CallingViews/MicrophoneChecker.swift b/Sources/StreamVideoSwiftUI/CallingViews/MicrophoneChecker.swift index 4d0239700..0f0c97152 100644 --- a/Sources/StreamVideoSwiftUI/CallingViews/MicrophoneChecker.swift +++ b/Sources/StreamVideoSwiftUI/CallingViews/MicrophoneChecker.swift @@ -173,3 +173,20 @@ protocol AudioSessionProtocol { } extension AVAudioSession: AudioSessionProtocol {} + +/// Provides the default value of the `ThermalStateObserving` protocol. +public struct MicrophoneCheckerKey: InjectionKey { + public static var currentValue: MicrophoneChecker = MicrophoneChecker() +} + +extension InjectedValues { + + public var microphoneChecker: MicrophoneChecker { + get { + Self[MicrophoneCheckerKey.self] + } + set { + Self[MicrophoneCheckerKey.self] = newValue + } + } +} diff --git a/Sources/StreamVideoSwiftUI/CallingViews/PreJoiningView.swift b/Sources/StreamVideoSwiftUI/CallingViews/PreJoiningView.swift index d815ef477..a965bb7bf 100644 --- a/Sources/StreamVideoSwiftUI/CallingViews/PreJoiningView.swift +++ b/Sources/StreamVideoSwiftUI/CallingViews/PreJoiningView.swift @@ -10,8 +10,8 @@ import SwiftUI public struct LobbyView: View { @StateObject var viewModel: LobbyViewModel - @StateObject var microphoneChecker = MicrophoneChecker() - + @Injected(\.microphoneChecker) var microphoneChecker + var callId: String var callType: String @Binding var callSettings: CallSettings diff --git a/Sources/StreamVideoSwiftUI/CallingViews/iOS13/PreJoiningView_iOS13.swift b/Sources/StreamVideoSwiftUI/CallingViews/iOS13/PreJoiningView_iOS13.swift index ffcc203a8..c1e39c72f 100644 --- a/Sources/StreamVideoSwiftUI/CallingViews/iOS13/PreJoiningView_iOS13.swift +++ b/Sources/StreamVideoSwiftUI/CallingViews/iOS13/PreJoiningView_iOS13.swift @@ -11,7 +11,7 @@ struct LobbyView_iOS13: View { @ObservedObject var callViewModel: CallViewModel @BackportStateObject var viewModel: LobbyViewModel - @BackportStateObject var microphoneChecker = MicrophoneChecker() + @Injected(\.microphoneChecker) var microphoneChecker: MicrophoneChecker var callId: String var callType: String