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

feat: [FC-0047] Course progress and collapsing sections #446

Merged
4 changes: 0 additions & 4 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
BA8FA6702AD59EA300EA029A /* MicrosoftAuthProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA8FA66F2AD59EA300EA029A /* MicrosoftAuthProvider.swift */; };
BA981BCE2B8F5C49005707C2 /* Sequence+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA981BCD2B8F5C49005707C2 /* Sequence+Extensions.swift */; };
BA981BD02B91ED50005707C2 /* FullScreenProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA981BCF2B91ED50005707C2 /* FullScreenProgressView.swift */; };
BAAD62C62AFCF00B000E6103 /* CustomDisclosureGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */; };
BAD9CA2F2B289B3500DE790A /* ajaxHandler.js in Resources */ = {isa = PBXBuildFile; fileRef = BAD9CA2E2B289B3500DE790A /* ajaxHandler.js */; };
BAD9CA332B28A8F300DE790A /* AjaxProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAD9CA322B28A8F300DE790A /* AjaxProvider.swift */; };
BAD9CA422B2B140100DE790A /* AgreementConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */; };
Expand Down Expand Up @@ -347,7 +346,6 @@
BA8FA66F2AD59EA300EA029A /* MicrosoftAuthProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosoftAuthProvider.swift; sourceTree = "<group>"; };
BA981BCD2B8F5C49005707C2 /* Sequence+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Sequence+Extensions.swift"; sourceTree = "<group>"; };
BA981BCF2B91ED50005707C2 /* FullScreenProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullScreenProgressView.swift; sourceTree = "<group>"; };
BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDisclosureGroup.swift; sourceTree = "<group>"; };
BAD9CA2E2B289B3500DE790A /* ajaxHandler.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = ajaxHandler.js; sourceTree = "<group>"; };
BAD9CA322B28A8F300DE790A /* AjaxProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AjaxProvider.swift; sourceTree = "<group>"; };
BAD9CA412B2B140100DE790A /* AgreementConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgreementConfigTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -731,7 +729,6 @@
023A1137291432FD00D0D354 /* FieldConfiguration.swift */,
BA4AFB412B5A7A0900A21367 /* VideoDownloadQualityView.swift */,
BA593F1A2AF8E487009ADB51 /* ScrollSlidingTabBar */,
BAAD62C52AFCF00B000E6103 /* CustomDisclosureGroup.swift */,
BA8FA6672AD59A5700EA029A /* SocialAuthButton.swift */,
02E93F862AEBAED4006C4750 /* AppReview */,
BA981BCF2B91ED50005707C2 /* FullScreenProgressView.swift */,
Expand Down Expand Up @@ -1191,7 +1188,6 @@
02F164372902A9EB0090DDEF /* StringExtension.swift in Sources */,
0231CDBE2922422D00032416 /* CSSInjector.swift in Sources */,
064987982B4D69FF0071642A /* CSSInjectionProtocol.swift in Sources */,
BAAD62C62AFCF00B000E6103 /* CustomDisclosureGroup.swift in Sources */,
BADB3F5B2AD6EC56004D5CFA /* ResultExtension.swift in Sources */,
0236961928F9A26900EEF206 /* AuthRepository.swift in Sources */,
023A1136291432B200D0D354 /* RegistrationTextField.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Frame-17.svg",
"filename" : "deleteDownloading.svg",
"idiom" : "universal"
}
],
Expand Down

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"images" : [
{
"filename" : "Frame-16.svg",
"filename" : "startDownloading.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Core/Core/Assets.xcassets/chevron_right.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "chevron_right.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
15 changes: 15 additions & 0 deletions Core/Core/Assets.xcassets/chevron_right.imageset/chevron_right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions Core/Core/Assets.xcassets/finished_sequence.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "finished_sequence.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions Core/Core/Configuration/Config/UIComponentsConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import Foundation

private enum Keys: String, RawStringExtractable {
case courseNestedListEnabled = "COURSE_NESTED_LIST_ENABLED"
case courseDropDownNavigationEnabled = "COURSE_DROPDOWN_NAVIGATION_ENABLED"
case courseUnitProgressEnabled = "COURSE_UNIT_PROGRESS_ENABLED"
}

public class UIComponentsConfig: NSObject {
public var courseNestedListEnabled: Bool
public var courseDropDownNavigationEnabled: Bool
public var courseUnitProgressEnabled: Bool

init(dictionary: [String: Any]) {
courseNestedListEnabled = dictionary[Keys.courseNestedListEnabled] as? Bool ?? false
courseDropDownNavigationEnabled = dictionary[Keys.courseDropDownNavigationEnabled] as? Bool ?? false
courseUnitProgressEnabled = dictionary[Keys.courseUnitProgressEnabled] as? Bool ?? false
super.init()
}
Expand Down
38 changes: 36 additions & 2 deletions Core/Core/Domain/Model/CourseBlockModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public struct CourseStructure: Equatable {
public let certificate: Certificate?
public let org: String
public let isSelfPaced: Bool
public let courseProgress: CourseProgress?

public init(
id: String,
Expand All @@ -37,7 +38,8 @@ public struct CourseStructure: Equatable {
media: DataLayer.CourseMedia,
certificate: Certificate?,
org: String,
isSelfPaced: Bool
isSelfPaced: Bool,
courseProgress: CourseProgress?
) {
self.id = id
self.graded = graded
Expand All @@ -51,6 +53,7 @@ public struct CourseStructure: Equatable {
self.certificate = certificate
self.org = org
self.isSelfPaced = isSelfPaced
self.courseProgress = courseProgress
}

public func totalVideosSizeInBytes(downloadQuality: DownloadQuality) -> Int {
Expand Down Expand Up @@ -78,6 +81,16 @@ public struct CourseStructure: Equatable {
}
}

public struct CourseProgress {
public let totalAssignmentsCount: Int?
public let assignmentsCompleted: Int?

public init(totalAssignmentsCount: Int, assignmentsCompleted: Int) {
self.totalAssignmentsCount = totalAssignmentsCount
self.assignmentsCompleted = assignmentsCompleted
}
}

public struct CourseChapter: Identifiable {

public let blockId: String
Expand Down Expand Up @@ -109,6 +122,8 @@ public struct CourseSequential: Identifiable {
public let type: BlockType
public let completion: Double
public var childs: [CourseVertical]
public let sequentialProgress: SequentialProgress?
public let due: Date?

public var isDownloadable: Bool {
return childs.first(where: { $0.isDownloadable }) != nil
Expand All @@ -120,14 +135,18 @@ public struct CourseSequential: Identifiable {
displayName: String,
type: BlockType,
completion: Double,
childs: [CourseVertical]
childs: [CourseVertical],
sequentialProgress: SequentialProgress?,
due: Date?
) {
self.blockId = blockId
self.id = id
self.displayName = displayName
self.type = type
self.completion = completion
self.childs = childs
self.sequentialProgress = sequentialProgress
self.due = due
}
}

Expand Down Expand Up @@ -177,6 +196,18 @@ public struct SubtitleUrl: Equatable {
}
}

public struct SequentialProgress {
public let assignmentType: String?
public let numPointsEarned: Int?
public let numPointsPossible: Int?

public init(assignmentType: String?, numPointsEarned: Int?, numPointsPossible: Int?) {
self.assignmentType = assignmentType
self.numPointsEarned = numPointsEarned
self.numPointsPossible = numPointsPossible
}
}

public struct CourseBlock: Hashable, Identifiable {
public static func == (lhs: CourseBlock, rhs: CourseBlock) -> Bool {
lhs.id == rhs.id &&
Expand All @@ -193,6 +224,7 @@ public struct CourseBlock: Hashable, Identifiable {
public let courseId: String
public let topicId: String?
public let graded: Bool
public let due: Date?
public var completion: Double
public let type: BlockType
public let displayName: String
Expand All @@ -212,6 +244,7 @@ public struct CourseBlock: Hashable, Identifiable {
courseId: String,
topicId: String? = nil,
graded: Bool,
due: Date?,
completion: Double,
type: BlockType,
displayName: String,
Expand All @@ -226,6 +259,7 @@ public struct CourseBlock: Hashable, Identifiable {
self.courseId = courseId
self.topicId = topicId
self.graded = graded
self.due = due
self.completion = completion
self.type = type
self.displayName = displayName
Expand Down
14 changes: 14 additions & 0 deletions Core/Core/Extensions/DateExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public extension Date {
}

public enum DateStringStyle {
case courseStartsMonthDDYear
case courseEndsMonthDDYear
case startDDMonthYear
case endedMonthDay
case mmddyy
Expand Down Expand Up @@ -103,6 +105,10 @@ public extension Date {
dateFormatter.locale = Locale(identifier: "en_US_POSIX")

switch style {
case .courseStartsMonthDDYear:
dateFormatter.dateFormat = CoreLocalization.DateFormat.mmmDdYyyy
case .courseEndsMonthDDYear:
dateFormatter.dateFormat = CoreLocalization.DateFormat.mmmDdYyyy
case .endedMonthDay:
dateFormatter.dateFormat = CoreLocalization.DateFormat.mmmmDd
case .mmddyy:
Expand All @@ -122,6 +128,14 @@ public extension Date {
let date = dateFormatter.string(from: self)

switch style {
case .courseStartsMonthDDYear:
return CoreLocalization.Date.courseStarts + " " + date
case .courseEndsMonthDDYear:
if Date() < self {
return CoreLocalization.Date.courseEnds + " " + date
} else {
return CoreLocalization.Date.courseEnded + " " + date
}
case .endedMonthDay:
return CoreLocalization.Date.ended + " " + date
case .mmddyy, .monthYear:
Expand Down
1 change: 1 addition & 0 deletions Core/Core/Extensions/Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation

public extension Notification.Name {
static let onCourseEnrolled = Notification.Name("onCourseEnrolled")
static let onblockCompletionRequested = Notification.Name("onblockCompletionRequested")
static let onTokenRefreshFailed = Notification.Name("onTokenRefreshFailed")
static let onActualVersionReceived = Notification.Name("onActualVersionReceived")
static let onAppUpgradeAccountSettingsTapped = Notification.Name("onAppUpgradeAccountSettingsTapped")
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/SwiftGen/Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ public enum CoreAssets {
public static let certificateBadge = ImageAsset(name: "certificateBadge")
public static let check = ImageAsset(name: "check")
public static let checkEmail = ImageAsset(name: "checkEmail")
public static let chevronRight = ImageAsset(name: "chevron_right")
public static let clearInput = ImageAsset(name: "clearInput")
public static let edit = ImageAsset(name: "edit")
public static let favorite = ImageAsset(name: "favorite")
public static let finishedSequence = ImageAsset(name: "finished_sequence")
public static let goodWork = ImageAsset(name: "goodWork")
public static let airmail = ImageAsset(name: "airmail")
public static let defaultMail = ImageAsset(name: "defaultMail")
Expand Down
6 changes: 6 additions & 0 deletions Core/Core/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public enum CoreLocalization {
}
}
public enum Date {
/// Course Ended
public static let courseEnded = CoreLocalization.tr("Localizable", "DATE.COURSE_ENDED", fallback: "Course Ended")
/// Course Ends
public static let courseEnds = CoreLocalization.tr("Localizable", "DATE.COURSE_ENDS", fallback: "Course Ends")
/// Course Starts
public static let courseStarts = CoreLocalization.tr("Localizable", "DATE.COURSE_STARTS", fallback: "Course Starts")
/// Ended
public static let ended = CoreLocalization.tr("Localizable", "DATE.ENDED", fallback: "Ended")
/// Just now
Expand Down
49 changes: 0 additions & 49 deletions Core/Core/View/Base/CustomDisclosureGroup.swift

This file was deleted.

Loading