From 5854e468fa5407f9517b44373b10d0cc688b7aab Mon Sep 17 00:00:00 2001 From: Ivan Magda Date: Sun, 16 Feb 2020 12:20:17 +0300 Subject: [PATCH 1/9] Download images in foreground --- .../DownloadingService/DownloadingServiceFactory.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Stepic/Sources/Frameworks/Downloader/DownloadingService/DownloadingServiceFactory.swift b/Stepic/Sources/Frameworks/Downloader/DownloadingService/DownloadingServiceFactory.swift index b069a22529..0c817b6e02 100644 --- a/Stepic/Sources/Frameworks/Downloader/DownloadingService/DownloadingServiceFactory.swift +++ b/Stepic/Sources/Frameworks/Downloader/DownloadingService/DownloadingServiceFactory.swift @@ -2,7 +2,7 @@ import Foundation enum DownloadingServiceFactory { private static let sharedImageDownloadingService = DownloadingService( - downloader: Downloader(session: .background(id: "image.main")), + downloader: Downloader(session: .foreground), fileManager: StoredFileManagerFactory.makeStoredFileManager(type: .image) ) From dc105fbc47473ebaa9966cf78f8f8e30fced85ba Mon Sep 17 00:00:00 2001 From: Ivan Magda Date: Sun, 16 Feb 2020 12:52:20 +0300 Subject: [PATCH 2/9] Register placeholder for empty submissions --- .../Modules/Submissions/SubmissionsViewController.swift | 2 +- Stepic/StepikPlaceholderStyle+Placeholders.swift | 6 ++++++ Stepic/en.lproj/Localizable.strings | 1 + Stepic/ru.lproj/Localizable.strings | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Stepic/Sources/Modules/Submissions/SubmissionsViewController.swift b/Stepic/Sources/Modules/Submissions/SubmissionsViewController.swift index 20fe00ab49..ce8ab05aea 100644 --- a/Stepic/Sources/Modules/Submissions/SubmissionsViewController.swift +++ b/Stepic/Sources/Modules/Submissions/SubmissionsViewController.swift @@ -100,7 +100,7 @@ final class SubmissionsViewController: UIViewController, ControllerWithStepikPla ), for: .connectionError ) - self.registerPlaceholder(placeholder: StepikPlaceholder(.emptySolutions, action: nil), for: .empty) + self.registerPlaceholder(placeholder: StepikPlaceholder(.emptySubmissions, action: nil), for: .empty) } private func updateState(newState: Submissions.ViewControllerState) { diff --git a/Stepic/StepikPlaceholderStyle+Placeholders.swift b/Stepic/StepikPlaceholderStyle+Placeholders.swift index 31d9418649..2890fc34c7 100644 --- a/Stepic/StepikPlaceholderStyle+Placeholders.swift +++ b/Stepic/StepikPlaceholderStyle+Placeholders.swift @@ -108,6 +108,12 @@ extension StepikPlaceholder.Style { text: NSLocalizedString("DiscussionsPlaceholderEmptySolutionsTitle", comment: ""), buttonTitle: NSLocalizedString("DiscussionsPlaceholderEmptySolutionsButtonTitle", comment: "") ) + static let emptySubmissions = StepikPlaceholderStyle( + id: "emptySubmissions", + image: PlaceholderImage(image: #imageLiteral(resourceName: "new-empty-empty"), scale: 0.99), + text: NSLocalizedString("SubmissionsPlaceholderEmptyTitle", comment: ""), + buttonTitle: nil + ) static let emptyProfileLoading = StepikPlaceholderStyle( id: "emptyProfileLoading", image: PlaceholderImage(image: #imageLiteral(resourceName: "new-empty-empty"), scale: 0.99), diff --git a/Stepic/en.lproj/Localizable.strings b/Stepic/en.lproj/Localizable.strings index 9bb22997f4..0b7182b8cf 100644 --- a/Stepic/en.lproj/Localizable.strings +++ b/Stepic/en.lproj/Localizable.strings @@ -859,6 +859,7 @@ CodeQuizFullscreenTabRunTitle = "Run"; /* Submissions */ SubmissionsTitle = "Submissions"; +SubmissionsPlaceholderEmptyTitle = "No Submissions"; /* Solution */ SolutionTitle = "Solution %@"; diff --git a/Stepic/ru.lproj/Localizable.strings b/Stepic/ru.lproj/Localizable.strings index 02bac5f3d0..198a98aa44 100644 --- a/Stepic/ru.lproj/Localizable.strings +++ b/Stepic/ru.lproj/Localizable.strings @@ -860,6 +860,7 @@ CodeQuizFullscreenTabRunTitle = "Запуск"; /* Submissions */ SubmissionsTitle = "Решения"; +SubmissionsPlaceholderEmptyTitle = "Решений нет"; /* Solution */ SolutionTitle = "Решение %@"; From e3a64b9c9bc24752f3eef213659c7bfd1f13028d Mon Sep 17 00:00:00 2001 From: Ivan Magda Date: Sun, 16 Feb 2020 18:40:39 +0300 Subject: [PATCH 3/9] Cosmetics video player & lesson (#654) * Increase horizontal spacing between video player bottom controls * Override prefersHomeIndicatorAutoHidden * Reset to aspect video fill mode only on transition to portrait * Update Tabman * Step view respects safe area * CodeInputAccessoryView leading to safe area --- Podfile | 2 +- Podfile.lock | 12 ++++-------- Stepic.xcodeproj/project.pbxproj | 4 ---- Stepic/CodeInputAccessoryView.xib | 16 +++++++--------- Stepic/Sources/Modules/Step/StepView.swift | 6 +++--- Stepic/StepikVideoPlayerViewController.swift | 17 ++++++++++++++--- Stepic/StepikVideoPlayerViewController.xib | 12 ++++++------ 7 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Podfile b/Podfile index f51b0c47b9..fe09a304a2 100644 --- a/Podfile +++ b/Podfile @@ -64,7 +64,7 @@ def all_pods pod 'ActionSheetPicker-3.0', '2.4.0' pod 'Nuke', '8.3.1' pod 'STRegex', '2.1.0' - pod 'Tabman', '2.6.3' + pod 'Tabman', '2.8.0' pod 'SwiftDate', '6.1.0' end diff --git a/Podfile.lock b/Podfile.lock index 6eed5555f5..4669729df3 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -5,7 +5,6 @@ PODS: - Alamofire (4.9.1) - Amplitude-iOS (4.9.3) - Atributika (4.9.4) - - AutoInsetter (1.8.0) - BEMCheckBox (1.4.1) - Branch (0.31.0): - Branch/Core (= 0.31.0) @@ -170,8 +169,7 @@ PODS: - SwiftLint (0.38.2) - SwiftyGif (5.2.0) - SwiftyJSON (5.0.0) - - Tabman (2.6.3): - - AutoInsetter (~> 1.8.0) + - Tabman (2.8.0): - Pageboy (~> 3.5.0) - TSMessages (0.9.13): - HexColors (~> 2.3.0) @@ -228,7 +226,7 @@ DEPENDENCIES: - SwiftDate (= 6.1.0) - SwiftLint (= 0.38.2) - SwiftyJSON (= 5.0.0) - - Tabman (= 2.6.3) + - Tabman (= 2.8.0) - TSMessages (from `https://github.com/KrauseFx/TSMessages.git`) - TTTAttributedLabel (= 2.0.0) - TUSafariActivity (= 1.0.4) @@ -242,7 +240,6 @@ SPEC REPOS: - Alamofire - Amplitude-iOS - Atributika - - AutoInsetter - BEMCheckBox - Branch - Charts @@ -323,7 +320,6 @@ SPEC CHECKSUMS: Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 Amplitude-iOS: 122e026c44db8460e5efcf84859aa290a0ae9786 Atributika: 643a248e2dd8b4d74b23b53ea31393cab0a01d94 - AutoInsetter: 0b90ca74e36561c340129045a3722c51a0b15c58 BEMCheckBox: 5ba6e37ade3d3657b36caecc35c8b75c6c2b1a4e Branch: d2e1611afa9ea9aa36fa1996df7f38ca2c3eb03e Charts: 74c9f256eaf0460c0c416522d1cf8c634ea6b286 @@ -377,7 +373,7 @@ SPEC CHECKSUMS: SwiftLint: 8f5d2f903e1c9bcbc832fd16771e80a263ac6cbb SwiftyGif: b85c6b33a9411859d9e1db998b6a8214aea942df SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7 - Tabman: 63eae331ae7a9388ae389b1808f1939269fcdece + Tabman: f62ad94ee54a7d96e3fbab34f677d9ea4d38ece6 TSMessages: eb3cf27b6900684a21bad4fe9ea426e287b8c839 TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656 TUSafariActivity: afc55a00965377939107ce4fdc7f951f62454546 @@ -385,6 +381,6 @@ SPEC CHECKSUMS: VK-ios-sdk: 62a10b6571fbcda0657f455fedce7fedf55b4cd0 YandexMobileMetrica: 1030df2959c886a7be3bc3d274eb54c8e86afd6f -PODFILE CHECKSUM: ba390ba6c2c2242b85e6dd46f53cc8dad466e12e +PODFILE CHECKSUM: b9360478efa119ccbcb0ae9fc4da864d52d5251e COCOAPODS: 1.8.4 diff --git a/Stepic.xcodeproj/project.pbxproj b/Stepic.xcodeproj/project.pbxproj index 3f5c00a146..7f941be13e 100644 --- a/Stepic.xcodeproj/project.pbxproj +++ b/Stepic.xcodeproj/project.pbxproj @@ -6258,7 +6258,6 @@ "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/Amplitude-iOS/Amplitude_iOS.framework", "${BUILT_PRODUCTS_DIR}/Atributika/Atributika.framework", - "${BUILT_PRODUCTS_DIR}/AutoInsetter/AutoInsetter.framework", "${BUILT_PRODUCTS_DIR}/BEMCheckBox/BEMCheckBox.framework", "${BUILT_PRODUCTS_DIR}/Branch/Branch.framework", "${BUILT_PRODUCTS_DIR}/CRToast/CRToast.framework", @@ -6312,7 +6311,6 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Amplitude_iOS.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Atributika.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AutoInsetter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BEMCheckBox.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Branch.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CRToast.framework", @@ -6376,7 +6374,6 @@ "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/Amplitude-iOS/Amplitude_iOS.framework", "${BUILT_PRODUCTS_DIR}/Atributika/Atributika.framework", - "${BUILT_PRODUCTS_DIR}/AutoInsetter/AutoInsetter.framework", "${BUILT_PRODUCTS_DIR}/BEMCheckBox/BEMCheckBox.framework", "${BUILT_PRODUCTS_DIR}/Branch/Branch.framework", "${BUILT_PRODUCTS_DIR}/CRToast/CRToast.framework", @@ -6426,7 +6423,6 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Amplitude_iOS.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Atributika.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AutoInsetter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BEMCheckBox.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Branch.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CRToast.framework", diff --git a/Stepic/CodeInputAccessoryView.xib b/Stepic/CodeInputAccessoryView.xib index ee2027b76b..92ec504630 100644 --- a/Stepic/CodeInputAccessoryView.xib +++ b/Stepic/CodeInputAccessoryView.xib @@ -1,16 +1,14 @@ - - - - + + - - + + - + @@ -44,13 +42,13 @@ - - + + diff --git a/Stepic/Sources/Modules/Step/StepView.swift b/Stepic/Sources/Modules/Step/StepView.swift index 62a1da6972..e417e08588 100644 --- a/Stepic/Sources/Modules/Step/StepView.swift +++ b/Stepic/Sources/Modules/Step/StepView.swift @@ -200,8 +200,8 @@ final class StepView: UIView { private func positionVideoPreview() { let fullHeight = self.bounds.height let previewHeight = self.stepVideoPreviewView.bounds.height - let topInset = self.scrollableStackView.contentInsets.top - let bottomInset = self.scrollableStackView.contentInsets.bottom + let topInset = self.safeAreaInsets.top + let bottomInset = self.safeAreaInsets.bottom let controlsRealHeight = self.stepControlsView.bounds.height let controlsHeight = self.stepControlsView.sizeWithAllControls.height @@ -238,7 +238,7 @@ extension StepView: ProgrammaticallyInitializableViewProtocol { self.scrollableStackView.translatesAutoresizingMaskIntoConstraints = false self.scrollableStackView.snp.makeConstraints { make in - make.edges.equalToSuperview() + make.edges.equalTo(self.safeAreaLayoutGuide) } self.loadingIndicatorView.translatesAutoresizingMaskIntoConstraints = false diff --git a/Stepic/StepikVideoPlayerViewController.swift b/Stepic/StepikVideoPlayerViewController.swift index ba4f10af31..69778d3145 100644 --- a/Stepic/StepikVideoPlayerViewController.swift +++ b/Stepic/StepikVideoPlayerViewController.swift @@ -78,7 +78,7 @@ final class StepikVideoPlayerViewController: UIViewController { private static let seekBackTimeOffset: TimeInterval = 10 private static let seekPreferredTimescale: CMTimeScale = 1000 - private static let hidePlayerControlsTimeInterval = 4.5 + private static let hidePlayerControlsTimeInterval: TimeInterval = 4.5 @IBOutlet weak var activityIndicator: UIActivityIndicatorView! @@ -204,7 +204,11 @@ final class StepikVideoPlayerViewController: UIViewController { private var wasPlayingBeforeSeeking = false - private var isPlayerControlsVisible = true + private var isPlayerControlsVisible = true { + didSet { + self.setNeedsUpdateOfHomeIndicatorAutoHidden() + } + } private var hidePlayerControlsTimer: Timer? /// This property will be set to `true` when player playback did end and device, not in the foreground state. @@ -214,6 +218,11 @@ final class StepikVideoPlayerViewController: UIViewController { override var prefersStatusBarHidden: Bool { true } + override var prefersHomeIndicatorAutoHidden: Bool { + let anyAutoplayControlVisible = self.allAutoplayViews.first(where: { $0.isHidden }) == nil + return self.isPlayerControlsVisible || anyAutoplayControlVisible ? false : true + } + // MARK: UIViewController life cycle override func viewDidLoad() { @@ -254,7 +263,9 @@ final class StepikVideoPlayerViewController: UIViewController { coordinator.animate( alongsideTransition: { _ in - self.currentVideoFillMode = .aspect + if DeviceInfo.current.orientation.interface.isPortrait { + self.currentVideoFillMode = .aspect + } }, completion: { _ in self.updateVideoFillModeIcon() diff --git a/Stepic/StepikVideoPlayerViewController.xib b/Stepic/StepikVideoPlayerViewController.xib index 72f7647f4e..34ad7012e5 100644 --- a/Stepic/StepikVideoPlayerViewController.xib +++ b/Stepic/StepikVideoPlayerViewController.xib @@ -1,9 +1,9 @@ - + - + @@ -48,7 +48,7 @@