Skip to content

Commit

Permalink
Merge pull request #983 from StepicOrg/release/1.175
Browse files Browse the repository at this point in the history
Release 1.175
  • Loading branch information
ivan-magda authored Jun 4, 2021
2 parents c12cae4 + 2a30e17 commit f2a41a7
Show file tree
Hide file tree
Showing 70 changed files with 3,086 additions and 99 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"
ruby "2.6.5"

gem "fastlane", "2.184.0"
gem "fastlane", "2.184.1"
gem "cocoapods", "1.10.1"
gem "generamba", "1.5.0"

Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.1.1)
aws-partitions (1.461.0)
aws-partitions (1.465.0)
aws-sdk-core (3.114.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
Expand All @@ -24,7 +24,7 @@ GEM
aws-sdk-kms (1.43.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.95.0)
aws-sdk-s3 (1.95.1)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -84,7 +84,7 @@ GEM
escape (0.0.4)
ethon (0.14.0)
ffi (>= 1.15.0)
excon (0.81.0)
excon (0.82.0)
faraday (1.4.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand All @@ -104,7 +104,7 @@ GEM
faraday_middleware (1.0.0)
faraday (~> 1.0)
fastimage (2.2.3)
fastlane (2.184.0)
fastlane (2.184.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -155,7 +155,7 @@ GEM
xcodeproj (>= 1.5.0, < 2.0.0)
gh_inspector (1.1.3)
git (1.2.9.1)
google-apis-androidpublisher_v3 (0.3.0)
google-apis-androidpublisher_v3 (0.4.0)
google-apis-core (~> 0.1)
google-apis-core (0.3.0)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -167,11 +167,11 @@ GEM
rexml
signet (~> 0.14)
webrick
google-apis-iamcredentials_v1 (0.3.0)
google-apis-iamcredentials_v1 (0.4.0)
google-apis-core (~> 0.1)
google-apis-playcustomapp_v1 (0.2.0)
google-apis-playcustomapp_v1 (0.3.0)
google-apis-core (~> 0.1)
google-apis-storage_v1 (0.3.0)
google-apis-storage_v1 (0.4.0)
google-apis-core (~> 0.1)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
Expand Down Expand Up @@ -273,7 +273,7 @@ PLATFORMS

DEPENDENCIES
cocoapods (= 1.10.1)
fastlane (= 2.184.0)
fastlane (= 2.184.1)
fastlane-plugin-firebase_app_distribution
generamba (= 1.5.0)

Expand Down
204 changes: 192 additions & 12 deletions Stepic.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Stepic/Images.xcassets/New course list/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "user-courses-reviews-block-stars.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
4 changes: 2 additions & 2 deletions Stepic/Info-Develop.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.174-develop</string>
<string>1.175-develop</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -62,7 +62,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>333</string>
<string>335</string>
<key>FacebookAppID</key>
<string>171127739724012</string>
<key>FacebookDisplayName</key>
Expand Down
4 changes: 2 additions & 2 deletions Stepic/Info-Production.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.174</string>
<string>1.175</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -62,7 +62,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>333</string>
<string>335</string>
<key>FacebookAppID</key>
<string>171127739724012</string>
<key>FacebookDisplayName</key>
Expand Down
4 changes: 2 additions & 2 deletions Stepic/Info-Release.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.174-release</string>
<string>1.175-release</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -62,7 +62,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>333</string>
<string>335</string>
<key>FacebookAppID</key>
<string>171127739724012</string>
<key>FacebookDisplayName</key>
Expand Down
12 changes: 11 additions & 1 deletion Stepic/Legacy/Analytics/Events/AmplitudeAnalyticsEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ extension AnalyticsEvent {
case widgetExtension(url: String)
case notification
case profile(id: Int)
case userCoursesReviews
case unknown

var name: String {
Expand Down Expand Up @@ -551,14 +552,23 @@ extension AnalyticsEvent {
return "notification"
case .profile:
return "profile"
case .userCoursesReviews:
return "user_courses_reviews"
case .unknown:
return "unknown"
}
}

var params: [String: Any]? {
switch self {
case .myCourses, .visitedCourses, .downloads, .fastContinue, .notification, .unknown, .recommendation:
case .myCourses,
.visitedCourses,
.downloads,
.fastContinue,
.notification,
.recommendation,
.userCoursesReviews,
.unknown:
return nil
case .search(let query):
return ["query": query]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ extension StepikPlaceholder.Style {
text: NSLocalizedString("SubmissionsPlaceholderEmptyTitle", comment: ""),
buttonTitle: nil
)
static let emptyReviews = StepikPlaceholderStyle(
id: "emptyReviews",
image: PlaceholderImage(image: UIImage(named: "new-empty-empty"), scale: 0.99),
text: NSLocalizedString("UserCoursesReviewsPlaceholderEmptyTitle", comment: ""),
buttonTitle: nil
)
static let emptyProfileLoading = StepikPlaceholderStyle(
id: "emptyProfileLoading",
image: PlaceholderImage(image: UIImage(named: "new-empty-empty"), scale: 0.99),
Expand Down
24 changes: 24 additions & 0 deletions Stepic/Legacy/Model/Entities/CourseReview/CourseReview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ final class CourseReview: NSManagedObject, JSONSerializable, IDFetchable {
}
}

static func fetch(userID: User.IdType) -> Guarantee<[CourseReview]> {
let request = CourseReview.fetchRequest
let descriptor = NSSortDescriptor(key: "managedId", ascending: false)

let predicate = NSPredicate(format: "managedUserId == %@", userID.fetchValue)

request.predicate = predicate
request.sortDescriptors = [descriptor]

return Guarantee { seal in
DispatchQueue.doWorkOnMain {
let context = CoreDataHelper.shared.context
context.performAndWait {
do {
let courseReviews = try context.fetch(request)
seal(courseReviews)
} catch {
seal([])
}
}
}
}
}

static func fetch(courseID: Course.IdType, userID: User.IdType) -> Guarantee<[CourseReview]> {
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "CourseReview")
let descriptor = NSSortDescriptor(key: "managedId", ascending: false)
Expand Down
38 changes: 38 additions & 0 deletions Stepic/Legacy/Model/Network/Endpoints/CourseReviewsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,44 @@ final class CourseReviewsAPI: APIEndpoint {
}
}

/// Get course review by user id.
func retrieve(userID: User.IdType, page: Int = 1) -> Promise<([CourseReview], Meta)> {
Promise { seal in
let parameters: Parameters = [
"user": userID,
"page": page
]

CourseReview.fetch(userID: userID).then {
cachedReviews -> Promise<([CourseReview], Meta, JSON)> in
self.retrieve.request(
requestEndpoint: self.name,
paramName: self.name,
params: parameters,
updatingObjects: cachedReviews,
withManager: self.manager
)
}.done { reviews, meta, _ in
seal.fulfill((reviews, meta))
}.catch { error in
seal.reject(error)
}
}
}

/// Get all course reviews by user id.
func retrieveAll(userID: User.IdType) -> Promise<[CourseReview]> {
CourseReview.fetch(userID: userID).then {
self.retrieve.requestWithCollectAllPages(
requestEndpoint: self.name,
paramName: self.name,
params: ["user": userID],
updatingObjects: $0,
withManager: self.manager
)
}
}

func create(
courseID: Course.IdType,
userID: User.IdType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ final class RetrieveRequestMaker {
requestEndpoint: String,
paramName: String,
params: Parameters,
updatingObjects: [T] = [],
withManager manager: Alamofire.Session
) -> Promise<[T]> {
var allObjects = [T]()
Expand All @@ -147,7 +148,7 @@ final class RetrieveRequestMaker {
requestEndpoint: requestEndpoint,
paramName: paramName,
params: currentPageParams,
updatingObjects: [],
updatingObjects: updatingObjects,
withManager: manager
)
}.done { objects, meta in
Expand Down
6 changes: 4 additions & 2 deletions Stepic/Legacy/Model/PlainObjects/CoursePlainObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
struct CoursePlainObject {
let id: Int
let title: String
let coverURLString: String
let sectionsIDs: [Int]
let sections: [SectionPlainObject]
let isEnrolled: Bool
Expand All @@ -11,11 +12,12 @@ struct CoursePlainObject {
}

extension CoursePlainObject {
init(course: Course) {
init(course: Course, withSections: Bool = true) {
self.id = course.id
self.title = course.title
self.coverURLString = course.coverURLString
self.sectionsIDs = course.sectionsArray
self.sections = course.sections.map(SectionPlainObject.init)
self.sections = withSections ? course.sections.map(SectionPlainObject.init) : []
self.isEnrolled = course.enrolled
self.isPaid = course.isPaid
self.isProctored = course.isProctored
Expand Down
26 changes: 26 additions & 0 deletions Stepic/Legacy/Model/PlainObjects/CourseReviewPlainObject.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation

struct CourseReviewPlainObject {
let id: Int
let courseID: Int
let userID: Int
let score: Int
let text: String
let creationDate: Date
var course: CoursePlainObject?
}

extension CourseReviewPlainObject {
init(courseReview: CourseReview) {
self.id = courseReview.id
self.courseID = courseReview.courseID
self.userID = courseReview.userID
self.score = courseReview.score
self.text = courseReview.text
self.creationDate = courseReview.creationDate

if let course = courseReview.course {
self.course = CoursePlainObject(course: course, withSections: false)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import SnapKit
import UIKit

extension UserCoursesReviewsBlockSkeletonView {
struct Appearance {
let cornerRadius: CGFloat = 4
}
}

final class UserCoursesReviewsBlockSkeletonView: UIView {
let appearance: Appearance

private lazy var titleLabelSkeleton = UIView()

init(
frame: CGRect = .zero,
appearance: Appearance = Appearance()
) {
self.appearance = appearance
super.init(frame: frame)

self.setupView()
self.addSubviews()
self.makeConstraints()
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

extension UserCoursesReviewsBlockSkeletonView: ProgrammaticallyInitializableViewProtocol {
func setupView() {
self.backgroundColor = .clear

self.titleLabelSkeleton.clipsToBounds = true
self.titleLabelSkeleton.layer.cornerRadius = self.appearance.cornerRadius
}

func addSubviews() {
self.addSubview(self.titleLabelSkeleton)
}

func makeConstraints() {
self.titleLabelSkeleton.translatesAutoresizingMaskIntoConstraints = false
self.titleLabelSkeleton.snp.makeConstraints { $0.edges.equalToSuperview() }
}
}
Loading

0 comments on commit f2a41a7

Please sign in to comment.