forked from openedx/openedx-app-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: webview discovery implimentation
- Loading branch information
1 parent
3bca8bf
commit fdc2e1e
Showing
19 changed files
with
600 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// DiscoveryConfig.swift | ||
// Core | ||
// | ||
// Created by SaeedBashir on 12/18/23. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum DiscoveryConfigType: String { | ||
case native | ||
case webview | ||
case none | ||
} | ||
|
||
private enum DiscoveryKeys: String, RawStringExtractable { | ||
case discoveryType = "TYPE" | ||
case webview = "WEBVIEW" | ||
case baseURL = "BASE_URL" | ||
case courseDetailTemplate = "COURSE_DETAIL_TEMPLATE" | ||
case programDetailTemplate = "PROGRAM_DETAIL_TEMPLATE" | ||
} | ||
|
||
public class DiscoveryWebviewConfig: NSObject { | ||
public let baseURL: String? | ||
public let courseDetailTemplate: String? | ||
public let programDetailTemplate: String? | ||
|
||
init(dictionary: [String: AnyObject]) { | ||
baseURL = dictionary[DiscoveryKeys.baseURL] as? String | ||
courseDetailTemplate = dictionary[DiscoveryKeys.courseDetailTemplate] as? String | ||
programDetailTemplate = dictionary[DiscoveryKeys.programDetailTemplate] as? String | ||
} | ||
} | ||
|
||
public class DiscoveryConfig: NSObject { | ||
public let type: DiscoveryConfigType | ||
public let webview: DiscoveryWebviewConfig | ||
|
||
init(dictionary: [String: AnyObject]) { | ||
type = (dictionary[DiscoveryKeys.discoveryType] as? String).flatMap { | ||
DiscoveryConfigType(rawValue: $0) | ||
} ?? .none | ||
webview = DiscoveryWebviewConfig(dictionary: dictionary[DiscoveryKeys.webview] as? [String: AnyObject] ?? [:]) | ||
} | ||
|
||
var isEnabled: Bool { | ||
return type != .none | ||
} | ||
} | ||
|
||
private let key = "DISCOVERY" | ||
extension Config { | ||
public var discovery: DiscoveryConfig { | ||
DiscoveryConfig(dictionary: self[key] as? [String: AnyObject] ?? [:]) | ||
} | ||
} |
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,27 @@ | ||
// | ||
// RawStringExtactable.swift | ||
// Core | ||
// | ||
// Created by SaeedBashir on 12/18/23. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol RawStringExtractable { | ||
var rawValue: String { get } | ||
} | ||
|
||
public protocol DictionaryExtractionExtension { | ||
associatedtype Key | ||
associatedtype Value | ||
subscript(key: Key) -> Value? { get } | ||
} | ||
|
||
extension Dictionary: DictionaryExtractionExtension {} | ||
|
||
public extension DictionaryExtractionExtension where Self.Key == String { | ||
|
||
subscript(key :RawStringExtractable) -> Value? { | ||
return self[key.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
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
Oops, something went wrong.