Skip to content

Commit

Permalink
Merge branch 'release/3.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
malcommac committed Dec 21, 2019
2 parents d87ed23 + dde841e commit a24bdce
Show file tree
Hide file tree
Showing 31 changed files with 1,671 additions and 587 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

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

Binary file modified Documentation_Assests/Logo.sketch
Binary file not shown.
Binary file added Documentation_Assests/image_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation_Assests/image_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions ExampleiOS/Assets.xcassets/rocket.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "816c77975b4ccce940d41933081b19d7.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
5 changes: 5 additions & 0 deletions ExampleiOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
40 changes: 40 additions & 0 deletions ExampleiOS/UIKit+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// UIKit+Extensions.swift
// ExampleiOS
//
// Created by daniele on 21/12/2019.
// Copyright © 2019 SwiftRichString. All rights reserved.
//

import UIKit

extension UIColor {

public static func randomColors(_ count: Int) -> [UIColor] {
return (0..<count).map { _ -> UIColor in
randomColor()
}
}

public static func randomColor() -> UIColor {
let redValue = CGFloat.random(in: 0...1)
let greenValue = CGFloat.random(in: 0...1)
let blueValue = CGFloat.random(in: 0...1)

let randomColor = UIColor(red: redValue, green: greenValue, blue: blueValue, alpha: 1.0)
return randomColor
}

}

extension UIFont {

/// Return the same font with given weight.
///
/// - Parameter weight: weight you want to get
public func withWeight(_ weight: UIFont.Weight) -> UIFont {
let descriptor = fontDescriptor.addingAttributes([UIFontDescriptor.AttributeName.traits: [UIFontDescriptor.TraitKey.weight: weight]])
return UIFont(descriptor: descriptor, size: 0) // size 0 means keep the size as it is
}

}
70 changes: 49 additions & 21 deletions ExampleiOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

/*let baseStyle = Style {
$0.font = UIFont.systemFont(ofSize: self.baseFontSize)
$0.lineSpacing = 2
}

let linkStyle = Style {
$0.font = UIFont.boldSystemFont(ofSize: self.baseFontSize)
$0.linkURL = URLRepresentable.tagAttribute("href")
}

let text = "Stile <a href=\"www.facebook.com/agencearcantide/photos/a.346501409312886/346503839312643/?type=3&theater\">link</a>"
let s = StyleGroup(base: baseStyle, ["a" : linkStyle])
self.textView?.attributedText = text.set(style: s)
*/


// self.textView?.attributedText = "ciao ciao " + AttributedString(image: UIImage(named: "rocket")!,
// bounds: CGRect(x: 0, y: -20, width: 25, height: 25)) + "ciao ciao"
//
//
// return
//
let bodyHTML = try! String(contentsOfFile: Bundle.main.path(forResource: "file", ofType: "txt")!)

// Create a set of styles

let headerStyle = Style {
$0.font = UIFont.boldSystemFont(ofSize: self.baseFontSize * 1.15)
$0.lineSpacing = 1
Expand All @@ -52,12 +45,22 @@ class ViewController: UIViewController {
let italicStyle = Style {
$0.font = UIFont.italicSystemFont(ofSize: self.baseFontSize)
}

let style = StyleGroup(base: Style {

let uppercasedRed = Style {
$0.font = UIFont.italicSystemFont(ofSize: self.baseFontSize)
$0.color = UIColor.red
$0.textTransforms = [
.uppercase
]
}

// And a group of them
let styleGroup = StyleGroup(base: Style {
$0.font = UIFont.systemFont(ofSize: self.baseFontSize)
$0.lineSpacing = 2
$0.kerning = Kerning.adobe(-15)
}, [
"ur": uppercasedRed,
"h3": headerStyle,
"h4": headerStyle,
"h5": headerStyle,
Expand All @@ -73,11 +76,36 @@ class ViewController: UIViewController {
"sup": Style {
$0.font = UIFont.systemFont(ofSize: self.baseFontSize / 1.2)
$0.baselineOffset = Float(self.baseFontSize) / 3.5
}])

self.textView?.attributedText = bodyHTML.set(style: style)
}])

// Apply a custom xml attribute resolver
styleGroup.xmlAttributesResolver = MyXMLDynamicAttributesResolver()

// Render
self.textView?.attributedText = bodyHTML.set(style: styleGroup)

// Accessibility support
if #available(iOS 10.0, *) {
self.textView?.adjustsFontForContentSizeCategory = true
}

}
}

public class MyXMLDynamicAttributesResolver: StandardXMLAttributesResolver {

public override func styleForUnknownXMLTag(_ tag: String, to attributedString: inout AttributedString, attributes: [String : String]?) {
super.styleForUnknownXMLTag(tag, to: &attributedString, attributes: attributes)

if tag == "rainbow" {
let colors = UIColor.randomColors(attributedString.length)
for i in 0..<attributedString.length {
attributedString.add(style: Style({
$0.color = colors[i]
}), range: NSMakeRange(i, 1))
}
}

}

}
10 changes: 7 additions & 3 deletions ExampleiOS/file.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<strong>Parler du don d'organe n'est plus tabou. Je me renseigne, j'en discute avec mes proches,... et je décide!</strong>
<strong>Parler du don d'organe n'est plus tabou. Je me renseigne, j'en discute avec mes proches,... <rainbow>et je décide!</rainbow></strong>

En Belgique, au début des années 2000, le nombre de donneurs d’organes avait tendance à diminuer et les listes d’attente à augmenter considérablement ayant comme corollaire une augmentation de la mortalité des patients inscrits sur les listes d’attente.
<img named="rocket" rect="0,-50,30,30"/>

Soucieux de cette situation, en juin 2005, le Ministre en charge de la Santé publique a souhaité mettre sur pied une vaste campagne de sensibilisation entièrement dédiée au don d’organes.
<img url="https://www.macitynet.it/wp-content/uploads/2018/05/video_ApplePark_magg18.jpg"/>

<strong color="#db13f2">En Belgique</strong>, au début des années 2000, le nombre de donneurs d’organes avait tendance à diminuer et les listes d’attente à augmenter considérablement ayant comme corollaire une augmentation de la mortalité des patients inscrits sur les listes d’attente.

Soucieux de cette situation, en juin 2005, le <ur>Ministre en charge de la Santé</ur> publique a souhaité mettre sur pied une vaste campagne de sensibilisation entièrement dédiée au don d’organes.

Depuis, de nombreuses actions entreprises par le SPF Santé publique viennent renforcer toutes celles qui sont accomplies au quotidien par les coordinateurs de transplantation, les coordinateurs locaux de don, les associations de familles de donneurs, les associations de patients transplantés et ce, depuis de très nombreuses années.

Expand Down
Loading

0 comments on commit a24bdce

Please sign in to comment.