Skip to content
Merged
Show file tree
Hide file tree
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct MobileSettingsView: View {
let connectedHostName: String
let startPairingScanner: (() -> Void)?
let signOut: (() -> Void)?
/// The shell store, used to drive the multi-Mac switcher. `nil` in previews,
/// where the "Switch Mac" entry is hidden.
/// The shell store, used for the live connection rows and the onboarding
/// replay's connection state. `nil` in previews.
var store: CMUXMobileShellStore?
@AppStorage(MobileSettingsView.sendAnonymousTelemetryKey) private var sendAnonymousTelemetry = false

Expand All @@ -40,7 +40,6 @@ struct MobileSettingsView: View {
/// `isEnabled` as a non-observable `UserDefaults` read, so reading it
/// directly in `body` would not re-render when it flips.
@State private var notificationsEnabled = false
@State private var showingHostPicker = false
@State private var showingOnboarding = false
@State private var showingSetupHelp = false
#if DEBUG
Expand Down Expand Up @@ -90,10 +89,11 @@ struct MobileSettingsView: View {
}
}

// Hidden entirely when there is nothing to show (no connected
// Mac and no store to switch with), so the no-devices screen's
// reuse of this sheet does not render an empty header.
if hasConnectionSection {
// Hidden when there is no live connection row to show, so the
// no-devices screen's reuse of this sheet does not render an
// empty header. Switching Macs lives in the workspace list's
// computer picker.
if hasConnectionRows {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Section(L10n.string("mobile.settings.connection", defaultValue: "Connection")) {
if let connections = store?.liveMacConnections,
!connections.isEmpty {
Expand All @@ -120,18 +120,9 @@ struct MobileSettingsView: View {
value: connectedHostName
)
}
if store != nil {
Button {
showingHostPicker = true
} label: {
Label(
L10n.string("mobile.settings.switchMac", defaultValue: "Switch Computer"),
systemImage: "macbook.and.iphone"
)
}
.accessibilityIdentifier("MobileSettingsSwitchMac")
}
}
}
if hasConnectionSection {
Button {
showingSetupHelp = true
} label: {
Expand Down Expand Up @@ -462,11 +453,6 @@ struct MobileSettingsView: View {
ToastGalleryView()
}
#endif
.sheet(isPresented: $showingHostPicker) {
if let store {
MobileHostPickerView(store: store)
}
}
.sheet(isPresented: $showingOnboarding) {
// Re-entry never writes first-run progress. The final scene reads
// live connection state and can reopen pairing from offline Settings.
Expand Down Expand Up @@ -529,9 +515,15 @@ struct MobileSettingsView: View {
nil
}

/// Whether the Connection section has any rows to show. When this sheet is
/// reused from the no-devices screen there is no connected Mac or store to
/// switch with, so the section is omitted entirely.
/// Whether the Connection section has any rows to show. When nothing is
/// connected the section is omitted entirely so its header never sits empty.
private var hasConnectionRows: Bool {
store?.liveMacConnections.isEmpty == false || !connectedHostName.isEmpty
}

/// Whether the setup and introduction entries apply. When this sheet is
/// reused from the no-devices screen there is no connected Mac or store,
/// so they are hidden.
private var hasConnectionSection: Bool {
!connectedHostName.isEmpty || store != nil
}
Expand Down
Loading