Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5acb789a62 | ||
|
|
fe8d28cfcb | ||
|
|
25d3bee5c1 | ||
|
|
bc80c351fb | ||
|
|
c2ddafb489 | ||
|
|
f0eda60afa | ||
|
|
b566e460ad | ||
|
|
c39454be01 | ||
|
|
ddca5365fc | ||
|
|
797b669aa1 | ||
|
|
ec4d296b9f | ||
|
|
37fa7e98e4 | ||
|
|
7916776680 | ||
|
|
cdbdd930e6 | ||
|
|
e087efe1cb | ||
|
|
8746135531 | ||
|
|
94602ea642 | ||
|
|
0e39df021c | ||
|
|
b4c935c6c5 | ||
|
|
c83354c959 | ||
|
|
9b7b96a359 | ||
|
|
0d0c610678 | ||
|
|
c32927f2bd | ||
|
|
f041e631c8 |
@@ -0,0 +1 @@
|
|||||||
|
3.0.2
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
Changelog
|
||||||
|
==========
|
||||||
|
|
||||||
|
### 1.0.4
|
||||||
|
|
||||||
|
- Add customisation way
|
||||||
|
|
||||||
|
### 1.0.3
|
||||||
|
|
||||||
|
- Remove public extension
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
Contributing 🚀
|
||||||
|
===============
|
||||||
|
|
||||||
|
For fixes, improvements or ideas, fork the repository and issue a pull request.
|
||||||
|
|
||||||
|
To get a pull request accepted, please adhere to these rules:
|
||||||
|
- Work from the latest `master` branch.
|
||||||
|
- Respect current code style and respect the [SwiftLint](https://github.com/realm/SwiftLint) rules (see swiftlint's file).
|
||||||
|
- If this is about new features, please make sure to add enable/disable configuration.
|
||||||
|
|
||||||
|
Ideally, only work on one feature at a time.
|
||||||
|
If you've done work on the code (i.e. not just fixes to the README), add yourself to the top of [`CONTRIBUTORS.md`](./CONTRIBUTORS.md).
|
||||||
|
|
||||||
|
Thank you, and happy coding ! 😘
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
Contributors
|
||||||
|
============
|
||||||
|
|
||||||
|
Contributors to the codebase :
|
||||||
|
|
||||||
|
| Name | Github handle | Mail |
|
||||||
|
| ------------- |------------- | ----- |
|
||||||
|
| David Lari | DavidLari | / |
|
||||||
|
|
||||||
@@ -14,6 +14,9 @@
|
|||||||
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
|
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
|
||||||
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
|
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
|
||||||
6B97E461A777A38641DFF2BB /* Pods_OpenSourceController_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C1ED0DAD6B8C56070C2725 /* Pods_OpenSourceController_Example.framework */; };
|
6B97E461A777A38641DFF2BB /* Pods_OpenSourceController_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C1ED0DAD6B8C56070C2725 /* Pods_OpenSourceController_Example.framework */; };
|
||||||
|
767195ED1E697890005424C6 /* CONTRIBUTORS.md in Sources */ = {isa = PBXBuildFile; fileRef = 767195EC1E697890005424C6 /* CONTRIBUTORS.md */; };
|
||||||
|
767195EF1E697896005424C6 /* CONTRIBUTING.md in Sources */ = {isa = PBXBuildFile; fileRef = 767195EE1E697896005424C6 /* CONTRIBUTING.md */; };
|
||||||
|
768FE1CC1E7062350037E80E /* CHANGELOG.md in Sources */ = {isa = PBXBuildFile; fileRef = 768FE1CB1E7062350037E80E /* CHANGELOG.md */; };
|
||||||
DE9F38AD98FC5DFBDF7EADF1 /* Pods_OpenSourceController_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B544A0C5F114143EEFD0366A /* Pods_OpenSourceController_Tests.framework */; };
|
DE9F38AD98FC5DFBDF7EADF1 /* Pods_OpenSourceController_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B544A0C5F114143EEFD0366A /* Pods_OpenSourceController_Tests.framework */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
@@ -54,6 +57,9 @@
|
|||||||
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
|
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
|
||||||
64B1D807A1D310FDA418A3AD /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
|
64B1D807A1D310FDA418A3AD /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
|
||||||
64E410A815536CB40C9EFD4D /* Pods-OpenSourceController_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OpenSourceController_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OpenSourceController_Example/Pods-OpenSourceController_Example.debug.xcconfig"; sourceTree = "<group>"; };
|
64E410A815536CB40C9EFD4D /* Pods-OpenSourceController_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OpenSourceController_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OpenSourceController_Example/Pods-OpenSourceController_Example.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
767195EC1E697890005424C6 /* CONTRIBUTORS.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CONTRIBUTORS.md; path = ../CONTRIBUTORS.md; sourceTree = "<group>"; };
|
||||||
|
767195EE1E697896005424C6 /* CONTRIBUTING.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CONTRIBUTING.md; path = ../CONTRIBUTING.md; sourceTree = "<group>"; };
|
||||||
|
768FE1CB1E7062350037E80E /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = "<group>"; };
|
||||||
7992D734190D4686F9AF2409 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
|
7992D734190D4686F9AF2409 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
|
||||||
87501F335829155E114806FA /* Pods-OpenSourceController_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OpenSourceController_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-OpenSourceController_Tests/Pods-OpenSourceController_Tests.release.xcconfig"; sourceTree = "<group>"; };
|
87501F335829155E114806FA /* Pods-OpenSourceController_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OpenSourceController_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-OpenSourceController_Tests/Pods-OpenSourceController_Tests.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
B544A0C5F114143EEFD0366A /* Pods_OpenSourceController_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OpenSourceController_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
B544A0C5F114143EEFD0366A /* Pods_OpenSourceController_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OpenSourceController_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@@ -147,6 +153,9 @@
|
|||||||
C1CC167BCAEA652E1A800918 /* OpenSourceController.podspec */,
|
C1CC167BCAEA652E1A800918 /* OpenSourceController.podspec */,
|
||||||
64B1D807A1D310FDA418A3AD /* README.md */,
|
64B1D807A1D310FDA418A3AD /* README.md */,
|
||||||
7992D734190D4686F9AF2409 /* LICENSE */,
|
7992D734190D4686F9AF2409 /* LICENSE */,
|
||||||
|
767195EC1E697890005424C6 /* CONTRIBUTORS.md */,
|
||||||
|
767195EE1E697896005424C6 /* CONTRIBUTING.md */,
|
||||||
|
768FE1CB1E7062350037E80E /* CHANGELOG.md */,
|
||||||
);
|
);
|
||||||
name = "Podspec Metadata";
|
name = "Podspec Metadata";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -405,7 +414,10 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
|
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
|
||||||
|
768FE1CC1E7062350037E80E /* CHANGELOG.md in Sources */,
|
||||||
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
|
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
|
||||||
|
767195EF1E697896005424C6 /* CONTRIBUTING.md in Sources */,
|
||||||
|
767195ED1E697890005424C6 /* CONTRIBUTORS.md in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import OpenSourceController
|
|||||||
|
|
||||||
class ViewController: UIViewController {
|
class ViewController: UIViewController {
|
||||||
|
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view, typically from a nib
|
// Do any additional setup after loading the view, typically from a nib
|
||||||
@@ -21,19 +23,61 @@ class ViewController: UIViewController {
|
|||||||
// Dispose of any resources that can be recreated.
|
// Dispose of any resources that can be recreated.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Action
|
||||||
|
|
||||||
|
/// Handle button click & show the controller with licences
|
||||||
@IBAction func showOpenSource(_ sender: Any) {
|
@IBAction func showOpenSource(_ sender: Any) {
|
||||||
// Create controller
|
// Create controller
|
||||||
let openSourceVC = OpenSourceController()
|
let openSourceVC = OpenSourceController()
|
||||||
|
|
||||||
|
// Apply somre customisation if you want !
|
||||||
|
//self.controllerCustomUI(openSourceVC: openSourceVC)
|
||||||
|
|
||||||
// Init with LicenceFile object
|
// Init with LicenceFile object
|
||||||
openSourceVC.licences = [LicenceFile(title: "FacebookImagePicker",
|
openSourceVC.licences = [LicenceFile(title: "FacebookImagePicker",
|
||||||
url: "https://raw.githubusercontent.com/terflogag/FacebookImagePicker/master/LICENSE"),
|
url: "https://raw.githubusercontent.com/terflogag/FacebookImagePicker/master/LICENSE"),
|
||||||
LicenceFile(title: "JSQMessagesViewController",
|
LicenceFile(title: "JSQMessagesViewController",
|
||||||
url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/develop/LICENSE"),
|
url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/develop/LICENSE"),
|
||||||
LicenceFile(title: "OpenSourceController",
|
LicenceFile(title: "OpenSourceController",
|
||||||
url: "https://raw.githubusercontent.com/terflogag/OpenSourceController/master/LICENSE")]
|
url: "https://raw.githubusercontent.com/terflogag/OpenSourceController/master/LICENSE"),
|
||||||
|
LicenceFile(title: "PermissionScope",
|
||||||
|
url: "https://raw.githubusercontent.com/nickoneill/PermissionScope/master/LICENSE"),
|
||||||
|
LicenceFile(title: "EasyTipView",
|
||||||
|
url: "https://raw.githubusercontent.com/teodorpatras/EasyTipView/master/LICENSE"),
|
||||||
|
LicenceFile(title: "ReachabilitySwift",
|
||||||
|
url: "https://raw.githubusercontent.com/ashleymills/Reachability.swift/master/LICENSE"),
|
||||||
|
LicenceFile(title: "KeychainAccess",
|
||||||
|
url: "https://raw.githubusercontent.com/kishikawakatsumi/KeychainAccess/master/LICENSE")]
|
||||||
|
|
||||||
// Present controller
|
// Present controller
|
||||||
openSourceVC.presentOpenSourceController(from: self)
|
openSourceVC.presentOpenSourceController(from: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Customization
|
||||||
|
|
||||||
|
fileprivate func controllerCustomUI(openSourceVC: OpenSourceController) {
|
||||||
|
// Navigation bar title
|
||||||
|
openSourceVC.config.title = "MyCustomTitle"
|
||||||
|
|
||||||
|
// Navigation bar tint color
|
||||||
|
openSourceVC.config.uiConfig.barTintColor = UIColor.red
|
||||||
|
|
||||||
|
// Close button color
|
||||||
|
openSourceVC.config.uiConfig.closeButtonColor = UIColor.white
|
||||||
|
|
||||||
|
// BackgroundColor
|
||||||
|
openSourceVC.config.uiConfig.backgroundColor = UIColor.red.withAlphaComponent(0.6)
|
||||||
|
|
||||||
|
// Licence text color
|
||||||
|
openSourceVC.config.uiConfig.licenceTextColor = UIColor.white
|
||||||
|
|
||||||
|
// Navigation bar title color
|
||||||
|
openSourceVC.config.uiConfig.titleColor = UIColor.white
|
||||||
|
|
||||||
|
// Licence cell background color
|
||||||
|
openSourceVC.config.uiConfig.licenceBackgroundColor = UIColor.red
|
||||||
|
|
||||||
|
// Verbose mode
|
||||||
|
openSourceVC.config.verbose = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'OpenSourceController'
|
s.name = 'OpenSourceController'
|
||||||
s.version = '1.0.2'
|
s.version = '1.0.4'
|
||||||
s.summary = 'Display all the librarys licence used in your application. Enjoy !'
|
s.summary = 'Display all the librarys licence used in your application. Enjoy !'
|
||||||
s.description = 'Display a screen with all licence used in your apply can be painful to maintain. OpenSourceController was built to respond to this problem. OpenSourceController is a simple parser to display the licences which are used in your application.'
|
s.description = 'Display a screen with all licence used in your apply can be painful to maintain. OpenSourceController was built to respond to this problem. OpenSourceController is a simple parser to display the licences which are used in your application.'
|
||||||
s.homepage = 'https://github.com/terflogag/OpenSourceController'
|
s.homepage = 'https://github.com/terflogag/OpenSourceController'
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
//
|
|
||||||
// AppearenceManager.swift
|
|
||||||
// Pods
|
|
||||||
//
|
|
||||||
// Created by Florian Gabach on 01/03/2017.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
class AppearenceManager: NSObject {
|
|
||||||
// White color : http://www.color-hex.com/color/ffffff
|
|
||||||
static let whiteCustom = UIColor(red: 246/255.0, green: 246/255.0, blue: 246/255.0, alpha: 1.0)
|
|
||||||
|
|
||||||
// Black color : http://www.color-hex.com/color/000000
|
|
||||||
static let black = UIColor.black
|
|
||||||
}
|
|
||||||
@@ -11,18 +11,24 @@ import UIKit
|
|||||||
public class OpenSourceController: NSObject {
|
public class OpenSourceController: NSObject {
|
||||||
|
|
||||||
// Contains list of licence object
|
// Contains list of licence object
|
||||||
public var licences: [LicenceFile]?
|
open var licences: [LicenceFile]?
|
||||||
|
|
||||||
|
// Configuration
|
||||||
|
open var config = OpenSourceControllerConfig()
|
||||||
|
|
||||||
/// Present OpenSourceViewController embbeded in navigation controller
|
/// Present OpenSourceViewController embbeded in navigation controller
|
||||||
///
|
///
|
||||||
/// - Parameter from: the source controller
|
/// - Parameter from: the source controller
|
||||||
public final func presentOpenSourceController(from: UIViewController) {
|
open func presentOpenSourceController(from: UIViewController) {
|
||||||
// Create open source controller
|
// Create open source controller
|
||||||
let licenceController = OpenSourceViewController()
|
let licenceController = OpenSourceViewController()
|
||||||
|
|
||||||
// Init licence
|
// Init licence
|
||||||
licenceController.licences = self.licences
|
licenceController.licences = self.licences
|
||||||
|
|
||||||
|
// Init config
|
||||||
|
licenceController.config = self.config
|
||||||
|
|
||||||
// Embed in navigation controller
|
// Embed in navigation controller
|
||||||
let navController = UINavigationController(rootViewController: licenceController)
|
let navController = UINavigationController(rootViewController: licenceController)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ class OpenSourceViewController: UITableViewController {
|
|||||||
private let reuseIdentifier = "openSourceCell"
|
private let reuseIdentifier = "openSourceCell"
|
||||||
|
|
||||||
/// Contains all licence object before downloaded
|
/// Contains all licence object before downloaded
|
||||||
var licences: [LicenceFile]?
|
internal var licences: [LicenceFile]?
|
||||||
|
|
||||||
|
// Controller configuration for customization
|
||||||
|
internal var config = OpenSourceControllerConfig()
|
||||||
|
|
||||||
/// Contains all licences object after downloaded
|
/// Contains all licences object after downloaded
|
||||||
fileprivate var downloadedLicence: [LicenceFile]? {
|
fileprivate var downloadedLicence: [LicenceFile]? {
|
||||||
@@ -54,7 +57,8 @@ class OpenSourceViewController: UITableViewController {
|
|||||||
fileprivate func prepareLicences() {
|
fileprivate func prepareLicences() {
|
||||||
if let licences = self.licences {
|
if let licences = self.licences {
|
||||||
self.startLoading()
|
self.startLoading()
|
||||||
LicenceDownloader.downloadLicences(licences: licences) { () in
|
LicenceDownloader.downloadLicences(licences: licences,
|
||||||
|
config: self.config) { () in
|
||||||
// Update licences
|
// Update licences
|
||||||
self.downloadedLicence = self.licences
|
self.downloadedLicence = self.licences
|
||||||
}
|
}
|
||||||
@@ -65,18 +69,25 @@ class OpenSourceViewController: UITableViewController {
|
|||||||
fileprivate func prepareTableView() {
|
fileprivate func prepareTableView() {
|
||||||
// Common init
|
// Common init
|
||||||
self.tableView.tableFooterView = UIView()
|
self.tableView.tableFooterView = UIView()
|
||||||
self.title = NSLocalizedString("Tiers library", comment: "")
|
|
||||||
self.tableView.register(OpenSourceTableViewCell.self, forCellReuseIdentifier: self.reuseIdentifier)
|
self.tableView.register(OpenSourceTableViewCell.self, forCellReuseIdentifier: self.reuseIdentifier)
|
||||||
|
self.title = self.config.title
|
||||||
|
self.tableView.register(OpenSourceTableViewCell.self,
|
||||||
|
forCellReuseIdentifier: self.reuseIdentifier)
|
||||||
self.tableView.dataSource = self
|
self.tableView.dataSource = self
|
||||||
self.tableView.delegate = self
|
self.tableView.delegate = self
|
||||||
self.tableView.separatorStyle = .singleLine
|
self.tableView.separatorStyle = .singleLine
|
||||||
self.tableView.backgroundColor = AppearenceManager.whiteCustom
|
self.tableView.backgroundColor = config.uiConfig.backgroundColor
|
||||||
|
|
||||||
|
// Navigation bar
|
||||||
|
self.navigationController?.navigationBar.barTintColor = self.config.uiConfig.barTintColor
|
||||||
|
let attribut = [NSForegroundColorAttributeName: self.config.uiConfig.titleColor]
|
||||||
|
self.navigationController?.navigationBar.titleTextAttributes = attribut
|
||||||
|
|
||||||
// Close button (on the right corner of navigation bar)
|
// Close button (on the right corner of navigation bar)
|
||||||
let closeButton = UIBarButtonItem(barButtonSystemItem: .stop,
|
let closeButton = UIBarButtonItem(barButtonSystemItem: .stop,
|
||||||
target: self,
|
target: self,
|
||||||
action: #selector(self.closePicker))
|
action: #selector(self.closePicker))
|
||||||
closeButton.tintColor = AppearenceManager.black
|
closeButton.tintColor = config.uiConfig.closeButtonColor
|
||||||
self.navigationItem.rightBarButtonItem = closeButton
|
self.navigationItem.rightBarButtonItem = closeButton
|
||||||
|
|
||||||
// Loading indicator
|
// Loading indicator
|
||||||
@@ -121,19 +132,22 @@ class OpenSourceViewController: UITableViewController {
|
|||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
var cell = tableView.dequeueReusableCell(withIdentifier: self.reuseIdentifier,
|
var cell = tableView.dequeueReusableCell(withIdentifier: self.reuseIdentifier,
|
||||||
for: indexPath) as? OpenSourceTableViewCell
|
for: indexPath) as? OpenSourceTableViewCell
|
||||||
|
// Init cell
|
||||||
if cell == nil {
|
if cell == nil {
|
||||||
cell = OpenSourceTableViewCell(style: UITableViewCellStyle.default,
|
cell = OpenSourceTableViewCell(style: UITableViewCellStyle.default,
|
||||||
reuseIdentifier: self.reuseIdentifier)
|
reuseIdentifier: self.reuseIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configure the cell with licence
|
||||||
if let licence = self.downloadedLicence?.get(at: indexPath.row) {
|
if let licence = self.downloadedLicence?.get(at: indexPath.row) {
|
||||||
cell?.configure(licence: licence)
|
cell?.configure(licence: licence, config: self.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cell!
|
return cell!
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||||
|
// Automatic dimension
|
||||||
return UITableViewAutomaticDimension
|
return UITableViewAutomaticDimension
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Foundation
|
|||||||
extension Array {
|
extension Array {
|
||||||
|
|
||||||
/// Get an index safely
|
/// Get an index safely
|
||||||
public func get(at index: Int) -> Element? {
|
func get(at index: Int) -> Element? {
|
||||||
guard index >= 0
|
guard index >= 0
|
||||||
&& index < count else {
|
&& index < count else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class LicenceDownloader: NSObject {
|
|||||||
/// - licences: array which contains licence model model
|
/// - licences: array which contains licence model model
|
||||||
/// - completion: end downloading completion
|
/// - completion: end downloading completion
|
||||||
class func downloadLicences(licences: [LicenceFile],
|
class func downloadLicences(licences: [LicenceFile],
|
||||||
|
config: OpenSourceControllerConfig,
|
||||||
completion: @escaping () -> Void) {
|
completion: @escaping () -> Void) {
|
||||||
// Number of licences
|
// Number of licences
|
||||||
let licenceCount = licences.count
|
let licenceCount = licences.count
|
||||||
@@ -25,7 +26,7 @@ class LicenceDownloader: NSObject {
|
|||||||
|
|
||||||
// Download licence's detail for every lience
|
// Download licence's detail for every lience
|
||||||
for licence in licences {
|
for licence in licences {
|
||||||
licence.downloadLicenceDetail(completion: { () in
|
licence.downloadLicenceDetail(config: config, completion: { () in
|
||||||
alreadyDownloaded += 1
|
alreadyDownloaded += 1
|
||||||
|
|
||||||
// If this is the last licence, perfom completion
|
// If this is the last licence, perfom completion
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ public class LicenceFile: NSObject {
|
|||||||
/// Download licence detail
|
/// Download licence detail
|
||||||
///
|
///
|
||||||
/// - Parameter completion: end of download handler
|
/// - Parameter completion: end of download handler
|
||||||
func downloadLicenceDetail(completion: @escaping (Void) -> Void) {
|
func downloadLicenceDetail(config: OpenSourceControllerConfig,
|
||||||
|
completion: @escaping (Void) -> Void) {
|
||||||
if let url = URL(string: self.url) {
|
if let url = URL(string: self.url) {
|
||||||
let task = URLSession.shared.dataTask(with: url) { (data, _, _) in
|
let task = URLSession.shared.dataTask(with: url) { (data, _, _) in
|
||||||
if let data = data,
|
if let data = data,
|
||||||
@@ -48,7 +49,9 @@ public class LicenceFile: NSObject {
|
|||||||
self.detail = html
|
self.detail = html
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
print("Licence for \(self.title ?? "") downloaded with success.")
|
if config.verbose {
|
||||||
|
print("Licence for \(self.title ?? "") downloaded with success.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// OpenSourceControllerConfig.swift
|
||||||
|
// Pods
|
||||||
|
//
|
||||||
|
// Created by Florian Gabach on 08/03/2017.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
/// Simple struct to hold settings
|
||||||
|
public struct OpenSourceControllerConfig {
|
||||||
|
|
||||||
|
/// Sub-stuct holding configuration relevant to UI presentation !
|
||||||
|
public struct UIConfig {
|
||||||
|
/// Will be applied to the navigation bar
|
||||||
|
public var barTintColor: UIColor = UIColor(red: 246/255.0, green: 246/255.0, blue: 246/255.0, alpha: 1.0)
|
||||||
|
|
||||||
|
/// Will be applied to the navigation bar
|
||||||
|
public var backgroundColor: UIColor = UIColor(red: 246/255.0, green: 246/255.0, blue: 246/255.0, alpha: 1.0)
|
||||||
|
|
||||||
|
/// Will be applied to licence text
|
||||||
|
public var licenceBackgroundColor: UIColor = UIColor.white
|
||||||
|
|
||||||
|
/// Will be applied to the navigation bar
|
||||||
|
public var closeButtonColor: UIColor = UIColor.black
|
||||||
|
|
||||||
|
/// Will be applied to licence text
|
||||||
|
public var licenceTextColor: UIColor = UIColor.black
|
||||||
|
|
||||||
|
/// Will be applied to licence text
|
||||||
|
public var titleColor: UIColor = UIColor.black
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Will be applied to the navigation bar title
|
||||||
|
public var title: String = "Tiers library"
|
||||||
|
|
||||||
|
// Verbose mode for print log when licence are downloaded
|
||||||
|
public var verbose: Bool = false
|
||||||
|
|
||||||
|
/// UI-specific configuration.
|
||||||
|
public var uiConfig = UIConfig()
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ class OpenSourceTableViewCell: UITableViewCell {
|
|||||||
super.init(style: .default,
|
super.init(style: .default,
|
||||||
reuseIdentifier: reuseIdentifier)
|
reuseIdentifier: reuseIdentifier)
|
||||||
|
|
||||||
|
// Prepare cell
|
||||||
self.prepareCellComponent()
|
self.prepareCellComponent()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ class OpenSourceTableViewCell: UITableViewCell {
|
|||||||
/// Initialize the cell content with Licence model
|
/// Initialize the cell content with Licence model
|
||||||
///
|
///
|
||||||
/// - Parameter licence: the licence model
|
/// - Parameter licence: the licence model
|
||||||
func configure(licence: LicenceFile) {
|
func configure(licence: LicenceFile, config: OpenSourceControllerConfig) {
|
||||||
|
|
||||||
// Build attributed text
|
// Build attributed text
|
||||||
let libraryTitleAttribut = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize + 2)]
|
let libraryTitleAttribut = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize + 2)]
|
||||||
@@ -60,5 +61,9 @@ class OpenSourceTableViewCell: UITableViewCell {
|
|||||||
|
|
||||||
// Set text
|
// Set text
|
||||||
self.textLabel?.attributedText = libraryTitle
|
self.textLabel?.attributedText = libraryTitle
|
||||||
|
self.textLabel?.textColor = config.uiConfig.licenceTextColor
|
||||||
|
|
||||||
|
// Background
|
||||||
|
self.backgroundColor = config.uiConfig.licenceBackgroundColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="Prs welcome" />
|
<a href="https://cocoapods.org/pods/OpenSourceController" target="_blank"><img src="https://img.shields.io/cocoapods/v/OpenSourceController.svg?style=flat" alt="Cocoapods version" /></a>
|
||||||
|
<a href="http://cocoapods.org/pods/OpenSourceController" target="_blank"><img src="https://img.shields.io/cocoapods/p/OpenSourceController.svg?style=flat" alt="Cocoapods plateform" /></a>
|
||||||
|
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="Prs welcome" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
@@ -11,6 +13,7 @@
|
|||||||
• <a href="#installation">Installation</a>
|
• <a href="#installation">Installation</a>
|
||||||
• <a href="#usage">Usage</a>
|
• <a href="#usage">Usage</a>
|
||||||
• <a href="#translation">Translation</a>
|
• <a href="#translation">Translation</a>
|
||||||
|
• <a href="#customisation">Customisation</a>
|
||||||
• <a href="#license">License</a>
|
• <a href="#license">License</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -23,15 +26,15 @@ Display a screen with all licences used in your application can be painful to ma
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- [x] Display tableView with licences used in your app
|
- [x] Display tableView with licences used in your app
|
||||||
- [x] AppStore ready
|
- [x] Download licence from an URL
|
||||||
- [x] Swift 3
|
|
||||||
|
|
||||||
## Todo
|
## Todo (feel free to make PR)
|
||||||
|
|
||||||
- [ ] Download licence from Podfile (https://github.com/terflogag/OpenSourceController/issues/1)
|
- [ ] Download licence from Podfile (https://github.com/terflogag/OpenSourceController/issues/1)
|
||||||
- [ ] Download licence from Cartfile (https://github.com/terflogag/OpenSourceController/issues/2)
|
- [ ] Download licence from Cartfile (https://github.com/terflogag/OpenSourceController/issues/2)
|
||||||
- [ ] Carthage support (feel free to make PR)
|
- [ ] Download licence from local file
|
||||||
- [ ] Unit & UI Test (feel free to make PR)
|
- [ ] Carthage support
|
||||||
|
- [ ] Unit & UI Test
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -72,18 +75,47 @@ url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/d
|
|||||||
openSourceVC.presentOpenSourceController(from: self)
|
openSourceVC.presentOpenSourceController(from: self)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Customisation
|
||||||
|
|
||||||
|
You can apply some customisation. To do it you can use the OpenSourceControllerConfig structure like this :
|
||||||
|
|
||||||
|
```swift
|
||||||
|
// Navigation bar title
|
||||||
|
openSourceVC.config.title = "MyCustomTitle"
|
||||||
|
|
||||||
|
// Navigation bar tint color
|
||||||
|
openSourceVC.config.uiConfig.barTintColor = UIColor.red
|
||||||
|
|
||||||
|
// Close button color
|
||||||
|
openSourceVC.config.uiConfig.closeButtonColor = UIColor.white
|
||||||
|
|
||||||
|
// BackgroundColor
|
||||||
|
openSourceVC.config.uiConfig.backgroundColor = UIColor.red.withAlphaComponent(0.6)
|
||||||
|
|
||||||
|
// Licence text color
|
||||||
|
openSourceVC.config.uiConfig.licenceTextColor = UIColor.white
|
||||||
|
|
||||||
|
// Navigation bar title color
|
||||||
|
openSourceVC.config.uiConfig.titleColor = UIColor.white
|
||||||
|
|
||||||
|
// Licence cell background color
|
||||||
|
openSourceVC.config.uiConfig.licenceBackgroundColor = UIColor.red
|
||||||
|
|
||||||
|
// Verbose mode
|
||||||
|
openSourceVC.config.verbose = true
|
||||||
|
```
|
||||||
|
|
||||||
## Translation
|
## Translation
|
||||||
|
|
||||||
OpenSourceController is currently write in english. If you need translation for the permission popup (or whatever thing), just add this line in your localized file :
|
OpenSourceController is currently write in english. If you need translation for the permission popup (or whatever thing), just add this line in your localized file :
|
||||||
|
|
||||||
```
|
```
|
||||||
"Tiers library" = "<your_translation>";
|
|
||||||
"Unable to load this licence." = "<your_translation>";
|
"Unable to load this licence." = "<your_translation>";
|
||||||
```
|
```
|
||||||
|
|
||||||
## Applications
|
## Applications
|
||||||
|
|
||||||
Some applications already use this picker like :
|
Some applications already use this controller like :
|
||||||
- [Troll Generator](https://itunes.apple.com/fr/app/troll-generator/id1038097542?mt=8)
|
- [Troll Generator](https://itunes.apple.com/fr/app/troll-generator/id1038097542?mt=8)
|
||||||
- [Giraf](https://itunes.apple.com/fr/app/giraf/id1136592561?mt=8)
|
- [Giraf](https://itunes.apple.com/fr/app/giraf/id1136592561?mt=8)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user