Compare commits

...
4 Commits
Author SHA1 Message Date
Florian Gabach b93d2f0d2a Bump to 2.0.1 2017-12-08 12:20:41 +01:00
Florian Gabach 2127942e5f Bump build system 2017-12-07 17:42:05 +01:00
Florian Gabach fd1107d42e Update README.md 2017-12-07 10:41:04 +01:00
Florian Gabach 1487636084 Update README.md 2017-11-22 21:09:29 +01:00
13 changed files with 158 additions and 64 deletions
+4
View File
@@ -1,6 +1,10 @@
Changelog Changelog
========== ==========
### 2.0.1
- Clean code and move loader position
### 2.0 ### 2.0
- Swift 4 version - Swift 4 version
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Latest</string>
</dict>
</plist>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildLocationStyle</key>
<string>UseAppPreferences</string>
<key>CustomBuildLocationType</key>
<string>RelativeToDerivedData</string>
<key>DerivedDataLocationStyle</key>
<string>Default</string>
<key>EnabledFullIndexStoreVisibility</key>
<false/>
<key>IssueFilterStyle</key>
<string>ShowActiveSchemeOnly</string>
<key>LiveSourceIssuesEnabled</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>OpenSourceControllerDemo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
@@ -103,8 +103,9 @@
"scale" : "2x" "scale" : "2x"
}, },
{ {
"idiom" : "ios-marketing",
"size" : "1024x1024", "size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "logo 7-3.png",
"scale" : "1x" "scale" : "1x"
} }
], ],
Binary file not shown.

After

