mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 07:34:32 +00:00
Update Onboarding and temperature stuff
This commit is contained in:
parent
5accee5d02
commit
6d01f6a1b2
7 changed files with 335 additions and 72 deletions
|
|
@ -55,6 +55,7 @@ struct DoNotDisturbLiveActivity: View {
|
|||
.accessibilityLabel(accessibilityDescription)
|
||||
.onAppear(perform: handleInitialState)
|
||||
.onChange(of: manager.isDoNotDisturbActive, handleFocusStateChange)
|
||||
.onChange(of: manager.focusToastTrigger, handleFocusModeSwitchToast)
|
||||
.onDisappear(perform: cancelPendingTasks)
|
||||
}
|
||||
|
||||
|
|
@ -333,19 +334,57 @@ struct DoNotDisturbLiveActivity: View {
|
|||
|
||||
private func handleFocusStateChange(_ oldValue: Bool, _ isActive: Bool) {
|
||||
cancelPendingTasks()
|
||||
|
||||
if isActive {
|
||||
withAnimation(.smooth(duration: 0.2)) {
|
||||
// Force a clean collapsed baseline before animating ON.
|
||||
// This avoids cases where prior OFF state leaves the view mid-transition.
|
||||
withAnimation(.none) {
|
||||
showInactiveIcon = false
|
||||
isExpanded = false
|
||||
iconScale = 1.0
|
||||
}
|
||||
|
||||
// Run the expansion on the next runloop tick so the reset takes effect first.
|
||||
DispatchQueue.main.async {
|
||||
withAnimation(.spring(response: 0.35, dampingFraction: 0.85)) {
|
||||
iconScale = 1.0
|
||||
isExpanded = true
|
||||
}
|
||||
if focusToastMode {
|
||||
scheduleTransientCollapse()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
triggerInactiveAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
private func handleFocusModeSwitchToast(_ oldValue: UUID, _ newValue: UUID) {
|
||||
// Only show a toast when Focus is currently active.
|
||||
guard manager.isDoNotDisturbActive else { return }
|
||||
|
||||
// Only relevant for the non-persistent (brief toast) mode.
|
||||
guard focusToastMode else { return }
|
||||
|
||||
// Cancel any pending collapse so the new mode can animate in cleanly.
|
||||
cancelPendingTasks()
|
||||
|
||||
// Force a clean collapsed baseline before animating ON for the *new* mode.
|
||||
// Without this, a mode switch can appear to start then cancel.
|
||||
withAnimation(.none) {
|
||||
showInactiveIcon = false
|
||||
isExpanded = false
|
||||
iconScale = 1.0
|
||||
}
|
||||
|
||||
// Run the expansion on the next runloop tick so the reset takes effect first.
|
||||
DispatchQueue.main.async {
|
||||
guard manager.isDoNotDisturbActive else { return }
|
||||
withAnimation(.spring(response: 0.35, dampingFraction: 0.85)) {
|
||||
iconScale = 1.0
|
||||
isExpanded = true
|
||||
}
|
||||
if focusToastMode {
|
||||
scheduleTransientCollapse()
|
||||
}
|
||||
} else {
|
||||
triggerInactiveAnimation()
|
||||
scheduleTransientCollapse()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -851,6 +851,7 @@ struct SettingsView: View {
|
|||
SettingsSearchEntry(tab: .stats, title: "Enable system stats monitoring", keywords: ["stats", "monitoring"], highlightID: SettingsTab.stats.highlightID(for: "Enable system stats monitoring")),
|
||||
SettingsSearchEntry(tab: .stats, title: "Stop monitoring after closing the notch", keywords: ["stats", "auto stop"], highlightID: SettingsTab.stats.highlightID(for: "Stop monitoring after closing the notch")),
|
||||
SettingsSearchEntry(tab: .stats, title: "CPU Usage", keywords: ["cpu", "graph"], highlightID: SettingsTab.stats.highlightID(for: "CPU Usage")),
|
||||
SettingsSearchEntry(tab: .stats, title: "Temperature unit", keywords: ["cpu", "temperature", "celsius", "fahrenheit"], highlightID: SettingsTab.stats.highlightID(for: "Temperature unit")),
|
||||
SettingsSearchEntry(tab: .stats, title: "Memory Usage", keywords: ["memory", "ram"], highlightID: SettingsTab.stats.highlightID(for: "Memory Usage")),
|
||||
SettingsSearchEntry(tab: .stats, title: "GPU Usage", keywords: ["gpu", "graphics"], highlightID: SettingsTab.stats.highlightID(for: "GPU Usage")),
|
||||
SettingsSearchEntry(tab: .stats, title: "Network Activity", keywords: ["network", "graph"], highlightID: SettingsTab.stats.highlightID(for: "Network Activity")),
|
||||
|
|
@ -6157,6 +6158,7 @@ struct StatsSettings: View {
|
|||
@Default(.showGpuGraph) var showGpuGraph
|
||||
@Default(.showNetworkGraph) var showNetworkGraph
|
||||
@Default(.showDiskGraph) var showDiskGraph
|
||||
@Default(.cpuTemperatureUnit) var cpuTemperatureUnit
|
||||
|
||||
private func highlightID(_ title: String) -> String {
|
||||
SettingsTab.stats.highlightID(for: title)
|
||||
|
|
@ -6246,6 +6248,16 @@ struct StatsSettings: View {
|
|||
Section {
|
||||
Defaults.Toggle("CPU Usage", key: .showCpuGraph)
|
||||
.settingsHighlight(id: highlightID("CPU Usage"))
|
||||
|
||||
if showCpuGraph {
|
||||
Picker("Temperature unit", selection: $cpuTemperatureUnit) {
|
||||
ForEach(LockScreenWeatherTemperatureUnit.allCases) { unit in
|
||||
Text(unit.rawValue).tag(unit)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.settingsHighlight(id: highlightID("Temperature unit"))
|
||||
}
|
||||
Defaults.Toggle("Memory Usage", key: .showMemoryGraph)
|
||||
.settingsHighlight(id: highlightID("Memory Usage"))
|
||||
Defaults.Toggle("GPU Usage", key: .showGpuGraph)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct StatsCard<Content: View>: View {
|
||||
|
|
@ -163,7 +164,10 @@ private struct CPUTemperatureGauge: View {
|
|||
let tint: Color
|
||||
var size: CGFloat = 84
|
||||
var lineWidth: CGFloat = 9
|
||||
private let maxTemperature: Double = 110
|
||||
@Default(.cpuTemperatureUnit) private var temperatureUnit
|
||||
private var maxTemperature: Double {
|
||||
temperatureUnit == .celsius ? 110 : 230
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
CircularGaugeView(
|
||||
|
|
@ -177,14 +181,19 @@ private struct CPUTemperatureGauge: View {
|
|||
)
|
||||
}
|
||||
|
||||
private var displayTemperature: Double? {
|
||||
guard let temperature else { return nil }
|
||||
return temperatureUnit == .celsius ? temperature : temperature * 9.0 / 5.0 + 32.0
|
||||
}
|
||||
|
||||
private var normalizedValue: Double {
|
||||
guard let temperature, maxTemperature > 0 else { return 0 }
|
||||
return min(max(temperature / maxTemperature, 0), 1)
|
||||
guard let displayTemperature, maxTemperature > 0 else { return 0 }
|
||||
return min(max(displayTemperature / maxTemperature, 0), 1)
|
||||
}
|
||||
|
||||
private var centerPrimary: String {
|
||||
guard let temperature else { return "—" }
|
||||
return String(format: "%.0f°", temperature)
|
||||
guard let displayTemperature else { return "—" }
|
||||
return String(format: "%.0f%@", displayTemperature, temperatureUnit.symbol)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue