diff --git a/Uplift.xcodeproj/project.pbxproj b/Uplift.xcodeproj/project.pbxproj index e2f1add..e333a65 100644 --- a/Uplift.xcodeproj/project.pbxproj +++ b/Uplift.xcodeproj/project.pbxproj @@ -902,7 +902,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 34; + CURRENT_PROJECT_VERSION = 35; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ZGMCXU7X3U; ENABLE_PREVIEWS = YES; @@ -946,7 +946,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 34; + CURRENT_PROJECT_VERSION = 35; DEVELOPMENT_TEAM = ZGMCXU7X3U; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; diff --git a/Uplift/Utils/Constants.swift b/Uplift/Utils/Constants.swift index 3a33ce1..53d6eae 100644 --- a/Uplift/Utils/Constants.swift +++ b/Uplift/Utils/Constants.swift @@ -126,9 +126,10 @@ struct Constants { static let gymDetailHorizontal: CGFloat = 24 static let gymDetailSpacing: CGFloat = 20 static let homeHorizontal: CGFloat = 16 + static let tabBarHeight: CGFloat = 64 } - /// Shadows usde in Uplift's design system. + /// Shadows used in Uplift's design system. enum Shadows { static let normalDark = ShadowConfig( color: Constants.Colors.black, diff --git a/Uplift/Views/Classes/ClassDetailView.swift b/Uplift/Views/Classes/ClassDetailView.swift index cac986d..a3f7fed 100644 --- a/Uplift/Views/Classes/ClassDetailView.swift +++ b/Uplift/Views/Classes/ClassDetailView.swift @@ -13,10 +13,10 @@ struct ClassDetailView: View { // MARK: - Properties - let classInstance: FitnessClassInstance - - @ObservedObject var viewModel: ClassesView.ViewModel + @State var classInstance: FitnessClassInstance @Environment(\.dismiss) private var dismiss + private let topViewId: String = "topId" + @ObservedObject var viewModel: ClassesView.ViewModel // MARK: - Constants @@ -38,28 +38,31 @@ struct ClassDetailView: View { var body: some View { NavigationStack { - ScrollView(.vertical, showsIndicators: false) { - scrollContent - } - .ignoresSafeArea(.all) - .padding(.bottom) - .navigationBarBackButtonHidden(true) - .toolbarBackground(.hidden, for: .navigationBar) - .toolbar { - ToolbarItem(placement: .topBarLeading) { - NavBackButton(dismiss: dismiss) + ScrollViewReader { reader in + ScrollView(.vertical, showsIndicators: false) { + scrollContent(reader) + } + .ignoresSafeArea(.all) + .padding(.bottom) + .navigationBarBackButtonHidden(true) + .toolbarBackground(.hidden, for: .navigationBar) + .toolbar { + ToolbarItem(placement: .topBarLeading) { + NavBackButton(dismiss: dismiss) + } + } + .background(Constants.Colors.white) + .onAppear { + viewModel.fetchAllClasses() } - } - .background(Constants.Colors.white) - .onAppear { - viewModel.fetchAllClasses() } } } - private var scrollContent: some View { + private func scrollContent(_ reader: ScrollViewProxy) -> some View { VStack(spacing: 0) { heroSection + .id(topViewId) dateTimeSection DividerLine() // TODO: Function data is not in backend @@ -70,7 +73,7 @@ struct ClassDetailView: View { // DividerLine() descriptionSection DividerLine() - nextSessionsSection + nextSessionsSection(reader) } .padding(.bottom) } @@ -210,7 +213,7 @@ struct ClassDetailView: View { .padding(textPadding) } - private var nextSessionsSection: some View { + private func nextSessionsSection(_ reader: ScrollViewProxy) -> some View { VStack(spacing: 24) { Text("NEXT SESSIONS") .font(Constants.Fonts.h2) @@ -225,8 +228,11 @@ struct ClassDetailView: View { } } else { ForEach(viewModel.nextSessions(classInstance: classInstance), id: \.self) { classInstance in - NavigationLink { - ClassDetailView(classInstance: classInstance, viewModel: viewModel) + Button { + withAnimation { + self.classInstance = classInstance + reader.scrollTo(topViewId) + } } label: { NextSessionCell(classInstance: classInstance, viewModel: viewModel) } diff --git a/Uplift/Views/ClassesView.swift b/Uplift/Views/ClassesView.swift index 9181f29..4dec167 100644 --- a/Uplift/Views/ClassesView.swift +++ b/Uplift/Views/ClassesView.swift @@ -64,7 +64,7 @@ struct ClassesView: View { calendarView classesOnDay } - .padding(.bottom, 32) + .padding(.bottom, 32 + Constants.Padding.tabBarHeight) } .refreshable { viewModel.refreshClasses() diff --git a/Uplift/Views/HomeView.swift b/Uplift/Views/HomeView.swift index 81f6f1e..5cc46da 100644 --- a/Uplift/Views/HomeView.swift +++ b/Uplift/Views/HomeView.swift @@ -174,7 +174,7 @@ struct HomeView: View { EdgeInsets( top: 12, leading: Constants.Padding.homeHorizontal, - bottom: 32, + bottom: 32 + Constants.Padding.tabBarHeight, trailing: Constants.Padding.homeHorizontal ) ) diff --git a/Uplift/Views/MainView.swift b/Uplift/Views/MainView.swift index eaff7f2..633e299 100644 --- a/Uplift/Views/MainView.swift +++ b/Uplift/Views/MainView.swift @@ -29,7 +29,8 @@ struct MainView: View { ClassesView() .environmentObject(tabBarProp) } - + } + .overlay(alignment: .bottom) { !tabBarProp.hidden ? tabBar.transition(.move(edge: .bottom)) : nil } @@ -75,7 +76,7 @@ struct MainView: View { Spacer() } - .frame(height: 64) + .frame(height: Constants.Padding.tabBarHeight) .background(Constants.Colors.yellow) .ignoresSafeArea(.all) }