Width:  |  Height:  |  Size: 287 KiB

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Latest</string>
</dict>
</plist>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildLocationStyle</key>
<string>UseAppPreferences</string>
<key>CustomBuildLocationType</key>
<string>RelativeToDerivedData</string>
<key>DerivedDataLocationStyle</key>
<string>Default</string>
<key>EnabledFullIndexStoreVisibility</key>
<false/>
<key>IssueFilterStyle</key>
<string>ShowActiveSchemeOnly</string>
<key>LiveSourceIssuesEnabled</key>
<true/>
</dict>
</plist>
+3 -3
View File
@@ -54,9 +54,9 @@ pod "OpenSourceController", '~> 1.0.8' # Swift 3.1 version
- To integrate OpenSourceController into your Xcode project using [Carthage](https://github.com/Carthage/Carthage), specify it in your Cartfile : - To integrate OpenSourceController into your Xcode project using [Carthage](https://github.com/Carthage/Carthage), specify it in your Cartfile :
```ruby ```ruby
github "terflogag/OpenSourceController" ~> 2.0 github "floriangbh/OpenSourceController" ~> 2.0
github "terflogag/OpenSourceController" ~> 1.0.8 # Swift 3.1 version github "floriangbh/OpenSourceController" ~> 1.0.8 # Swift 3.1 version
``` ```
## Usage ## Usage
@@ -131,7 +131,7 @@ What about yours ? If your application also use this library, feel free to cont
## Author ## Author
Florian Gabach, contact@floriangabach.fr Florian Gabach, florian.gabach@gmail.com
## License ## License
@@ -11,7 +11,17 @@ class OpenSourceViewController: UITableViewController {
// MARK: - Var // MARK: - Var
/// Loading indicator /// Loading indicator
fileprivate var indicator = UIActivityIndicatorView() fileprivate lazy var indicator: UIActivityIndicatorView = {
let indicator = UIActivityIndicatorView(frame:CGRect(x: 0,
y: 0,
width: 40,
height: 40) )
indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
indicator.hidesWhenStopped = true
indicator.backgroundColor = UIColor.clear
indicator.color = UIColor.black
return indicator
}()
/// TableViewCell identifier /// TableViewCell identifier
private let reuseIdentifier = "openSourceCell" private let reuseIdentifier = "openSourceCell"
@@ -38,28 +48,36 @@ class OpenSourceViewController: UITableViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Prepare tableview // Prepare controller
self.prepareTableView() self.prepare()
// Download licences
self.prepareLicences()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
} }
// MARK: - Prepare // MARK: - Prepare
/// Prepare controller
fileprivate func prepare() {
self.prepareTableView()
self.prepareActivityIndicator()
self.prepareCloseButton()
self.prepareStyle()
self.prepareLicences()
}
/// Download licences /// Download licences
fileprivate func prepareLicences() { fileprivate func prepareLicences() {
if let licences = self.licences { self.startLoading()
self.startLoading()
LicenceDownloader.downloadLicences(licences: licences, // Retrieve licence
config: self.config) { () in guard let licences = self.licences else {
// Update licences print("No licences found.")
self.downloadedLicence = self.licences return
} }
// Download licence
LicenceDownloader.downloadLicences(licences: licences,
config: self.config) { () in
// Update licences
self.downloadedLicence = self.licences
} }
} }
@@ -74,44 +92,49 @@ class OpenSourceViewController: UITableViewController {
self.tableView.dataSource = self self.tableView.dataSource = self
self.tableView.delegate = self self.tableView.delegate = self
self.tableView.separatorStyle = .singleLine self.tableView.separatorStyle = .singleLine
// Apply background color from configuration if needed
if let backgroundColor = self.config.uiConfig.backgroundColor { if let backgroundColor = self.config.uiConfig.backgroundColor {
self.tableView.backgroundColor = backgroundColor self.tableView.backgroundColor = backgroundColor
} }
}
// Navigation bar /// Prepare controller style
fileprivate func prepareStyle() {
// Apply navigation bar tint color if needed
if let tintColor = self.config.uiConfig.barTintColor { if let tintColor = self.config.uiConfig.barTintColor {
self.navigationController?.navigationBar.barTintColor = tintColor self.navigationController?.navigationBar.barTintColor = tintColor
} }
// Applu navigation bar text color if needed
if let textColor = self.config.uiConfig.titleColor { if let textColor = self.config.uiConfig.titleColor {
let attribut = [NSAttributedStringKey.foregroundColor: textColor] let attribut = [NSAttributedStringKey.foregroundColor: textColor]
self.navigationController?.navigationBar.titleTextAttributes = attribut self.navigationController?.navigationBar.titleTextAttributes = attribut
} }
}
/// Prepare close button on navigation bar
fileprivate func prepareCloseButton() {
// 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 = config.uiConfig.closeButtonColor ?? UIColor.black closeButton.tintColor = config.uiConfig.closeButtonColor ?? UIColor.black
self.navigationItem.rightBarButtonItem = closeButton self.navigationItem.rightBarButtonItem = closeButton
// Loading indicator
self.prepareActivityIndicator()
} }
// MARK: - Loading indicator // MARK: - Loading indicator
/// Prepare UIActivityIndicatorView and display it at the center of the view /// Prepare UIActivityIndicatorView and display it at the center of the view
fileprivate func prepareActivityIndicator() { fileprivate func prepareActivityIndicator() {
self.indicator = UIActivityIndicatorView(frame:CGRect(x: 0, // Add to view
y: 0,
width: 40,
height: 40) )
self.indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray
self.indicator.center = self.view.center
self.indicator.hidesWhenStopped = true
self.indicator.backgroundColor = UIColor.clear
self.indicator.color = UIColor.black
self.view.addSubview(indicator) self.view.addSubview(indicator)
// Apply constraint
self.indicator.translatesAutoresizingMaskIntoConstraints = false
self.indicator.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
let topConstraint = self.navigationController?.navigationBar.frame.size.height ?? 0.0
self.indicator.bottomAnchor.constraint(equalTo: view.topAnchor, constant: topConstraint).isActive=true
} }
/// Start loading : start the loader animation /// Start loading : start the loader animation
@@ -33,7 +33,7 @@ public struct OpenSourceControllerConfig {
/// Will be applied to the navigation bar title /// Will be applied to the navigation bar title
public var title: String = "Tiers library" public var title: String = "Tiers library"
// Verbose mode for print log when licence are downloaded /// Verbose mode for print log when licence are downloaded
public var verbose: Bool = false public var verbose: Bool = false
/// UI-specific configuration. /// UI-specific configuration.