Skip to content

Commit

Permalink
Merge pull request #17 from jinSasaki/refactor
Browse files Browse the repository at this point in the history
Refactor interface
  • Loading branch information
jinSasaki committed Dec 7, 2016
2 parents a3ee702 + 7eefcdb commit acb365c
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 55 deletions.
2 changes: 1 addition & 1 deletion AlertBar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AlertBar"
s.version = "0.2.0"
s.version = "0.3.0"
s.summary = "An easy alert on status bar."
s.homepage = "https://github.com/jinSasaki/AlertBar"
s.screenshots = "https://github.com/jinSasaki/AlertBar/raw/master/etc/demo.gif"
Expand Down
2 changes: 1 addition & 1 deletion Example/AlertBar/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ViewController: UIViewController {
}

@IBAction func tapError(_ sender: AnyObject) {
AlertBar.showError(NSError(domain: "Page not found", code: 404, userInfo: nil), duration: 3)
AlertBar.show(error: NSError(domain: "Page not found", code: 404, userInfo: nil), duration: 3)
}

@IBAction func tapNotice(_ sender: AnyObject) {
Expand Down
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- AlertBar (0.2.0)
- AlertBar (0.3.0)

DEPENDENCIES:
- AlertBar (from `../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
AlertBar: 3e6a111420c95e278e23e6fbe6668469e54c0be3
AlertBar: 1e17f957b65582b7a1610e6bc2eb9c169e9466df

PODFILE CHECKSUM: d0b6cb35dafa29919b756447265020670bcb91c2

COCOAPODS: 1.1.0.rc.2
COCOAPODS: 1.1.1
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/AlertBar.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Target Support Files/AlertBar/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Pod/Classes/AlertBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public enum AlertBarType {
get {
switch self {
case .success:
return AlertBarHelper.UIColorFromRGB(0x4CAF50)
return UIColor(0x4CAF50)
case .error:
return AlertBarHelper.UIColorFromRGB(0xf44336)
return UIColor(0xf44336)
case .notice:
return AlertBarHelper.UIColorFromRGB(0x2196F3)
return UIColor(0x2196F3)
case .warning:
return AlertBarHelper.UIColorFromRGB(0xFFC107)
return UIColor(0xFFC107)
case .info:
return AlertBarHelper.UIColorFromRGB(0x009688)
return UIColor(0x009688)
case .custom(let backgroundColor, _):
return backgroundColor
}
Expand All @@ -39,7 +39,7 @@ public enum AlertBarType {
case .custom(_, let textColor):
return textColor
default:
return AlertBarHelper.UIColorFromRGB(0xFFFFFF)
return UIColor(0xFFFFFF)
}
}
}
Expand Down Expand Up @@ -130,16 +130,16 @@ open class AlertBar: UIView {
})
}

open class func showError(_ error: NSError, duration: Double = 2, completion: (() -> Void)? = nil) {
let code = error.code
open class func show(error: Error, duration: Double = 2, completion: (() -> Void)? = nil) {
let code = (error as NSError).code
let localizedDescription = error.localizedDescription
self.show(.error, message: "(\(code)) " + localizedDescription)
self.show(.error, message: "(\(code)) " + localizedDescription, duration: duration, completion: completion)
}
}

internal class AlertBarHelper {
class func UIColorFromRGB(_ rgbValue: UInt) -> UIColor {
return UIColor(
internal extension UIColor {
convenience init(_ rgbValue: UInt) {
self.init(
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
Expand Down

0 comments on commit acb365c

Please sign in to comment.