Skip to content

Commit

Permalink
fix: Part #4 sync to upstream (#540)
Browse files Browse the repository at this point in the history
* fix: SE device UI issues (#39)

* fix: se device

* fix: course image

* fix: small course

* fix: header for ios 15

* fix: double nav bar

* chore: added trophy assets

* fix: fixed all courses screen

* fix: ipad course dashboard

* chore: fixed dates banner padding

* fix: ipad upgrade view

* chore: fix for rotation bug

* fix: scroll on home tab

* chore: update introspect for future versions

* chore: rename name of file icon

* chore: delete unneeded IAP icon

* chore: delete IAP part

* chore: delete IAP part

* chore: fix after merge

* chore: started to add courseRawImage

* chore: delete IAP part

* fix: after merge

* chore: deleted unsupported ios 15 modifiers

* chore: added courseRawImage

* chore: moved progress to correct place

* chore: fix broken tests

---------

Co-authored-by: Vadim Kuznetsov <[email protected]>
Co-authored-by: Anton Yarmolenko <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent 5645bce commit 21e94b6
Show file tree
Hide file tree
Showing 38 changed files with 372 additions and 272 deletions.
1 change: 1 addition & 0 deletions Core/Core/Data/Model/Data_Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public extension DataLayer.DiscoveryResponce {
courseID: $0.courseID ?? "",
numPages: pagination.numPages,
coursesCount: pagination.count,
courseRawImage: $0.media.image?.raw,
progressEarned: 0,
progressPossible: 0)
})
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Data/Model/Data_Enrollments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public extension DataLayer.CourseEnrollments {
courseID: course.id,
numPages: enrollments.numPages ?? 1,
coursesCount: enrollments.count ?? 0,
courseRawImage: course.media.courseImage?.url,
progressEarned: 0,
progressPossible: 0
)
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Data/Model/Data_PrimaryEnrollment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ public extension DataLayer.PrimaryEnrollment {
courseID: enrollment.course.id,
numPages: numPages,
coursesCount: count,
courseRawImage: enrollment.course.media.image?.raw,
progressEarned: enrollment.progress?.assignmentsCompleted ?? 0,
progressPossible: enrollment.progress?.totalAssignmentsCount ?? 0
)
Expand Down
3 changes: 3 additions & 0 deletions Core/Core/Domain/Model/CourseItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct CourseItem: Hashable {
public let courseID: String
public let numPages: Int
public let coursesCount: Int
public let courseRawImage: String?
public let progressEarned: Int
public let progressPossible: Int

Expand All @@ -35,6 +36,7 @@ public struct CourseItem: Hashable {
courseID: String,
numPages: Int,
coursesCount: Int,
courseRawImage: String?,
progressEarned: Int,
progressPossible: Int) {
self.name = name
Expand All @@ -49,6 +51,7 @@ public struct CourseItem: Hashable {
self.courseID = courseID
self.numPages = numPages
self.coursesCount = coursesCount
self.courseRawImage = courseRawImage
self.progressEarned = progressEarned
self.progressPossible = progressPossible
}
Expand Down
1 change: 1 addition & 0 deletions Core/Core/View/Base/CourseCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ struct CourseCellView_Previews: PreviewProvider {
courseID: "1",
numPages: 1,
coursesCount: 10,
courseRawImage: nil,
progressEarned: 4,
progressPossible: 10
)
Expand Down
10 changes: 9 additions & 1 deletion Core/Core/View/Base/DynamicOffsetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public struct DynamicOffsetView: View {

@Environment(\.isHorizontal) private var isHorizontal

@State private var isOnTheScreen: Bool = false
public init(
coordinate: Binding<CGFloat>,
collapsed: Binding<Bool>,
Expand All @@ -45,6 +46,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 @@ -59,8 +63,12 @@ public struct DynamicOffsetView: View {
}
)
.onAppear {
isOnTheScreen = true
changeCollapsedHeight(collapsed: collapsed, isHorizontal: isHorizontal)
}
.onDisappear {
isOnTheScreen = false
}
.onChange(of: collapsed) { collapsed in
if !collapsed {
changeCollapsedHeight(collapsed: collapsed, isHorizontal: isHorizontal)
Expand All @@ -87,7 +95,7 @@ public struct DynamicOffsetView: View {
collapseHeight = collapsedVerticalHeight
}
} else {
collapseHeight = 240
collapseHeight = expandedHeight
}
viewHeight = collapseHeight
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22758" systemVersion="23F79" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23507" systemVersion="24A348" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="CDCourseBlock" representedClassName="CDCourseBlock" syncable="YES" codeGenerationType="class">
<attribute name="allSources" optional="YES" attributeType="Transformable" valueTransformerName="NSSecureUnarchiveFromData" customClassName="[String]"/>
<attribute name="assignmentType" optional="YES" attributeType="String"/>
Expand Down Expand Up @@ -68,6 +68,7 @@
<attribute name="courseCount" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="courseEnd" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="courseID" optional="YES" attributeType="String"/>
<attribute name="courseRawImage" optional="YES" attributeType="String"/>
<attribute name="courseStart" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="desc" optional="YES" attributeType="String"/>
<attribute name="enrollmentEnd" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
Expand Down
27 changes: 17 additions & 10 deletions Course/Course/Presentation/Container/CourseContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Core
import Discussion
import Swinject
import Theme
@_spi(Advanced) import SwiftUIIntrospect

public struct CourseContainerView: View {

Expand All @@ -30,6 +31,7 @@ public struct CourseContainerView: View {
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }

private let coordinateBoundaryLower: CGFloat = -115
private let courseRawImage: String?

private var coordinateBoundaryHigher: CGFloat {
let topInset = UIApplication.shared.windowInsets.top
Expand All @@ -52,7 +54,8 @@ public struct CourseContainerView: View {
viewModel: CourseContainerViewModel,
courseDatesViewModel: CourseDatesViewModel,
courseID: String,
title: String
title: String,
courseRawImage: String?
) {
self.viewModel = viewModel
Task {
Expand All @@ -68,6 +71,7 @@ public struct CourseContainerView: View {
self.courseID = courseID
self.title = title
self.courseDatesViewModel = courseDatesViewModel
self.courseRawImage = courseRawImage
}

public var body: some View {
Expand Down Expand Up @@ -108,22 +112,24 @@ public struct CourseContainerView: View {
collapsed: $collapsed,
containerWidth: proxy.size.width,
animationNamespace: animationNamespace,
isAnimatingForTap: $isAnimatingForTap
isAnimatingForTap: $isAnimatingForTap,
courseRawImage: courseRawImage
)
}
.offset(
y: ignoreOffset
? (collapsed ? coordinateBoundaryLower : .zero)
: ((coordinateBoundaryLower...coordinateBoundaryHigher).contains(coordinate)
? coordinate
? (collapsed ? coordinateBoundaryLower : coordinate)
: (collapsed ? coordinateBoundaryLower : .zero))
)
backButton(containerWidth: proxy.size.width)
}
}.ignoresSafeArea(edges: idiom == .pad ? .leading : .top)
.onAppear {
self.collapsed = isHorizontal
}
}
.ignoresSafeArea(edges: idiom == .pad ? .leading : .top)
.onAppear {
self.collapsed = isHorizontal
}
}
}

Expand Down Expand Up @@ -282,7 +288,7 @@ public struct CourseContainerView: View {
}
}
.tabViewStyle(.page(indexDisplayMode: .never))
.introspect(.scrollView, on: .iOS(.v15, .v16, .v17), customize: { tabView in
.introspect(.scrollView, on: .iOS(.v16...), customize: { tabView in
tabView.isScrollEnabled = false
})
.onFirstAppear {
Expand Down Expand Up @@ -379,11 +385,12 @@ struct CourseScreensView_Previews: PreviewProvider {
config: ConfigMock(),
courseID: "1",
courseName: "a",
analytics: CourseAnalyticsMock(),
analytics: CourseAnalyticsMock(),
calendarManager: CalendarManagerMock()
),
courseID: "",
title: "Title of Course"
title: "Title of Course",
courseRawImage: nil
)
}
}
Expand Down
1 change: 0 additions & 1 deletion Course/Course/Presentation/Outline/ContinueWithView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct ContinueWithView: View {
.frame(width: 200)
}
.padding(.horizontal, 24)
.padding(.top, 32)
} else {
VStack(alignment: .leading) {
ContinueTitle(vertical: courseContinueUnit)
Expand Down
132 changes: 67 additions & 65 deletions Course/Course/Presentation/Outline/CourseOutlineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,79 +61,81 @@ public struct CourseOutlineView: View {
GeometryReader { proxy in
VStack(alignment: .center) {
ScrollView {
DynamicOffsetView(
coordinate: $coordinate,
collapsed: $collapsed,
viewHeight: $viewHeight
)
RefreshProgressView(isShowRefresh: $viewModel.isShowRefresh)
VStack(alignment: .leading) {

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,
!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()
}
VStack(spacing: 0) {
DynamicOffsetView(
coordinate: $coordinate,
collapsed: $collapsed,
viewHeight: $viewHeight
)
RefreshProgressView(isShowRefresh: $viewModel.isShowRefresh)
VStack(alignment: .leading) {

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

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(
isVideo: isVideo,
course: course,
proxy: proxy,
viewModel: viewModel
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(
isVideo: isVideo,
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: 200)
}
.frameLimit(width: proxy.size.width)
}
.frameLimit(width: proxy.size.width)
}
.refreshable {
Task {
Expand Down
Loading

0 comments on commit 21e94b6

Please sign in to comment.