Init licence cell from LicenceFile object
This commit is contained in:
@@ -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:.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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!
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user