iOS and Android dependency updates and optimizations
This commit is contained in:
@@ -62,7 +62,6 @@ struct SessionsView: View {
|
||||
)
|
||||
}
|
||||
|
||||
// View mode toggle
|
||||
if !dataManager.sessions.isEmpty || dataManager.activeSession != nil {
|
||||
Button(action: {
|
||||
withAnimation(.easeInOut(duration: 0.2)) {
|
||||
@@ -116,7 +115,6 @@ struct SessionsList: View {
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
// Active session banner section
|
||||
if let activeSession = dataManager.activeSession,
|
||||
let gym = dataManager.gym(withId: activeSession.gymId)
|
||||
{
|
||||
@@ -130,7 +128,6 @@ struct SessionsList: View {
|
||||
}
|
||||
}
|
||||
|
||||
// Completed sessions section
|
||||
if !completedSessions.isEmpty {
|
||||
Section {
|
||||
ForEach(completedSessions) { session in
|
||||
@@ -156,16 +153,23 @@ struct SessionsList: View {
|
||||
}
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.alert("Delete Session", isPresented: .constant(sessionToDelete != nil)) {
|
||||
Button("Cancel", role: .cancel) {
|
||||
sessionToDelete = nil
|
||||
}
|
||||
.confirmationDialog(
|
||||
"Delete Session",
|
||||
isPresented: .init(
|
||||
get: { sessionToDelete != nil },
|
||||
set: { if !$0 { sessionToDelete = nil } }
|
||||
),
|
||||
titleVisibility: .visible
|
||||
) {
|
||||
Button("Delete", role: .destructive) {
|
||||
if let session = sessionToDelete {
|
||||
dataManager.deleteSession(session)
|
||||
sessionToDelete = nil
|
||||
}
|
||||
}
|
||||
Button("Cancel", role: .cancel) {
|
||||
sessionToDelete = nil
|
||||
}
|
||||
} message: {
|
||||
Text(
|
||||
"Are you sure you want to delete this session? This will also delete all attempts associated with this session."
|
||||
@@ -178,18 +182,8 @@ struct ActiveSessionBanner: View {
|
||||
let session: ClimbSession
|
||||
let gym: Gym
|
||||
@EnvironmentObject var dataManager: ClimbingDataManager
|
||||
@State private var navigateToDetail = false
|
||||
|
||||
// Access MusicService via DataManager if possible, or EnvironmentObject if injected
|
||||
// Since DataManager holds MusicService, we can access it through there if we expose it or inject it.
|
||||
// In SettingsView we saw .environmentObject(dataManager.musicService).
|
||||
// We should probably inject it here too or access via dataManager if it's public.
|
||||
// Let's check ClimbingDataManager again. It has `let musicService = MusicService.shared`.
|
||||
// But it's not @Published so it won't trigger updates unless we observe the service itself.
|
||||
// The best way is to use @EnvironmentObject var musicService: MusicService
|
||||
// and ensure it's injected in the parent view.
|
||||
|
||||
@EnvironmentObject var musicService: MusicService
|
||||
@State private var navigateToDetail = false
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
@@ -213,7 +207,7 @@ struct ActiveSessionBanner: View {
|
||||
.foregroundColor(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
|
||||
|
||||
if musicService.isMusicEnabled && musicService.isAuthorized {
|
||||
Button(action: {
|
||||
musicService.togglePlayback()
|
||||
@@ -251,7 +245,6 @@ struct ActiveSessionBanner: View {
|
||||
.fill(.green.opacity(0.1))
|
||||
.stroke(.green.opacity(0.3), lineWidth: 1)
|
||||
)
|
||||
|
||||
.navigationDestination(isPresented: $navigateToDetail) {
|
||||
SessionDetailView(sessionId: session.id)
|
||||
}
|
||||
@@ -262,6 +255,12 @@ struct SessionRow: View {
|
||||
let session: ClimbSession
|
||||
@EnvironmentObject var dataManager: ClimbingDataManager
|
||||
|
||||
private static let dateFormatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
return formatter
|
||||
}()
|
||||
|
||||
private var gym: Gym? {
|
||||
dataManager.gym(withId: session.gymId)
|
||||
}
|
||||
@@ -275,7 +274,7 @@ struct SessionRow: View {
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(formatDate(session.date))
|
||||
Text(Self.dateFormatter.string(from: session.date))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
@@ -295,12 +294,6 @@ struct SessionRow: View {
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
|
||||
private func formatDate(_ date: Date) -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
}
|
||||
|
||||
struct EmptySessionsView: View {
|
||||
|
||||
Reference in New Issue
Block a user