From 80c77992e9792a7ff7f6625183c0e110a7024e19 Mon Sep 17 00:00:00 2001 From: Saeed Bashir Date: Mon, 15 Jan 2024 12:57:44 +0500 Subject: [PATCH] refactor: address review feedback --- Core/Core/View/Base/WebView.swift | 5 ++-- Course/Course/uk.lproj/Localizable.strings | 5 ---- .../Presentation/DiscoveryRouter.swift | 12 +++++++-- .../WebDiscovery/DiscoverWebviewModel.swift | 2 +- .../WebDiscovery/URL+PathExtension.swift | 2 +- .../Discovery/uk.lproj/Localizable.strings | 5 ++++ OpenEdX/Data/DiscoveryPersistence.swift | 26 ++++++++++--------- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Core/Core/View/Base/WebView.swift b/Core/Core/View/Base/WebView.swift index 670d9516d..85859e1f3 100644 --- a/Core/Core/View/Base/WebView.swift +++ b/Core/Core/View/Base/WebView.swift @@ -99,7 +99,8 @@ public struct WebView: UIViewRepresentable { let isWebViewDelegateHandled = await ( parent.webViewNavDelegate?.webView( webView, - shouldLoad: navigationAction.request, navigationAction: navigationAction) ?? false + shouldLoad: navigationAction.request, + navigationAction: navigationAction) ?? false ) if isWebViewDelegateHandled { @@ -188,8 +189,6 @@ public struct WebView: UIViewRepresentable { webView.backgroundColor = .clear webView.scrollView.backgroundColor = Theme.Colors.white.uiColor() webView.scrollView.alwaysBounceVertical = false -// webView.scrollView.layer.cornerRadius = 24 -// webView.scrollView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] webView.scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 200, right: 0) return webView diff --git a/Course/Course/uk.lproj/Localizable.strings b/Course/Course/uk.lproj/Localizable.strings index 180474854..59c7bce6a 100644 --- a/Course/Course/uk.lproj/Localizable.strings +++ b/Course/Course/uk.lproj/Localizable.strings @@ -6,11 +6,6 @@ */ -"DETAILS.TITLE" = "Деталі курсу"; -"DETAILS.VIEW_COURSE" = "Переглянути курс"; -"DETAILS.ENROLL_NOW" = "Зареєструватися"; -"DETAILS.ENROLLMENT_DATE_IS_OVER" = "Ви не можете зареєструватися на цей курс, оскільки дата реєстрації закінчилася."; - "OUTLINE.CONGRATULATIONS" = "Вітаємо!"; "OUTLINE.PASSED_THE_COURSE" = "Ви пройшли курс"; "OUTLINE.VIEW_CERTIFICATE" = "Переглянути сертифікат"; diff --git a/Discovery/Discovery/Presentation/DiscoveryRouter.swift b/Discovery/Discovery/Presentation/DiscoveryRouter.swift index c8fd80b29..cf47d2204 100644 --- a/Discovery/Discovery/Presentation/DiscoveryRouter.swift +++ b/Discovery/Discovery/Presentation/DiscoveryRouter.swift @@ -10,7 +10,11 @@ import Core public protocol DiscoveryRouter: BaseRouter { func showCourseDetais(courseID: String, title: String) - func showWebDiscoveryDetails(pathID: String, discoveryType: DiscoveryWebviewType, sourceScreen: LogistrationSourceScreen) + func showWebDiscoveryDetails( + pathID: String, + discoveryType: DiscoveryWebviewType, + sourceScreen: LogistrationSourceScreen + ) func showUpdateRequiredView(showAccountLink: Bool) func showUpdateRecomendedView() func showDiscoverySearch(searchQuery: String?) @@ -32,7 +36,11 @@ public class DiscoveryRouterMock: BaseRouterMock, DiscoveryRouter { public override init() {} public func showCourseDetais(courseID: String, title: String) {} - public func showWebDiscoveryDetails(pathID: String, discoveryType: DiscoveryWebviewType, sourceScreen: LogistrationSourceScreen) {} + public func showWebDiscoveryDetails( + pathID: String, + discoveryType: DiscoveryWebviewType, + sourceScreen: LogistrationSourceScreen + ) {} public func showUpdateRequiredView(showAccountLink: Bool) {} public func showUpdateRecomendedView() {} public func showDiscoverySearch(searchQuery: String? = nil) {} diff --git a/Discovery/Discovery/Presentation/WebDiscovery/DiscoverWebviewModel.swift b/Discovery/Discovery/Presentation/WebDiscovery/DiscoverWebviewModel.swift index d68e8a83d..09266c14f 100644 --- a/Discovery/Discovery/Presentation/WebDiscovery/DiscoverWebviewModel.swift +++ b/Discovery/Discovery/Presentation/WebDiscovery/DiscoverWebviewModel.swift @@ -33,7 +33,7 @@ public class DiscoveryWebviewModel: ObservableObject { var sourceScreen: LogistrationSourceScreen var userloggedIn: Bool { - return !(storage.user?.username?.isEmpty ?? true) + return storage.user?.username?.isEmpty == false } public init( diff --git a/Discovery/Discovery/Presentation/WebDiscovery/URL+PathExtension.swift b/Discovery/Discovery/Presentation/WebDiscovery/URL+PathExtension.swift index ca89f7d77..01a5faabf 100644 --- a/Discovery/Discovery/Presentation/WebDiscovery/URL+PathExtension.swift +++ b/Discovery/Discovery/Presentation/WebDiscovery/URL+PathExtension.swift @@ -13,7 +13,7 @@ public extension URL { } var isValidAppURLScheme: Bool { - return scheme ?? "" == URIString.appURLScheme.rawValue ? true : false + return scheme ?? "" == URIString.appURLScheme.rawValue && } var queryParameters: [String: Any]? { diff --git a/Discovery/Discovery/uk.lproj/Localizable.strings b/Discovery/Discovery/uk.lproj/Localizable.strings index 63109fae9..28f832e27 100644 --- a/Discovery/Discovery/uk.lproj/Localizable.strings +++ b/Discovery/Discovery/uk.lproj/Localizable.strings @@ -29,3 +29,8 @@ "ALERT.LEAVING_APP_TITLE" = "Leaving the app"; "ALERT.LEAVING_APP_MESSAGE" = "You are now leaving the app and opening a browser"; + +"DETAILS.TITLE" = "Деталі курсу"; +"DETAILS.VIEW_COURSE" = "Переглянути курс"; +"DETAILS.ENROLL_NOW" = "Зареєструватися"; +"DETAILS.ENROLLMENT_DATE_IS_OVER" = "Ви не можете зареєструватися на цей курс, оскільки дата реєстрації закінчилася."; diff --git a/OpenEdX/Data/DiscoveryPersistence.swift b/OpenEdX/Data/DiscoveryPersistence.swift index b56bfa20e..189264f41 100644 --- a/OpenEdX/Data/DiscoveryPersistence.swift +++ b/OpenEdX/Data/DiscoveryPersistence.swift @@ -71,18 +71,20 @@ public class DiscoveryPersistence: DiscoveryPersistenceProtocol { let request = CDCourseDetails.fetchRequest() request.predicate = NSPredicate(format: "courseID = %@", courseID) guard let courseDetails = try? context.fetch(request).first else { throw NoCachedDataError() } - return CourseDetails(courseID: courseDetails.courseID ?? "", - org: courseDetails.org ?? "", - courseTitle: courseDetails.courseTitle ?? "", - courseDescription: courseDetails.courseDescription ?? "", - courseStart: courseDetails.courseStart, - courseEnd: courseDetails.courseEnd, - enrollmentStart: courseDetails.enrollmentStart, - enrollmentEnd: courseDetails.enrollmentEnd, - isEnrolled: courseDetails.isEnrolled, - overviewHTML: courseDetails.overviewHTML ?? "", - courseBannerURL: courseDetails.courseBannerURL ?? "", - courseVideoURL: nil) + return CourseDetails( + courseID: courseDetails.courseID ?? "", + org: courseDetails.org ?? "", + courseTitle: courseDetails.courseTitle ?? "", + courseDescription: courseDetails.courseDescription ?? "", + courseStart: courseDetails.courseStart, + courseEnd: courseDetails.courseEnd, + enrollmentStart: courseDetails.enrollmentStart, + enrollmentEnd: courseDetails.enrollmentEnd, + isEnrolled: courseDetails.isEnrolled, + overviewHTML: courseDetails.overviewHTML ?? "", + courseBannerURL: courseDetails.courseBannerURL ?? "", + courseVideoURL: nil + ) } public func saveCourseDetails(course: CourseDetails) {