Skip to content

Commit

Permalink
Merge pull request #466 from SourcePointUSA/add_markdown_parser_to_tvOS
Browse files Browse the repository at this point in the history
Add markdown support to tvOS
  • Loading branch information
andresilveirah committed Jul 25, 2023
2 parents e6dee6f + 1bba34d commit 99682cf
Show file tree
Hide file tree
Showing 138 changed files with 35,973 additions and 1,784 deletions.
1 change: 1 addition & 0 deletions ConsentViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Pod::Spec.new do |s|
s.ios.exclude_files = 'ConsentViewController/Classes/Views/tvOS'
s.tvos.deployment_target = '10.0'
s.tvos.exclude_files = 'ConsentViewController/Classes/Views/iOS'
s.tvos.dependency 'Down', '~> 0.9.0'
s.resource_bundles = { 'ConsentViewController' => ['ConsentViewController/Assets/**/*', 'Pod/Classes/**/*.{storyboard,xib,xcassets,json,imageset,png,js}'] }
s.resources = "ConsentViewController/**/*.{js,json,png}"
s.info_plist = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import UIKit
import Down

extension UIImageView {
func load(url: URL) {
Expand Down Expand Up @@ -212,15 +213,22 @@ class FocusGuideDebugView: UIView {
return label
}

func parseText(_ rawText: String) -> NSAttributedString? {
guard let markdownText = try? Down(markdownString: rawText).toAttributedString(),
markdownText.length != 0 else {
return rawText.htmlToAttributedString
}
return markdownText
}

@discardableResult
func loadTextView(forComponentId id: String, textView: UITextView, text: String? = nil, bounces: Bool = true) -> UITextView {
if let textViewComponent = components.first(where: { $0.id == id }) as? SPNativeText {
let style = textViewComponent.settings.style
if let text = text {
textView.attributedText = text.htmlToAttributedString
} else {
textView.attributedText = textViewComponent.settings.text.htmlToAttributedString
}
textView.attributedText = parseText(text != nil ?
text! :
textViewComponent.settings.text
)
textView.textColor = UIColor(hexString: style.font.color)
textView.isUserInteractionEnabled = true
textView.isScrollEnabled = true
Expand Down
8 changes: 6 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
PODS:
- ConsentViewController (7.2.1)
- ConsentViewController (7.2.1):
- Down (~> 0.9.0)
- Down (0.9.5)
- IQKeyboardManagerSwift (6.5.10)
- JSONView (0.0.3)
- Nimble (10.0.0)
Expand All @@ -18,6 +20,7 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- Down
- IQKeyboardManagerSwift
- JSONView
- Nimble
Expand All @@ -30,7 +33,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
ConsentViewController: 038d1eb3a9cebc9157809220a319ac1ef7173b8d
ConsentViewController: b4bc3ccbeb4d1659b61609ba956b61c4aa78fa86
Down: 7321a72d0747ed0061dce948bcff518fcb6df2bd
IQKeyboardManagerSwift: 52962c76ab33532f15ad9f3ff4e5715eda5335bb
JSONView: ba9049102fae7ad70de40234d0b7c60986e61e4c
Nimble: 5316ef81a170ce87baf72dd961f22f89a602ff84
Expand Down
218 changes: 218 additions & 0 deletions Example/Pods/Down/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 99682cf

Please sign in to comment.