Skip to content

Commit

Permalink
fix: header for ios 15
Browse files Browse the repository at this point in the history
  • Loading branch information
forgotvas committed Jul 24, 2024
1 parent 87f3a31 commit 4611a4b
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 206 deletions.
8 changes: 8 additions & 0 deletions Core/Core/View/Base/DynamicOffsetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public struct DynamicOffsetView: View {
@Environment(\.isHorizontal) private var isHorizontal
@Binding private var shouldHideMenuBar: Bool

@State private var isOnTheScreen: Bool = false
public init(
coordinate: Binding<CGFloat>,
collapsed: Binding<Bool>,
Expand All @@ -51,6 +52,9 @@ public struct DynamicOffsetView: View {
.frame(height: collapseHeight)
.overlay(
GeometryReader { geometry -> Color in
if !isOnTheScreen {
return .clear
}
guard idiom != .pad else {
return .clear
}
Expand All @@ -67,13 +71,17 @@ public struct DynamicOffsetView: View {
}
)
.onAppear {
isOnTheScreen = true
changeCollapsedHeight(
collapsed: collapsed,
isHorizontal: isHorizontal,
shouldShowUpgradeButton: shouldShowUpgradeButton,
shouldHideMenuBar: shouldHideMenuBar
)
}
.onDisappear {
isOnTheScreen = false
}
.onChange(of: shouldHideMenuBar) { shouldHideMenuBar in
changeCollapsedHeight(
collapsed: collapsed,
Expand Down
156 changes: 79 additions & 77 deletions Course/Course/Presentation/Outline/CourseOutlineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,92 +69,94 @@ public struct CourseOutlineView: View {
}
}
}) {
DynamicOffsetView(
coordinate: $coordinate,
collapsed: $collapsed,
viewHeight: $viewHeight,
shouldShowUpgradeButton: $viewModel.shouldShowUpgradeButton,
shouldHideMenuBar: $viewModel.shouldHideMenuBar
)
RefreshProgressView(isShowRefresh: $viewModel.isShowRefresh)
VStack(alignment: .leading) {
if let courseDeadlineInfo = viewModel.courseDeadlineInfo,
courseDeadlineInfo.datesBannerInfo.status == .resetDatesBanner,
!courseDeadlineInfo.hasEnded,
!isVideo {
DatesStatusInfoView(
datesBannerInfo: courseDeadlineInfo.datesBannerInfo,
courseID: courseID,
courseContainerViewModel: viewModel,
screen: .courseDashbaord
)
.padding(.horizontal, 16)
}

if isVideo,
viewModel.isShowProgress == false {
downloadQualityBars(proxy: proxy)
}
certificateView

if viewModel.courseStructure == nil,
viewModel.isShowProgress == false,
!isVideo {
FullScreenErrorView(
type: .noContent(
CourseLocalization.Error.coursewareUnavailable,
image: CoreAssets.information.swiftUIImage
)
)
.frame(maxWidth: .infinity)
.frame(height: proxy.size.height - viewHeight)
} else {
if let continueWith = viewModel.continueWith,
let courseStructure = viewModel.courseStructure,
VStack(spacing: 0) {
DynamicOffsetView(
coordinate: $coordinate,
collapsed: $collapsed,
viewHeight: $viewHeight,
shouldShowUpgradeButton: $viewModel.shouldShowUpgradeButton,
shouldHideMenuBar: $viewModel.shouldHideMenuBar
)
RefreshProgressView(isShowRefresh: $viewModel.isShowRefresh)
VStack(alignment: .leading) {
if let courseDeadlineInfo = viewModel.courseDeadlineInfo,
courseDeadlineInfo.datesBannerInfo.status == .resetDatesBanner,
!courseDeadlineInfo.hasEnded,
!isVideo {
let chapter = courseStructure.childs[continueWith.chapterIndex]
let sequential = chapter.childs[continueWith.sequentialIndex]
let continueUnit = sequential.childs[continueWith.verticalIndex]

ContinueWithView(
data: continueWith,
courseContinueUnit: continueUnit
) {
viewModel.openLastVisitedBlock()
}
DatesStatusInfoView(
datesBannerInfo: courseDeadlineInfo.datesBannerInfo,
courseID: courseID,
courseContainerViewModel: viewModel,
screen: .courseDashbaord
)
.padding(.horizontal, 16)
}

if let course = isVideo
? viewModel.courseVideosStructure
: viewModel.courseStructure {

if !isVideo,
let progress = course.courseProgress,
progress.totalAssignmentsCount != 0 {
CourseProgressView(progress: progress)
.padding(.horizontal, 24)
.padding(.top, 16)
.padding(.bottom, 8)
}

// MARK: - Sections
CustomDisclosureGroup(
course: course,
proxy: proxy,
viewModel: viewModel
if isVideo,
viewModel.isShowProgress == false {
downloadQualityBars(proxy: proxy)
}
certificateView

if viewModel.courseStructure == nil,
viewModel.isShowProgress == false,
!isVideo {
FullScreenErrorView(
type: .noContent(
CourseLocalization.Error.coursewareUnavailable,
image: CoreAssets.information.swiftUIImage
)
)
.frame(maxWidth: .infinity)
.frame(height: proxy.size.height - viewHeight)
} else {
if let courseStart = viewModel.courseStart {
Text(courseStart > Date() ? CourseLocalization.Outline.courseHasntStarted : "")
.frame(maxWidth: .infinity)
.frame(maxHeight: .infinity)
.padding(.top, 100)
if let continueWith = viewModel.continueWith,
let courseStructure = viewModel.courseStructure,
!isVideo {
let chapter = courseStructure.childs[continueWith.chapterIndex]
let sequential = chapter.childs[continueWith.sequentialIndex]
let continueUnit = sequential.childs[continueWith.verticalIndex]

ContinueWithView(
data: continueWith,
courseContinueUnit: continueUnit
) {
viewModel.openLastVisitedBlock()
}
}

if let course = isVideo
? viewModel.courseVideosStructure
: viewModel.courseStructure {

if !isVideo,
let progress = course.courseProgress,
progress.totalAssignmentsCount != 0 {
CourseProgressView(progress: progress)
.padding(.horizontal, 24)
.padding(.top, 16)
.padding(.bottom, 8)
}

// MARK: - Sections
CustomDisclosureGroup(
course: course,
proxy: proxy,
viewModel: viewModel
)
} else {
if let courseStart = viewModel.courseStart {
Text(courseStart > Date() ? CourseLocalization.Outline.courseHasntStarted : "")
.frame(maxWidth: .infinity)
.frame(maxHeight: .infinity)
.padding(.top, 100)
}
}
Spacer(minLength: viewHeight < 200 ? 200 : viewHeight)
}
Spacer(minLength: viewHeight < 200 ? 200 : viewHeight)
}
.frameLimit(width: proxy.size.width)
}
.frameLimit(width: proxy.size.width)
}
.onRightSwipeGesture {
viewModel.router.back()
Expand Down
Loading

0 comments on commit 4611a4b

Please sign in to comment.