diff --git a/Example/OpenSourceController/AppDelegate.swift b/Example/OpenSourceController/AppDelegate.swift index c338c1f..2847442 100644 --- a/Example/OpenSourceController/AppDelegate.swift +++ b/Example/OpenSourceController/AppDelegate.swift @@ -13,7 +13,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true @@ -41,6 +40,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - } - diff --git a/Example/OpenSourceController/ViewController.swift b/Example/OpenSourceController/ViewController.swift index 0d8f04b..003024d 100644 --- a/Example/OpenSourceController/ViewController.swift +++ b/Example/OpenSourceController/ViewController.swift @@ -24,15 +24,14 @@ class ViewController: UIViewController { @IBAction func showOpenSource(_ sender: Any) { // Create controller let openSourceVC = OpenSourceController() - + // Init with LicenceFile object - openSourceVC.licences = [LicenceFile(title: "FacebookImagePicker", + openSourceVC.licences = [LicenceFile(title: "FacebookImagePicker", url: "https://raw.githubusercontent.com/terflogag/FacebookImagePicker/master/LICENSE"), - LicenceFile(title: "JSQMessagesViewController", + LicenceFile(title: "JSQMessagesViewController", url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/develop/LICENSE")] - + // Present controller openSourceVC.presentOpenSourceController(from: self) } } - diff --git a/Example/Tests/Tests.swift b/Example/Tests/Tests.swift index b53f249..f5111c0 100644 --- a/Example/Tests/Tests.swift +++ b/Example/Tests/Tests.swift @@ -3,27 +3,27 @@ import XCTest import OpenSourceController class Tests: XCTestCase { - + override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. } - + override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } - + func testExample() { // This is an example of a functional test case. XCTAssert(true, "Pass") } - + func testPerformanceExample() { // This is an example of a performance test case. - self.measure() { + self.measure { // Put the code you want to measure the time of here. } } - + } diff --git a/OpenSourceController/Classes/Controller/OpenSourceViewController.swift b/OpenSourceController/Classes/Controller/OpenSourceViewController.swift index 53f8e4b..c5fd8ff 100644 --- a/OpenSourceController/Classes/Controller/OpenSourceViewController.swift +++ b/OpenSourceController/Classes/Controller/OpenSourceViewController.swift @@ -124,14 +124,11 @@ class OpenSourceViewController: UITableViewController { reuseIdentifier: self.reuseIdentifier) } - let libraryTitleAttribut = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize + 2)] - let libraryLicenceAttribut = [NSFontAttributeName: UIFont.systemFont(ofSize: UIFont.systemFontSize)] - let libraryTitle = NSMutableAttributedString(string: self.downloadedLicence?[indexPath.row].title ?? "", - attributes: libraryTitleAttribut) - libraryTitle.append(NSAttributedString(string: "\n\n")) - libraryTitle.append(NSAttributedString(string: self.downloadedLicence?[indexPath.row].detail ?? "", - attributes: libraryLicenceAttribut)) - cell?.textLabel?.attributedText = libraryTitle + if let licences = self.downloadedLicence, + indexPath.row < licences.count { + let licence = licences[indexPath.row] + cell?.configure(licence: licence) + } return cell! } diff --git a/OpenSourceController/Classes/View/OpenSourceTableViewCell.swift b/OpenSourceController/Classes/View/OpenSourceTableViewCell.swift index cd6cc7a..7679769 100644 --- a/OpenSourceController/Classes/View/OpenSourceTableViewCell.swift +++ b/OpenSourceController/Classes/View/OpenSourceTableViewCell.swift @@ -10,11 +10,6 @@ import UIKit class OpenSourceTableViewCell: UITableViewCell { - // MARK: IBOutlet - - @IBOutlet var licenceTitle: UILabel! - @IBOutlet var licenceDesc: UILabel! - // MARK: - Lifecycle override init(style: UITableViewCellStyle, reuseIdentifier: String?) { @@ -54,10 +49,16 @@ class OpenSourceTableViewCell: UITableViewCell { /// - Parameter licence: the licence model func configure(licence: LicenceFile) { - // Library's name - self.licenceTitle.text = licence.title + // Build attributed text + let libraryTitleAttribut = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize + 2)] + let libraryLicenceAttribut = [NSFontAttributeName: UIFont.systemFont(ofSize: UIFont.systemFontSize)] + let libraryTitle = NSMutableAttributedString(string: licence.title ?? "", + attributes: libraryTitleAttribut) + libraryTitle.append(NSAttributedString(string: "\n\n")) + libraryTitle.append(NSAttributedString(string: licence.detail ?? "", + attributes: libraryLicenceAttribut)) - // Library licence's detail - self.licenceDesc.text = licence.detail + // Set text + self.textLabel?.attributedText = libraryTitle } }