Compare commits

...
26 Commits
Author SHA1 Message Date
Florian Gabach e05dd8699e Bump to 1.0.5 2017-03-08 17:17:39 +01:00
Florian Gabach 599de6b72a Set default customisation 2017-03-08 17:17:09 +01:00
Florian Gabach 5acb789a62 More licence for exemple 2017-03-08 17:05:02 +01:00
Florian Gabach fe8d28cfcb Fix title 2017-03-08 17:03:37 +01:00
Florian Gabach 25d3bee5c1 Bump version 2017-03-08 17:01:40 +01:00
Florian Gabach bc80c351fb Fix warning 2017-03-08 17:01:31 +01:00
Florian Gabach c2ddafb489 Add contributor 2017-03-08 17:00:21 +01:00
Florian Gabach f0eda60afa Merge pull request #4 from DavidLari/master
Add title property/Remove hard coded title
2017-03-08 16:58:39 +01:00
Florian Gabach b566e460ad Merge branch 'master' into master 2017-03-08 16:57:07 +01:00
Florian Gabach c39454be01 Update README.md 2017-03-08 16:54:29 +01:00
Florian Gabach ddca5365fc Add verbose mode 2017-03-08 16:52:24 +01:00
Florian Gabach 797b669aa1 Update README.md 2017-03-08 16:47:14 +01:00
Florian Gabach ec4d296b9f Add public customisation 2017-03-08 16:46:23 +01:00
David Lari 37fa7e98e4 Merge pull request #1 from DavidLari/DavidLari-patch-1
Remove print() statement
2017-03-08 10:43:58 -05:00
David Lari 7916776680 Remove hard coded title 2017-03-08 10:38:33 -05:00
David Lari cdbdd930e6 Add title property 2017-03-08 10:36:18 -05:00
David Lari e087efe1cb Remove print() statement 2017-03-08 10:33:37 -05:00
Florian Gabach 8746135531 Add CHANGELOG 2017-03-06 08:54:00 +01:00
Florian Gabach 94602ea642 Add swift version file 2017-03-06 08:35:53 +01:00
Florian Gabach 0e39df021c Bump version 2017-03-06 08:34:16 +01:00
Florian Gabach b4c935c6c5 Make extension internal 2017-03-06 08:34:01 +01:00
Florian Gabach c83354c959 Update README.md 2017-03-05 15:26:08 +01:00
Florian Gabach 9b7b96a359 Update README.md 2017-03-05 15:24:45 +01:00
Florian Gabach 0d0c610678 Update README.md 2017-03-05 15:21:10 +01:00
Florian Gabach c32927f2bd Update README.md 2017-03-03 11:33:27 +01:00
Florian Gabach f041e631c8 Add contributor & contributing file 2017-03-03 11:11:05 +01:00
16 changed files with 227 additions and 40 deletions
+1
View File
@@ -0,0 +1 @@
3.0.2
+14
View File
@@ -0,0 +1,14 @@
Changelog
==========
### 1.0.5
- Fix default customisation
### 1.0.4
- Add customisation way
### 1.0.3
- Remove public extension
+14
View File
@@ -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 ! 😘
+9
View File
@@ -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 */; };
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 */; };
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 */; };
/* End PBXBuildFile section */
@@ -54,6 +57,9 @@
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>"; };
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>"; };
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; };
@@ -147,6 +153,9 @@
C1CC167BCAEA652E1A800918 /* OpenSourceController.podspec */,
64B1D807A1D310FDA418A3AD /* README.md */,
7992D734190D4686F9AF2409 /* LICENSE */,
767195EC1E697890005424C6 /* CONTRIBUTORS.md */,
767195EE1E697896005424C6 /* CONTRIBUTING.md */,
768FE1CB1E7062350037E80E /* CHANGELOG.md */,
);
name = "Podspec Metadata";
sourceTree = "<group>";
@@ -405,7 +414,10 @@
buildActionMask = 2147483647;
files = (
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
768FE1CC1E7062350037E80E /* CHANGELOG.md in Sources */,
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
767195EF1E697896005424C6 /* CONTRIBUTING.md in Sources */,
767195ED1E697890005424C6 /* CONTRIBUTORS.md in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -11,6 +11,8 @@ import OpenSourceController
class ViewController: UIViewController {
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
// 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.
}
// MARK: - Action
/// Handle button click & show the controller with licences
@IBAction func showOpenSource(_ sender: Any) {
// Create controller
let openSourceVC = OpenSourceController()
// Apply somre customisation if you want !
//self.controllerCustomUI(openSourceVC: openSourceVC)
// Init with LicenceFile object
openSourceVC.licences = [LicenceFile(title: "FacebookImagePicker",
url: "https://raw.githubusercontent.com/terflogag/FacebookImagePicker/master/LICENSE"),
LicenceFile(title: "JSQMessagesViewController",
url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/develop/LICENSE"),
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
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 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'OpenSourceController'
s.version = '1.0.2'
s.version = '1.0.5'
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.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 {
// Contains list of licence object
public var licences: [LicenceFile]?
open var licences: [LicenceFile]?
// Configuration
open var config = OpenSourceControllerConfig()
/// Present OpenSourceViewController embbeded in navigation controller
///
/// - Parameter from: the source controller
public final func presentOpenSourceController(from: UIViewController) {
open func presentOpenSourceController(from: UIViewController) {
// Create open source controller
let licenceController = OpenSourceViewController()
// Init licence
licenceController.licences = self.licences
// Init config
licenceController.config = self.config
// Embed in navigation controller
let navController = UINavigationController(rootViewController: licenceController)
@@ -19,7 +19,10 @@ class OpenSourceViewController: UITableViewController {
private let reuseIdentifier = "openSourceCell"
/// 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
fileprivate var downloadedLicence: [LicenceFile]? {
@@ -54,7 +57,8 @@ class OpenSourceViewController: UITableViewController {
fileprivate func prepareLicences() {
if let licences = self.licences {
self.startLoading()
LicenceDownloader.downloadLicences(licences: licences) { () in
LicenceDownloader.downloadLicences(licences: licences,
config: self.config) { () in
// Update licences
self.downloadedLicence = self.licences
}
@@ -65,18 +69,31 @@ class OpenSourceViewController: UITableViewController {
fileprivate func prepareTableView() {
// Common init
self.tableView.tableFooterView = UIView()
self.title = NSLocalizedString("Tiers library", comment: "")
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.delegate = self
self.tableView.separatorStyle = .singleLine
self.tableView.backgroundColor = AppearenceManager.whiteCustom
if let backgroundColor = self.config.uiConfig.backgroundColor {
self.tableView.backgroundColor = backgroundColor
}
// Navigation bar
if let tintColor = self.config.uiConfig.barTintColor {
self.navigationController?.navigationBar.barTintColor = tintColor
}
if let textColor = self.config.uiConfig.titleColor {
let attribut = [NSForegroundColorAttributeName: textColor]
self.navigationController?.navigationBar.titleTextAttributes = attribut
}
// Close button (on the right corner of navigation bar)
let closeButton = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(self.closePicker))
closeButton.tintColor = AppearenceManager.black
closeButton.tintColor = config.uiConfig.closeButtonColor ?? UIColor.black
self.navigationItem.rightBarButtonItem = closeButton
// Loading indicator
@@ -121,19 +138,22 @@ class OpenSourceViewController: UITableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: self.reuseIdentifier,
for: indexPath) as? OpenSourceTableViewCell
// Init cell
if cell == nil {
cell = OpenSourceTableViewCell(style: UITableViewCellStyle.default,
reuseIdentifier: self.reuseIdentifier)
}
// Configure the cell with licence
if let licence = self.downloadedLicence?.get(at: indexPath.row) {
cell?.configure(licence: licence)
cell?.configure(licence: licence, config: self.config)
}
return cell!
}
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
// Automatic dimension
return UITableViewAutomaticDimension
}
@@ -11,7 +11,7 @@ import Foundation
extension Array {
/// Get an index safely
public func get(at index: Int) -> Element? {
func get(at index: Int) -> Element? {
guard index >= 0
&& index < count else {
return nil
@@ -16,6 +16,7 @@ class LicenceDownloader: NSObject {
/// - licences: array which contains licence model model
/// - completion: end downloading completion
class func downloadLicences(licences: [LicenceFile],
config: OpenSourceControllerConfig,
completion: @escaping () -> Void) {
// Number of licences
let licenceCount = licences.count
@@ -25,7 +26,7 @@ class LicenceDownloader: NSObject {
// Download licence's detail for every lience
for licence in licences {
licence.downloadLicenceDetail(completion: { () in
licence.downloadLicenceDetail(config: config, completion: { () in
alreadyDownloaded += 1
// If this is the last licence, perfom completion
@@ -38,7 +38,8 @@ public class LicenceFile: NSObject {
/// Download licence detail
///
/// - 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) {
let task = URLSession.shared.dataTask(with: url) { (data, _, _) in
if let data = data,
@@ -48,7 +49,9 @@ public class LicenceFile: NSObject {
self.detail = html
// Log
print("Licence for \(self.title ?? "") downloaded with success.")
if config.verbose {
print("Licence for \(self.title ?? "") downloaded with success.")
}
}
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?
/// Will be applied to the navigation bar
public var backgroundColor: UIColor?
/// Will be applied to licence text
public var licenceBackgroundColor: UIColor?
/// Will be applied to the navigation bar
public var closeButtonColor: UIColor?
/// Will be applied to licence text
public var licenceTextColor: UIColor?
/// Will be applied to licence text
public var titleColor: UIColor?
}
/// 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,
reuseIdentifier: reuseIdentifier)
// Prepare cell
self.prepareCellComponent()
}
@@ -47,7 +48,7 @@ class OpenSourceTableViewCell: UITableViewCell {
/// Initialize the cell content with Licence model
///
/// - Parameter licence: the licence model
func configure(licence: LicenceFile) {
func configure(licence: LicenceFile, config: OpenSourceControllerConfig) {
// Build attributed text
let libraryTitleAttribut = [NSFontAttributeName: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize + 2)]
@@ -60,5 +61,11 @@ class OpenSourceTableViewCell: UITableViewCell {
// Set text
self.textLabel?.attributedText = libraryTitle
self.textLabel?.textColor = config.uiConfig.licenceTextColor
// Background
if let backgroundColor = config.uiConfig.licenceBackgroundColor {
self.backgroundColor = backgroundColor
}
}
}
+40 -8
View File
@@ -3,7 +3,9 @@
</p>
<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 align="center">
@@ -11,6 +13,7 @@
• <a href="#installation">Installation</a>
• <a href="#usage">Usage</a>
• <a href="#translation">Translation</a>
• <a href="#customisation">Customisation</a>
• <a href="#license">License</a>
</p>
@@ -23,15 +26,15 @@ Display a screen with all licences used in your application can be painful to ma
## Features
- [x] Display tableView with licences used in your app
- [x] AppStore ready
- [x] Swift 3
- [x] Download licence from an URL
## Todo
## Todo (feel free to make PR)
- [ ] Download licence from Podfile (https://github.com/terflogag/OpenSourceController/issues/1)
- [ ] Download licence from Cartfile (https://github.com/terflogag/OpenSourceController/issues/2)
- [ ] Carthage support (feel free to make PR)
- [ ] Unit & UI Test (feel free to make PR)
- [ ] Download licence from local file
- [ ] Carthage support
- [ ] Unit & UI Test
## Requirements
@@ -72,18 +75,47 @@ url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/d
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
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>";
```
## 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)
- [Giraf](https://itunes.apple.com/fr/app/giraf/id1136592561?mt=8)