Skip to content

Commit

Permalink
Add close button to loading screen, so the user can always navigate b…
Browse files Browse the repository at this point in the history
…ack even when the stream is loading
  • Loading branch information
aravind-raveendran committed Sep 27, 2023
1 parent 5624d85 commit c331873
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Sources/DolbyIORTSCore/StreamOrchestrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
46 changes: 31 additions & 15 deletions Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -118,6 +106,10 @@ public struct StreamingScreen: View {
private var progressView: some View {
ProgressView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.toolbar {
closeToolbarItem
titleToolBarItem
}
}

@ViewBuilder
Expand All @@ -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 {
Expand Down

0 comments on commit c331873

Please sign in to comment.