O p t i m i z e
This commit is contained in:
@@ -27,7 +27,9 @@ struct SessionsView: View {
|
||||
EmptySessionsView()
|
||||
} else {
|
||||
if viewMode == .list {
|
||||
SessionsList()
|
||||
SessionsList(onNavigateToSession: { sessionId in
|
||||
selectedSessionId = sessionId
|
||||
})
|
||||
} else {
|
||||
CalendarView(
|
||||
sessions: completedSessions,
|
||||
@@ -108,6 +110,7 @@ struct SessionsView: View {
|
||||
struct SessionsList: View {
|
||||
@EnvironmentObject var dataManager: ClimbingDataManager
|
||||
@State private var sessionToDelete: ClimbSession?
|
||||
var onNavigateToSession: (UUID) -> Void
|
||||
|
||||
private var completedSessions: [ClimbSession] {
|
||||
dataManager.sessions
|
||||
@@ -121,7 +124,11 @@ struct SessionsList: View {
|
||||
let gym = dataManager.gym(withId: activeSession.gymId)
|
||||
{
|
||||
Section {
|
||||
ActiveSessionBanner(session: activeSession, gym: gym)
|
||||
ActiveSessionBanner(
|
||||
session: activeSession,
|
||||
gym: gym,
|
||||
onNavigateToSession: onNavigateToSession
|
||||
)
|
||||
.padding(.horizontal, 16)
|
||||
.listRowInsets(EdgeInsets(top: 16, leading: 0, bottom: 24, trailing: 0))
|
||||
.listRowBackground(Color.clear)
|
||||
@@ -183,8 +190,7 @@ struct ActiveSessionBanner: View {
|
||||
let session: ClimbSession
|
||||
let gym: Gym
|
||||
@EnvironmentObject var dataManager: ClimbingDataManager
|
||||
|
||||
@State private var navigateToDetail = false
|
||||
var onNavigateToSession: (UUID) -> Void
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
@@ -214,7 +220,7 @@ struct ActiveSessionBanner: View {
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
navigateToDetail = true
|
||||
onNavigateToSession(session.id)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
@@ -237,9 +243,7 @@ struct ActiveSessionBanner: View {
|
||||
.fill(.green.opacity(0.1))
|
||||
.stroke(.green.opacity(0.3), lineWidth: 1)
|
||||
)
|
||||
.navigationDestination(isPresented: $navigateToDetail) {
|
||||
SessionDetailView(sessionId: session.id)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user