From c3318735ac8d78318b22b043d393b72981ad46cd Mon Sep 17 00:00:00 2001 From: Aravind Raveendran Date: Wed, 27 Sep 2023 13:53:22 +1000 Subject: [PATCH] Add close button to loading screen, so the user can always navigate back even when the stream is loading --- .../DolbyIORTSCore/StreamOrchestrator.swift | 2 + .../Screens/Media/StreamingScreen.swift | 46 +++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Sources/DolbyIORTSCore/StreamOrchestrator.swift b/Sources/DolbyIORTSCore/StreamOrchestrator.swift index 2e2908c..8324e6a 100644 --- a/Sources/DolbyIORTSCore/StreamOrchestrator.swift +++ b/Sources/DolbyIORTSCore/StreamOrchestrator.swift @@ -74,6 +74,8 @@ public final actor StreamOrchestrator { let (_, connectionResult) = await (startConnectionStateUpdate, startConnection) if connectionResult { activeStreamDetail = StreamDetail(streamName: streamName, accountID: accountID) + } else { + activeStreamDetail = nil } return connectionResult } diff --git a/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift b/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift index 2075955..ffd2db9 100644 --- a/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift +++ b/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift @@ -75,21 +75,9 @@ public struct StreamingScreen: View { liveIndicatorView } .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - IconButton(iconAsset: .close) { - endStream() - } - } - ToolbarItem(placement: .principal) { - let streamName = viewModel.streamDetail.streamName - Text( - verbatim: streamName, - font: .custom("AvenirNext-Regular", size: FontSize.subhead, relativeTo: .subheadline) - ) - } - ToolbarItem(placement: .navigationBarTrailing) { - SettingsButton { isShowingSettingsScreen = true } - } + closeToolbarItem + titleToolBarItem + settingsToolbarItem } } @@ -118,6 +106,10 @@ public struct StreamingScreen: View { private var progressView: some View { ProgressView() .frame(maxWidth: .infinity, maxHeight: .infinity) + .toolbar { + closeToolbarItem + titleToolBarItem + } } @ViewBuilder @@ -140,6 +132,30 @@ public struct StreamingScreen: View { EmptyView() } } + + private var titleToolBarItem: ToolbarItem<(), some View> { + ToolbarItem(placement: .principal) { + let streamName = viewModel.streamDetail.streamName + Text( + verbatim: streamName, + font: .custom("AvenirNext-Regular", size: FontSize.subhead, relativeTo: .subheadline) + ) + } + } + + private var closeToolbarItem: ToolbarItem<(), some View> { + ToolbarItem(placement: .navigationBarLeading) { + IconButton(iconAsset: .close) { + endStream() + } + } + } + + private var settingsToolbarItem: ToolbarItem<(), some View> { + ToolbarItem(placement: .navigationBarTrailing) { + SettingsButton { isShowingSettingsScreen = true } + } + } public var body: some View { NavigationView {