-
Notifications
You must be signed in to change notification settings - Fork 18
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
Unit progress navigation style #258
Merged
volodymyr-chekyrta
merged 41 commits into
openedx:develop
from
touchapp:feat/unit_progress
Feb 2, 2024
+1,131
−486
Merged
Changes from 29 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ab96cc7
chore: add lesson line progress view
eyatsenkoperpetio 33b59a1
chore: add colors and config to course unit view model
eyatsenkoperpetio 4507540
chore: add ajax provider and refactor code, fix crash on Config resolve
eyatsenkoperpetio 4de4be1
Merge branch 'develop' into feat/unit_progress
eyatsenkoperpetio bafaff0
chore: update when back if some changed
eyatsenkoperpetio 3352528
chore: hide progress dots when line show
eyatsenkoperpetio ededc14
chore: padding and separate views
eyatsenkoperpetio e77e1bc
Merge branch 'develop' into feat/unit_progress
eyatsenkoperpetio fd16f64
chore: added one more state and change inset what fixes dark mode
rnr 96e5d72
Merge pull request #7 from touchapp/feat/unit_progress_line_improvements
forgotvas 9154c48
fix: arrow buttons in unit content
forgotvas ee9723e
fix: animation
forgotvas 5cf0197
fix: different navigation stacks
forgotvas 1a31646
fix: offset in landscape mode
forgotvas 7f3c4a2
fix: offset on orientation change
forgotvas bfd5507
fix: unit tests
forgotvas 9079d30
Merge pull request #8 from touchapp/feat/unit-animation
rnr 1fc1863
Merge branch 'develop' into feat/unit_progress
rnr 5c5ba04
chore: fixed warnings
rnr 462fa00
chore: fixed warnings
rnr c0a6184
Merge branch 'develop' into feat/unit_progress
rnr 5d18fdf
chore: fixed rounded corners and padding for progress line
rnr 9ff5efa
fix: paddings
forgotvas 2f85376
Merge pull request #9 from touchapp/fix/unit_progress
rnr 1b01de7
chore: moved rounded corners to view extension
rnr 59ea2f7
chore: delete unused code
rnr d88becc
fix: use full width if we are using horizontal navigation
forgotvas b939721
Merge branch 'fixed_rounded_corners_and_progress_line_padding' of htt…
forgotvas cce4537
Merge pull request #10 from touchapp/fixed_rounded_corners_and_progre…
rnr 23cb12f
chore: refactor of ajax completion handler
forgotvas d2abb01
chore: warning fix
forgotvas 18d6f44
chore: added forMainFrameOnly parameter
forgotvas ca3b9cf
fix: previous button for horizontal navigation
forgotvas d2adf89
Merge pull request #12 from touchapp/fix/prev-button
rnr b7c45a7
Merge pull request #11 from touchapp/chore/ajax-refactor
forgotvas 554c4e5
chore: resolve PR comments
eyatsenkoperpetio e5af1a7
chore: update course struct after complete unit
eyatsenkoperpetio 3524328
Merge branch 'develop' into feat/unit_progress
eyatsenkoperpetio ddb566e
Merge branch 'develop' into feat/unit_progress
eyatsenkoperpetio b91cf6d
chore: down up dropdown button
eyatsenkoperpetio 79378bc
chore: remove refresh course
eyatsenkoperpetio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// AjaxProvider.swift | ||
// Core | ||
// | ||
// Created by Eugene Yatsenko on 12.12.2023. | ||
// | ||
|
||
import Foundation | ||
import WebKit | ||
import Swinject | ||
|
||
public extension NSNotification { | ||
static let blockCompletion = Notification.Name.init("block_completion") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notifications are centralized in |
||
|
||
final class AjaxProvider { | ||
|
||
let AJAXCallBackHandler = "ajaxCallbackHandler" | ||
let ajaxScriptFile = "ajaxHandler" | ||
|
||
private struct AJAXCallbackData { | ||
private enum Keys: String { | ||
case url = "url" | ||
case statusCode = "status" | ||
case responseText = "response_text" | ||
} | ||
|
||
let url: String | ||
let statusCode: Int | ||
let responseText: String | ||
|
||
init(data: [AnyHashable: Any]) { | ||
url = data[Keys.url.rawValue] as? String ?? "" | ||
statusCode = data[Keys.statusCode.rawValue] as? Int ?? 0 | ||
responseText = data[Keys.responseText.rawValue] as? String ?? "" | ||
} | ||
} | ||
|
||
enum XBlockCompletionCallbackType: String { | ||
case html = "publish_completion" | ||
case problem = "problem_check" | ||
case dragAndDrop = "do_attempt" | ||
case ora = "render_grade" | ||
} | ||
|
||
func addAjaxCallbackScript( | ||
in contentController: WKUserContentController, | ||
scriptMessageHandler: WKScriptMessageHandler | ||
) { | ||
guard let url = Bundle(for: CoreBundle.self).url(forResource: ajaxScriptFile, withExtension: "js"), | ||
let handler = try? String(contentsOf: url, encoding: .utf8) else { return } | ||
let script = WKUserScript(source: handler, injectionTime: .atDocumentEnd, forMainFrameOnly: false) | ||
contentController.add(scriptMessageHandler, name: AJAXCallBackHandler) | ||
contentController.addUserScript(script) | ||
} | ||
|
||
@discardableResult | ||
func isCompletionCallback(with data: [AnyHashable: Any]) -> Bool { | ||
let callback = AJAXCallbackData(data: data) | ||
let requestURL = callback.url | ||
|
||
if callback.statusCode != 200 { | ||
return false | ||
} | ||
|
||
var complete = false | ||
if isBlockOf(type: .ora, with: requestURL) { | ||
complete = callback.responseText.contains("is--complete") | ||
} else { | ||
complete = isBlockOf(type: .html, with: requestURL) | ||
|| isBlockOf(type: .problem, with: requestURL) | ||
|| isBlockOf(type: .dragAndDrop, with: requestURL) | ||
} | ||
if complete { | ||
NotificationCenter.default.post( | ||
name: NSNotification.blockCompletion, | ||
object: nil | ||
) | ||
} | ||
return complete | ||
} | ||
|
||
private func isBlockOf(type: XBlockCompletionCallbackType, with requestURL: String) -> Bool { | ||
return requestURL.contains(type.rawValue) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//Every time an Ajax call is being invoked the listener will recognize it and will call the native app with the request details | ||
|
||
$(document).ajaxSuccess(function(event, request, settings) { | ||
callNativeApp({ | ||
"status": request.status, | ||
"url":settings.url, | ||
"response_text": request.responseText | ||
}); | ||
}); | ||
|
||
function callNativeApp(data) { | ||
try { | ||
webkit.messageHandlers.ajaxCallbackHandler.postMessage(data); | ||
} | ||
catch(err) { | ||
console.log('The native context does not exist yet'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The Keys enum can implement protocol
RawStringExtractable
so that values can be extracted without mentioning the .rawValue from dictionary.