Fixed Widget stats

This commit is contained in:
2025-09-15 23:27:21 -06:00
parent 363fbd676a
commit b53dfb1aa5
13 changed files with 94 additions and 157 deletions

View File

@@ -43,8 +43,8 @@ struct ContentView: View {
.tag(4)
}
.environmentObject(dataManager)
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
.onChange(of: scenePhase) {
if scenePhase == .active {
dataManager.onAppBecomeActive()
}
}

View File

@@ -1,4 +1,3 @@
import Foundation
import SwiftUI
@@ -493,13 +492,14 @@ struct Attempt: Identifiable, Codable, Hashable {
}
func updated(
result: AttemptResult? = nil, highestHold: String? = nil, notes: String? = nil,
problemId: UUID? = nil, result: AttemptResult? = nil, highestHold: String? = nil,
notes: String? = nil,
duration: Int? = nil, restTime: Int? = nil
) -> Attempt {
return Attempt(
id: self.id,
sessionId: self.sessionId,
problemId: self.problemId,
problemId: problemId ?? self.problemId,
result: result ?? self.result,
highestHold: highestHold ?? self.highestHold,
notes: notes ?? self.notes,

View File

@@ -1,4 +1,3 @@
import Combine
import SwiftUI
@@ -82,9 +81,9 @@ struct IconAppearanceModifier: ViewModifier {
func body(content: Content) -> some View {
content
.onChange(of: colorScheme) { _, newColorScheme in
iconHelper.updateDarkModeStatus(for: newColorScheme)
onChange(iconHelper.getRecommendedIconVariant(for: newColorScheme))
.onChange(of: colorScheme) {
iconHelper.updateDarkModeStatus(for: colorScheme)
onChange(iconHelper.getRecommendedIconVariant(for: colorScheme))
}
.onAppear {
iconHelper.updateDarkModeStatus(for: colorScheme)

View File

@@ -1020,7 +1020,7 @@ extension ClimbingDataManager {
private func updateLiveActivityForActiveSession() {
guard let activeSession = activeSession,
activeSession.status == .active,
let gym = gym(withId: activeSession.gymId)
let _ = gym(withId: activeSession.gymId)
else {
return
}

View File

@@ -45,7 +45,7 @@ final class LiveActivityManager {
do {
let activity = try Activity<SessionActivityAttributes>.request(
attributes: attributes,
contentState: initialContentState,
content: .init(state: initialContentState, staleDate: nil),
pushType: nil
)
self.currentActivity = activity
@@ -81,12 +81,8 @@ final class LiveActivityManager {
completedProblems: completedProblems
)
do {
await currentActivity.update(using: updatedContentState, alertConfiguration: nil)
print("✅ Live Activity updated successfully")
} catch {
print("❌ Failed to update live activity: \(error)")
}
await currentActivity.update(.init(state: updatedContentState, staleDate: nil))
print("✅ Live Activity updated successfully")
}
/// Call this when a ClimbSession ends to end the Live Activity
@@ -98,14 +94,9 @@ final class LiveActivityManager {
print("🔴 Ending Live Activity: \(currentActivity.id)")
do {
await currentActivity.end(using: nil, dismissalPolicy: .immediate)
self.currentActivity = nil
print("✅ Live Activity ended successfully")
} catch {
print("❌ Failed to end live activity: \(error)")
self.currentActivity = nil
}
await currentActivity.end(nil, dismissalPolicy: .immediate)
self.currentActivity = nil
print("✅ Live Activity ended successfully")
}
/// Check if Live Activities are available and authorized

View File

@@ -1,4 +1,3 @@
import SwiftUI
struct AddAttemptView: View {
@@ -610,36 +609,25 @@ struct EditAttemptView: View {
var body: some View {
NavigationView {
Form {
Section("Problem") {
Section("Select Problem") {
if availableProblems.isEmpty {
Text("No problems available")
.foregroundColor(.secondary)
} else {
ForEach(availableProblems, id: \.id) { problem in
HStack {
VStack(alignment: .leading, spacing: 4) {
Text(problem.name ?? "Unnamed Problem")
.font(.headline)
Text(
"\(problem.difficulty.system.displayName): \(problem.difficulty.grade)"
)
.font(.subheadline)
.foregroundColor(.blue)
LazyVGrid(
columns: Array(repeating: GridItem(.flexible(), spacing: 8), count: 2),
spacing: 8
) {
ForEach(availableProblems, id: \.id) { problem in
ProblemSelectionCard(
problem: problem,
isSelected: selectedProblem?.id == problem.id
) {
selectedProblem = problem
}
Spacer()
if selectedProblem?.id == problem.id {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(.blue)
}
}
.contentShape(Rectangle())
.onTapGesture {
selectedProblem = problem
}
}
.padding(.vertical, 8)
}
}
@@ -724,6 +712,7 @@ struct EditAttemptView: View {
guard selectedProblem != nil else { return }
let updatedAttempt = attempt.updated(
problemId: selectedProblem?.id,
result: selectedResult,
highestHold: highestHold.isEmpty ? nil : highestHold,
notes: notes.isEmpty ? nil : notes,

View File

@@ -128,7 +128,7 @@ struct LiveActivityDebugView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.padding(8)
.id("bottom")
.onChange(of: debugOutput) { _ in
.onChange(of: debugOutput) {
withAnimation {
proxy.scrollTo("bottom", anchor: .bottom)
}