Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SE device UI issues #39

Merged
merged 15 commits into from
Jul 26, 2024
2 changes: 1 addition & 1 deletion Core/Core/View/Base/DynamicOffsetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public struct DynamicOffsetView: View {
}

private func expandedHeight(shouldShowUpgradeButton: Bool, shouldHideMenuBar: Bool) -> CGFloat {
240 + (shouldShowUpgradeButton ? 63 : 0) - (shouldHideMenuBar ? 80 : 0)
expandedHeight + (shouldShowUpgradeButton ? 63 : 0) - (shouldHideMenuBar ? 80 : 0)
}

private func changeCollapsedHeight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public struct CourseContainerView: View {

return topInset
}
private var additionSpace: CGFloat {
viewModel.shouldShowUpgradeButton ? 60 : 0
}

private struct GeometryName {
static let backButton = "backButton"
Expand Down Expand Up @@ -106,8 +109,8 @@ public struct CourseContainerView: View {
.offset(
y: ignoreOffset
? (collapsed ? coordinateBoundaryLower : .zero)
: ((coordinateBoundaryLower...coordinateBoundaryHigher).contains(coordinate)
? coordinate
: ((coordinateBoundaryLower-additionSpace...coordinateBoundaryHigher).contains(coordinate)
? (collapsed ? coordinateBoundaryLower : coordinate)
: (collapsed ? coordinateBoundaryLower : .zero))
)
backButton(containerWidth: proxy.size.width)
Expand Down Expand Up @@ -337,7 +340,7 @@ public struct CourseContainerView: View {

private func collapseHeader(_ coordinate: CGFloat) {
guard !isHorizontal else { return collapsed = true }
let lowerBound: CGFloat = -90
let lowerBound: CGFloat = -90-additionSpace
let upperBound: CGFloat = 160

switch coordinate {
Expand Down
2 changes: 1 addition & 1 deletion Course/Course/Presentation/Outline/CourseOutlineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public struct CourseOutlineView: View {
.padding(.top, 100)
}
}
Spacer(minLength: 200)
Spacer(minLength: viewHeight < 200 ? 200 : viewHeight)
}
}
.frameLimit(width: proxy.size.width)
Expand Down
11 changes: 9 additions & 2 deletions Course/Course/Presentation/Subviews/CourseHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ struct CourseHeaderView: View {
var body: some View {
ZStack(alignment: .bottomLeading) {
ScrollView {
if let banner = (viewModel.courseStructure?.media.image.raw ?? courseRawImage)?
if let banner = (courseRawImage ?? viewModel.courseStructure?.media.image.raw)?
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
KFImage(URL(string: viewModel.config.baseURL.absoluteString + banner))
KFImage(courseBannerURL(for: banner))
.onFailureImage(CoreAssets.noCourseImage.image)
.resizable()
.aspectRatio(contentMode: .fill)
Expand Down Expand Up @@ -192,6 +192,13 @@ struct CourseHeaderView: View {
.ignoresSafeArea(edges: .top)
}

private func courseBannerURL(for path: String) -> URL? {
if path.contains("http://") || path.contains("https://") {
return URL(string: path)
}
return URL(string: viewModel.config.baseURL.absoluteString + path)
}

private func courseMenuBar(containerWidth: CGFloat) -> some View {
ScrollSlidingTabBar(
selection: $viewModel.selection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct PrimaryCourseDashboardView<ProgramView: View>: View {
enrollmentEnd: nil,
title: primary.name,
org: primary.org,
courseRawImage: nil,
courseRawImage: primary.courseBanner,
coursewareAccess: nil,
showDates: lastVisitedBlockID == nil,
lastVisitedBlockID: lastVisitedBlockID
Expand All @@ -104,7 +104,7 @@ public struct PrimaryCourseDashboardView<ProgramView: View>: View {
enrollmentEnd: nil,
title: primary.name,
org: primary.org,
courseRawImage: nil,
courseRawImage: primary.courseBanner,
coursewareAccess: nil,
showDates: false,
lastVisitedBlockID: nil
Expand All @@ -120,7 +120,7 @@ public struct PrimaryCourseDashboardView<ProgramView: View>: View {
enrollmentEnd: nil,
title: primary.name,
org: primary.org,
courseRawImage: nil,
courseRawImage: primary.courseBanner,
coursewareAccess: nil,
showDates: false,
lastVisitedBlockID: primary.lastVisitedBlockID
Expand All @@ -136,7 +136,9 @@ public struct PrimaryCourseDashboardView<ProgramView: View>: View {
sku: primary.sku ?? "",
courseID: primary.courseID,
screen: .dashboard,
pacing: primary.isSelfPaced ? Pacing.selfPace.rawValue : Pacing.instructor.rawValue,
pacing: primary.isSelfPaced ?
Pacing.selfPace.rawValue :
Pacing.instructor.rawValue,
lmsPrice: primary.lmsPrice ?? .zero
)
}
Expand Down Expand Up @@ -244,7 +246,7 @@ public struct PrimaryCourseDashboardView<ProgramView: View>: View {
enrollmentEnd: course.enrollmentEnd,
title: course.name,
org: course.org,
courseRawImage: course.courseRawImage,
courseRawImage: course.imageURL,
coursewareAccess: course.coursewareAccess,
showDates: false,
lastVisitedBlockID: nil
Expand Down
Loading