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
19 changes: 1 addition & 18 deletions Sources/ColumbaApp/Views/Settings/BackgroundTransportView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,7 @@ struct BackgroundTransportView: View {

@ViewBuilder
private var actionButton: some View {
if isEnabledState {
// Disable: clear on-demand + stop (a bare stop() would auto-reconnect).
Button {
errorMessage = nil
Task {
do { try await tunnel.disable() }
catch { errorMessage = error.localizedDescription }
}
} label: {
Text("Disable Background Transport")
.font(.headline)
.foregroundStyle(.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 16)
.background(Theme.error)
.clipShape(RoundedRectangle(cornerRadius: Theme.cornerRadiusLarge))
}
} else {
if !isEnabledState {
Comment thread
greptile-apps[bot] marked this conversation as resolved.
// Enable: install the profile (also arms on-demand) then start.
Button {
enable()
Expand Down
24 changes: 21 additions & 3 deletions Sources/ColumbaApp/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ struct SettingsView: View {
// profile (re-arms on-demand) and reconnects in this session.
Button {
guard !isReticulumActionWorking else { return }
let stopping = tunnel.isRunning
let stopping = reticulumIsOn(tunnel)
isReticulumActionWorking = true
Task {
defer { isReticulumActionWorking = false }
Expand All @@ -583,14 +583,14 @@ struct SettingsView: View {
if isReticulumActionWorking {
ProgressView().tint(.white)
} else {
Text(tunnel.isRunning ? String(localized: "Stop") : String(localized: "Start"))
Text(reticulumIsOn(tunnel) ? String(localized: "Stop") : String(localized: "Start"))
}
}
.font(.subheadline.weight(.semibold))
.foregroundStyle(.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 14)
.background(tunnel.isRunning
.background(reticulumIsOn(tunnel)
? LinearGradient(colors: [Theme.error], startPoint: .top, endPoint: .bottom)
: Theme.accentGradient)
.clipShape(RoundedRectangle(cornerRadius: Theme.cornerRadiusMedium))
Expand Down Expand Up @@ -643,6 +643,24 @@ struct SettingsView: View {
@unknown default: return Theme.textSecondary
}
}

/// Whether the card's action button should present the "Stop" (disable)
/// affordance. Mirrors the explainer sheet's `isEnabledState`: the tunnel
/// counts as "on" whenever it is connected, mid-connect, reasserting, or
/// tearing down - so a user can cancel a slow connect / in-progress stop
/// instead of being stuck on "Start". (A bare `isRunning` is only true for
/// `.connected`, which hides the stop action during `.connecting` /
/// `.reasserting` - the gap PR #217's removed explainer button used to cover.)
private func reticulumIsOn(_ tunnel: TunnelManager) -> Bool {
switch tunnel.status {
case .connected, .connecting, .reasserting, .disconnecting:
return true
case .disconnected, .invalid:
return false
@unknown default:
return tunnel.isEnabled
}
}
#endif

// MARK: - Identity Card
Expand Down
Loading