-
Notifications
You must be signed in to change notification settings - Fork 16
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: webview based discovery implementation #219
feat: webview based discovery implementation #219
Conversation
3f4fef5
to
d656376
Compare
@saeedbashir could you please provide properly configured config with added parameters to test this? Thank you |
@rnr Our prod config is already configured for the web view based discovery. You can use that to test it. |
…adding in discovery
Hello @saeedbashir Screen.Recording.2024-01-10.at.13.31.11.mov |
@rnr Can you please try it now? |
@saeedbashir now it's working fine. thank you |
Core/Core/View/Base/WebView.swift
Outdated
@@ -139,8 +188,8 @@ 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.layer.cornerRadius = 24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saeedbashir do we need this commented out code?
Core/Core/View/Base/WebView.swift
Outdated
let isWebViewDelegateHandled = await ( | ||
parent.webViewNavDelegate?.webView( | ||
webView, | ||
shouldLoad: navigationAction.request, navigationAction: navigationAction) ?? false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you follow style 'each argument on its own line' here please
var sourceScreen: LogistrationSourceScreen | ||
|
||
var userloggedIn: Bool { | ||
return !(storage.user?.username?.isEmpty ?? true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't storage.user?.username?.isEmpty == false
more clear here?
func showCourseDetais(courseID: String, title: String) | ||
func showWebDiscoveryDetails(pathID: String, discoveryType: DiscoveryWebviewType, sourceScreen: LogistrationSourceScreen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix please SwiftLint line length warning here
@@ -23,8 +32,18 @@ public class DiscoveryRouterMock: BaseRouterMock, DiscoveryRouter { | |||
public override init() {} | |||
|
|||
public func showCourseDetais(courseID: String, title: String) {} | |||
public func showWebDiscoveryDetails(pathID: String, discoveryType: DiscoveryWebviewType, sourceScreen: LogistrationSourceScreen) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix please SwiftLint line length warning here
} | ||
|
||
var isValidAppURLScheme: Bool { | ||
return scheme ?? "" == URIString.appURLScheme.rawValue ? true : false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't just scheme ?? "" == URIString.appURLScheme.rawValue
work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty scheme ("") is valid too here (in case URIString.appURLScheme gets empty someway)?
maybe need to add && scheme?.isEmpty == false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty scheme ("") is valid too here (in case URIString.appURLScheme gets empty someway)?
It's a defined value, so it shouldn't be needed to address it at the moment.
"ALERT.LEAVING_APP_TITLE" = "Leaving the app"; | ||
"ALERT.LEAVING_APP_MESSAGE" = "You are now leaving the app and opening a browser"; | ||
|
||
"DETAILS.TITLE" = "Course details"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add these to uk.lproj too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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 ?? "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please format to have parameter on its own line
let view = DiscoveryWebview( | ||
viewModel: Container.shared.resolve( | ||
DiscoveryWebviewModel.self, | ||
argument: sourceScreen)!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's fine because having the (
brackets of the argument on the next line breaks the arguments flow.
DiscoveryWebview( | ||
viewModel: Container.shared.resolve( | ||
DiscoveryWebviewModel.self, | ||
argument: viewModel.sourceScreen)!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saeedbashir, could you please fix the tests?
|
@saeedbashir project isn't compilable after fix (there is misspelling in URL+PathExtension.swift) |
Discovery/Discovery/Presentation/WebDiscovery/URL+PathExtension.swift
Outdated
Show resolved
Hide resolved
Discovery/Discovery/Presentation/WebDiscovery/DiscoverWebviewModel.swift
Outdated
Show resolved
Hide resolved
Discovery/Discovery/Presentation/WebDiscovery/DiscoverWebviewModel.swift
Outdated
Show resolved
Hide resolved
Hi @volodymyr-chekyrta any other info needed to review this PR? |
Hi @touchapp, I'll do my best to finish review today |
Discovery/Discovery/Presentation/WebDiscovery/DiscoveryURIDetails.swift
Outdated
Show resolved
Hide resolved
@@ -69,6 +69,7 @@ | |||
|
|||
"WEBVIEW.ALERT.OK" = "Так"; | |||
"WEBVIEW.ALERT.CANCEL" = "Скасувати"; | |||
"WEBVIEW.ALERT.CONTINUE" = "Continue"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to have a localized version of the string at this moment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't add translations on the go. Files will be translated later.
if enroll.statusCode == 200 { | ||
return true | ||
} else { | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can refactor it like:
return enroll.statusCode == 200
|
||
var path: String { | ||
switch self { | ||
case .getDiscovery: | ||
return "/api/courses/v1/courses/" | ||
case .searchCourses: | ||
return "/api/courses/v1/courses/" | ||
case .getCourseDetail(courseID: let courseID, _): | ||
return "/api/courses/v1/courses/\(courseID)" | ||
case .enrollToCourse(courseID: _): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting warning in code:
Empty Enum Arguments Violation: Arguments can be omitted when matching enums with associated values if they are not used (empty_enum_arguments)
} | ||
} | ||
|
||
var httpMethod: HTTPMethod { | ||
switch self { | ||
case .getDiscovery, .searchCourses: | ||
return .get | ||
case .getCourseDetail(courseID: _, username: _): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same warning here:
Empty Enum Arguments Violation: Arguments can be omitted when matching enums with associated values if they are not used (empty_enum_arguments)
} | ||
|
||
var isValidAppURLScheme: Bool { | ||
return scheme ?? "" == URIString.appURLScheme.rawValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address warning:
Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
574b74f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This PR adds support for web-view-based discovery. The switch between native discovery and web-view-based discovery is being controlled from the config file.
Note:
By default, the discovery will be disabled because some providers don't want to provide discovery to their users.
Sample Config Foe WebDiscovery:
Sample Config For WebDiscovery:
Working Video:
web.discovery.mov