Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Stream/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ struct ContentView: View {

@State private var showingSettings = false

/// Gates the "Stop Broadcast" confirmation. A live stream is easy to kill by a
/// stray tap on the toolbar's stop button, so tapping it while live asks first
/// instead of tearing the broadcast down immediately.
@State private var showingStopConfirmation = false

/// The mic gain to restore when the user un-mutes from the FAB. Captured the
/// moment they mute so toggling back returns to their chosen level, not unity.
@State private var preMuteVolume: Double = 1.0
Expand Down Expand Up @@ -76,6 +81,19 @@ struct ContentView: View {
.sheet(isPresented: $showingSettings) { settingsSheet }
}
.task { chat.autoConnect() }
.confirmationDialog(
"Stop the broadcast?",
isPresented: $showingStopConfirmation,
titleVisibility: .visible
) {
Button("Stop Broadcast", role: .destructive) {
Haptics.tap()
capture.stop()
}
Button("Keep Streaming", role: .cancel) { }
} message: {
Text("You're live. Stopping ends the stream for everyone watching.")
}
.alert("Screen Capture", isPresented: Binding(
get: { capture.errorMessage != nil },
set: { if !$0 { capture.clearError() } }
Expand All @@ -93,7 +111,7 @@ struct ContentView: View {
Button {
Haptics.tap()
if capture.isLive {
capture.stop()
showingStopConfirmation = true
} else {
persist()
capture.presentPicker(settings: settings)
Expand Down
Loading