Compare commits

...
14 Commits
Author SHA1 Message Date
Florian Gabach 8ad819052c Bump to 2.1.2 2018-02-26 14:30:51 +01:00
Florian Gabach 318d3e1f8e Use DispatchGroup for download licences 2018-02-26 14:22:37 +01:00
Florian Gabach a7a6a1b315 Clean 2018-02-22 17:12:06 +01:00
Florian Gabach 96a45035a9 Update README.md 2017-12-26 14:15:15 +01:00
Florian Gabach 003ca5c285 Add framework.zip 2017-12-10 15:22:27 +01:00
Florian Gabach bc2e69440c Bump to 2.1.1 2017-12-10 15:18:17 +01:00
Florian Gabach 794d5a2d86 Fix podspec homepage 2017-12-10 14:39:33 +01:00
Florian Gabach c5beca03f7 Update pod meta 2017-12-10 14:32:17 +01:00
Florian Gabach 7ee4cfa0fd Clean 2017-12-10 14:30:58 +01:00
Florian Gabach 4dc34e956a Bump version 2017-12-10 14:29:07 +01:00
Florian Gabach 584e357f0e Allow to push controller 2017-12-10 14:28:56 +01:00
Florian Gabach 243ee49fc1 Add gitignore 2017-12-09 20:18:39 +01:00
Florian Gabach 5f53dbe6b5 Add carthage zip framework 2017-12-09 20:17:36 +01:00
Florian Gabach 97ceb32d29 Bump to 2.0.2 2017-12-08 16:11:26 +01:00
25 changed files with 112 additions and 45 deletions
+43
View File
@@ -0,0 +1,43 @@
# Mac OS X
.DS_Store
# Xcode
## Build generated
build/
DerivedData
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
.build/
# Carthage
Carthage/
# Cocoapods
Pods/
+12
View File
@@ -1,6 +1,18 @@
Changelog Changelog
========== ==========
### 2.1.2
- Use DispatchGroup for download
### 2.1.1
- Hide close button when push the controller
### 2.1.0
- Add push transition with `pushOpenSourceController(from: self)`
### 2.0.1 ### 2.0.1
- Clean code and move loader position - Clean code and move loader position
Binary file not shown.
@@ -19,6 +19,7 @@
76EAA8911E93F67B009A41DA /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EAA8901E93F67B009A41DA /* Array+Extensions.swift */; }; 76EAA8911E93F67B009A41DA /* Array+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EAA8901E93F67B009A41DA /* Array+Extensions.swift */; };
76EAA8941E93F681009A41DA /* OpenSourceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EAA8921E93F681009A41DA /* OpenSourceController.swift */; }; 76EAA8941E93F681009A41DA /* OpenSourceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EAA8921E93F681009A41DA /* OpenSourceController.swift */; };
76EAA8951E93F681009A41DA /* OpenSourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EAA8931E93F681009A41DA /* OpenSourceViewController.swift */; }; 76EAA8951E93F681009A41DA /* OpenSourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76EAA8931E93F681009A41DA /* OpenSourceViewController.swift */; };
C33E4D96204442AC00142EE6 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = C33E4D95204442AC00142EE6 /* CHANGELOG.md */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@@ -36,6 +37,7 @@
76EAA8901E93F67B009A41DA /* Array+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Array+Extensions.swift"; path = "../../Sources/Extensions/Array+Extensions.swift"; sourceTree = "<group>"; }; 76EAA8901E93F67B009A41DA /* Array+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Array+Extensions.swift"; path = "../../Sources/Extensions/Array+Extensions.swift"; sourceTree = "<group>"; };
76EAA8921E93F681009A41DA /* OpenSourceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenSourceController.swift; path = ../../Sources/Controller/OpenSourceController.swift; sourceTree = "<group>"; }; 76EAA8921E93F681009A41DA /* OpenSourceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenSourceController.swift; path = ../../Sources/Controller/OpenSourceController.swift; sourceTree = "<group>"; };
76EAA8931E93F681009A41DA /* OpenSourceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenSourceViewController.swift; path = ../../Sources/Controller/OpenSourceViewController.swift; sourceTree = "<group>"; }; 76EAA8931E93F681009A41DA /* OpenSourceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenSourceViewController.swift; path = ../../Sources/Controller/OpenSourceViewController.swift; sourceTree = "<group>"; };
C33E4D95204442AC00142EE6 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -52,6 +54,7 @@
76EAA8581E93F2CC009A41DA = { 76EAA8581E93F2CC009A41DA = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
C33E4D95204442AC00142EE6 /* CHANGELOG.md */,
76EAA8631E93F2CC009A41DA /* OpenSourceControllerDemo */, 76EAA8631E93F2CC009A41DA /* OpenSourceControllerDemo */,
76EAA8621E93F2CC009A41DA /* Products */, 76EAA8621E93F2CC009A41DA /* Products */,
); );
@@ -157,6 +160,7 @@
76EAA86F1E93F2CC009A41DA /* LaunchScreen.storyboard in Resources */, 76EAA86F1E93F2CC009A41DA /* LaunchScreen.storyboard in Resources */,
76EAA86C1E93F2CC009A41DA /* Assets.xcassets in Resources */, 76EAA86C1E93F2CC009A41DA /* Assets.xcassets in Resources */,
76EAA86A1E93F2CC009A41DA /* Main.storyboard in Resources */, 76EAA86A1E93F2CC009A41DA /* Main.storyboard in Resources */,
C33E4D96204442AC00142EE6 /* CHANGELOG.md in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/> <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
@@ -37,10 +37,11 @@
<constraint firstItem="LI4-fC-2Ry" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="wVV-oT-zRH"/> <constraint firstItem="LI4-fC-2Ry" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="wVV-oT-zRH"/>
</constraints> </constraints>
</view> </view>
<navigationItem key="navigationItem" id="0ga-4U-IeA"/>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="136.80000000000001" y="138.98050974512745"/> <point key="canvasLocation" x="815.20000000000005" y="138.98050974512745"/>
</scene> </scene>
</scenes> </scenes>
</document> </document>
@@ -14,14 +14,8 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib
} }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Action // MARK: - Action
/// Handle button click & show the controller with licences /// Handle button click & show the controller with licences
@@ -52,7 +46,7 @@ class ViewController: UIViewController {
openSourceVC.presentOpenSourceController(from: self) openSourceVC.presentOpenSourceController(from: self)
} }
// Customization // MARK: - Customization
fileprivate func controllerCustomUI(openSourceVC: OpenSourceController) { fileprivate func controllerCustomUI(openSourceVC: OpenSourceController) {
// Navigation bar title // Navigation bar title
Binary file not shown.
+4 -4
View File
@@ -1,12 +1,12 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'OpenSourceController' s.name = 'OpenSourceController'
s.version = '2.0.1' s.version = '2.1.2'
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/floriangbh/OpenSourceController'
s.license = { :type => 'MIT', :file => 'LICENSE' } s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Florian Gabach' => 'contact@floriangabach.fr' } s.author = { 'Florian Gabach' => 'florian.gabach@gmail.com' }
s.source = { :git => 'https://github.com/terflogag/OpenSourceController.git', :tag => s.version.to_s } s.source = { :git => 'https://github.com/floriangbh/OpenSourceController.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0' s.ios.deployment_target = '9.0'
s.source_files = 'Sources/**/*' s.source_files = 'Sources/**/*'
end end
+3 -8
View File
@@ -81,6 +81,9 @@ url: "https://raw.githubusercontent.com/jessesquires/JSQMessagesViewController/d
// Present controller // Present controller
openSourceVC.presentOpenSourceController(from: self) openSourceVC.presentOpenSourceController(from: self)
// OR push the controller if the source controller is embeded in navigation controller
openSourceVC.pushOpenSourceController(from: self)
``` ```
## Customisation ## Customisation
@@ -121,14 +124,6 @@ OpenSourceController is currently write in english. If you need translation for
"Unable to load this licence." = "<your_translation>"; "Unable to load this licence." = "<your_translation>";
``` ```
## Applications
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)
What about yours ? If your application also use this library, feel free to contact me or make pull request on the README 😁
## Author ## Author
Florian Gabach, florian.gabach@gmail.com Florian Gabach, florian.gabach@gmail.com
@@ -33,4 +33,26 @@ public class OpenSourceController: NSObject {
// Present controller // Present controller
from.present(navController, animated: true) from.present(navController, animated: true)
} }
/// Push OpenSourceViewController from navigation controller
///
/// - Parameter from: the source controller
open func pushOpenSourceController(from: UIViewController) {
// Create open source controller
let licenceController = OpenSourceViewController()
licenceController.showCloseButton = false // Don't show close button
// Init licence
licenceController.licences = self.licences
// Init config
licenceController.config = self.config
// Push controller
guard let navigationController = from.navigationController else {
print("Source controller isn't embeded in navigation controller. Can't push.")
return
}
navigationController.pushViewController(licenceController, animated: true)
}
} }
@@ -29,9 +29,12 @@ class OpenSourceViewController: UITableViewController {
/// Contains all licence object before downloaded /// Contains all licence object before downloaded
internal var licences: [LicenceFile]? internal var licences: [LicenceFile]?
// Controller configuration for customization /// Controller configuration for customization
internal var config = OpenSourceControllerConfig() internal var config = OpenSourceControllerConfig()
/// Do we need to show the close button ? (disable if push the controller)
internal var showCloseButton: Bool = true
/// Contains all licences object after downloaded /// Contains all licences object after downloaded
fileprivate var downloadedLicence: [LicenceFile]? { fileprivate var downloadedLicence: [LicenceFile]? {
didSet { didSet {
@@ -58,7 +61,11 @@ class OpenSourceViewController: UITableViewController {
fileprivate func prepare() { fileprivate func prepare() {
self.prepareTableView() self.prepareTableView()
self.prepareActivityIndicator() self.prepareActivityIndicator()
self.prepareCloseButton()
if showCloseButton {
self.prepareCloseButton()
}
self.prepareStyle() self.prepareStyle()
self.prepareLicences() self.prepareLicences()
} }
@@ -7,7 +7,6 @@
import Foundation import Foundation
extension Array { extension Array {
/// Get an index safely /// Get an index safely
func get(at index: Int) -> Element? { func get(at index: Int) -> Element? {
guard index >= 0 guard index >= 0
+9 -11
View File
@@ -16,22 +16,20 @@ class LicenceDownloader: NSObject {
class func downloadLicences(licences: [LicenceFile], class func downloadLicences(licences: [LicenceFile],
config: OpenSourceControllerConfig, config: OpenSourceControllerConfig,
completion: @escaping () -> Void) { completion: @escaping () -> Void) {
// Number of licences let licenceGroupe = DispatchGroup()
let licenceCount = licences.count
// Already licence downloaded
var alreadyDownloaded = 0
// Download licence's detail for every lience // Download licence's detail for every lience
for licence in licences { for licence in licences {
licenceGroupe.enter()
licence.downloadLicenceDetail(config: config, completion: { () in licence.downloadLicenceDetail(config: config, completion: { () in
alreadyDownloaded += 1 licenceGroupe.leave()
// If this is the last licence, perfom completion
if licenceCount == alreadyDownloaded {
completion()
}
}) })
} }
// When everything is downloaded
licenceGroupe.notify(queue: .main) {
completion()
}
} }
} }
@@ -22,14 +22,6 @@ class OpenSourceTableViewCell: UITableViewCell {
super.init(coder: aDecoder) super.init(coder: aDecoder)
} }
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
override func layoutSubviews() {
super.layoutSubviews()
}
// MARK: - Prepare // MARK: - Prepare
func prepareCellComponent() { func prepareCellComponent() {