Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please check this out. #345

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Spring/AsyncButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ import UIKit

public class AsyncButton: UIButton {

private var imageURL = [UInt:NSURL]()
private var placeholderImage = [UInt:UIImage]()
private var imageURL = [UInt: NSURL]()
private var placeholderImage = [UInt: UIImage]()


public func setImageURL(url: NSURL?, placeholderImage placeholder:UIImage?, forState state:UIControl.State) {
public func setImageURL(url: NSURL?, placeholderImage placeholder: UIImage?, forState state: UIControl.State) {

imageURL[state.rawValue] = url
placeholderImage[state.rawValue] = placeholder
Expand All @@ -47,5 +46,4 @@ public class AsyncButton: UIButton {
}
}
}

}
5 changes: 2 additions & 3 deletions Spring/AsyncImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import UIKit

public class AsyncImageView: UIImageView {

public var placeholderImage : UIImage?

public var url : NSURL? {
public var placeholderImage: UIImage?
public var url: NSURL? {
didSet {
self.image = placeholderImage
if let urlString = url?.absoluteString {
Expand Down
5 changes: 3 additions & 2 deletions Spring/AutoTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import UIKit

public class AutoTextView: UITextView {


private let edgeInset: CGFloat = 4
public override var intrinsicContentSize: CGSize {
get {
var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude))
Expand All @@ -18,7 +19,7 @@ public class AutoTextView: UITextView {
size.height = 0
}

contentInset = UIEdgeInsets(top: -4, left: -4, bottom: -4, right: -4)
contentInset = UIEdgeInsets(top: -edgeInset, left: -edgeInset, bottom: -edgeInset, right: -edgeInset)
layoutIfNeeded()

return size
Expand Down
2 changes: 1 addition & 1 deletion Spring/BlurView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import UIKit

public func insertBlurView (view: UIView, style: UIBlurEffect.Style) -> UIVisualEffectView {
view.backgroundColor = UIColor.clear
view.backgroundColor = .clear

let blurEffect = UIBlurEffect(style: style)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
Expand Down
8 changes: 4 additions & 4 deletions Spring/DesignableButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import UIKit

@IBDesignable public class DesignableButton: SpringButton {

@IBInspectable public var borderColor: UIColor = UIColor.clear {
@IBInspectable public var borderColor: UIColor = .clear {
didSet {
layer.borderColor = borderColor.cgColor
}
Expand All @@ -42,7 +42,7 @@ import UIKit
}
}

@IBInspectable public var shadowColor: UIColor = UIColor.clear {
@IBInspectable public var shadowColor: UIColor = .clear {
didSet {
layer.shadowColor = shadowColor.cgColor
}
Expand All @@ -65,5 +65,5 @@ import UIKit
layer.shadowOffset.height = shadowOffsetY
}
}

}
4 changes: 2 additions & 2 deletions Spring/DesignableImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UIKit

@IBDesignable public class DesignableImageView: SpringImageView {

@IBInspectable public var borderColor: UIColor = UIColor.clear {
@IBInspectable public var borderColor: UIColor = .clear {
didSet {
layer.borderColor = borderColor.cgColor
}
Expand All @@ -41,5 +41,5 @@ import UIKit
layer.cornerRadius = cornerRadius
}
}

}
4 changes: 2 additions & 2 deletions Spring/DesignableLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import UIKit

@IBDesignable public class DesignableLabel: SpringLabel {

@IBInspectable public var lineHeight: CGFloat = 1.5 {
didSet {
let font = UIFont(name: self.font.fontName, size: self.font.pointSize)
Expand All @@ -39,5 +39,5 @@ import UIKit
self.attributedText = attributedString
}
}

}
16 changes: 8 additions & 8 deletions Spring/DesignableTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import UIKit

@IBDesignable class DesignableTabBarController: UITabBarController {

@IBInspectable var normalTint: UIColor = UIColor.clear {
@IBInspectable var normalTint: UIColor = .clear {
didSet {
UITabBar.appearance().tintColor = normalTint
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: normalTint], for: UIControl.State())
}
}

@IBInspectable var selectedTint: UIColor = UIColor.clear {
@IBInspectable var selectedTint: UIColor = .clear {
didSet {
UITabBar.appearance().tintColor = selectedTint
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: selectedTint], for:UIControl.State.selected)
Expand All @@ -47,16 +47,16 @@ import UIKit
@IBInspectable var firstSelectedImage: UIImage? {
didSet {
if let image = firstSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[0].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
let tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?.first?.selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
}

@IBInspectable var secondSelectedImage: UIImage? {
didSet {
if let image = secondSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]?
let tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[1].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -65,7 +65,7 @@ import UIKit
@IBInspectable var thirdSelectedImage: UIImage? {
didSet {
if let image = thirdSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]?
let tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[2].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -74,7 +74,7 @@ import UIKit
@IBInspectable var fourthSelectedImage: UIImage? {
didSet {
if let image = fourthSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]?
let tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[3].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand All @@ -83,7 +83,7 @@ import UIKit
@IBInspectable var fifthSelectedImage: UIImage? {
didSet {
if let image = fifthSelectedImage {
var tabBarItems = self.tabBar.items as [UITabBarItem]?
let tabBarItems = self.tabBar.items as [UITabBarItem]?
tabBarItems?[4].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Spring/DesignableTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UIKit

@IBDesignable public class DesignableTextField: SpringTextField {

@IBInspectable public var placeholderColor: UIColor = UIColor.clear {
@IBInspectable public var placeholderColor: UIColor = .clear {
didSet {
guard let placeholder = placeholder else { return }
attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor: placeholderColor])
Expand Down Expand Up @@ -63,7 +63,7 @@ import UIKit
}
}

@IBInspectable public var borderColor: UIColor = UIColor.clear {
@IBInspectable public var borderColor: UIColor = .clear {
didSet {
layer.borderColor = borderColor.cgColor
}
Expand All @@ -80,7 +80,7 @@ import UIKit
layer.cornerRadius = cornerRadius
}
}

@IBInspectable public var lineHeight: CGFloat = 1.5 {
didSet {
let font = UIFont(name: self.font!.fontName, size: self.font!.pointSize)
Expand Down
2 changes: 1 addition & 1 deletion Spring/DesignableTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UIKit

@IBDesignable public class DesignableTextView: SpringTextView {

@IBInspectable public var borderColor: UIColor = UIColor.clear {
@IBInspectable public var borderColor: UIColor = .clear {
didSet {
layer.borderColor = borderColor.cgColor
}
Expand Down
4 changes: 2 additions & 2 deletions Spring/DesignableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import UIKit

@IBDesignable public class DesignableView: SpringView {

@IBInspectable public var borderColor: UIColor = UIColor.clear {
@IBInspectable public var borderColor: UIColor = .clear {
didSet {
layer.borderColor = borderColor.cgColor
}
Expand All @@ -42,7 +42,7 @@ import UIKit
}
}

@IBInspectable public var shadowColor: UIColor = UIColor.clear {
@IBInspectable public var shadowColor: UIColor = .clear {
didSet {
layer.shadowColor = shadowColor.cgColor
}
Expand Down
6 changes: 2 additions & 4 deletions Spring/ImageLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
// SOFTWARE.

import UIKit
import Foundation


public class ImageLoader {

var cache = NSCache<NSString, NSData>()

public class var sharedLoader : ImageLoader {
public class var sharedLoader: ImageLoader {
struct Static {
static let instance : ImageLoader = ImageLoader()
static let instance: ImageLoader = ImageLoader()
}
return Static.instance
}
Expand Down
11 changes: 5 additions & 6 deletions Spring/KeyboardLayoutConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import UIKit
@available(tvOS, unavailable)
public class KeyboardLayoutConstraint: NSLayoutConstraint {

private var offset : CGFloat = 0
private var keyboardVisibleHeight : CGFloat = 0
private var offset: CGFloat = 0
private var keyboardVisibleHeight: CGFloat = 0

@available(tvOS, unavailable)
override public func awakeFromNib() {
Expand Down Expand Up @@ -66,14 +66,12 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
UIApplication.shared.keyWindow?.layoutIfNeeded()
return
}, completion: { finished in
})
})
default:

break
}

}

}

@objc func keyboardWillHideNotification(_ notification: NSNotification) {
Expand All @@ -95,7 +93,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
UIApplication.shared.keyWindow?.layoutIfNeeded()
return
}, completion: { finished in
})
})
default:
break
}
Expand All @@ -107,4 +105,5 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint {
}

}

#endif
31 changes: 15 additions & 16 deletions Spring/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import UIKit
#if !os(tvOS)
@available(tvOS, unavailable)
public class LoadingView: UIView {

@IBOutlet public weak var indicatorView: SpringView!

override public func awakeFromNib() {
let animation = CABasicAnimation()
animation.keyPath = "transform.rotation.z"
Expand All @@ -37,42 +37,41 @@ public class LoadingView: UIView {
animation.repeatCount = HUGE
indicatorView.layer.add(animation, forKey: "")
}

class func designCodeLoadingView() -> UIView {

return Bundle(for: self).loadNibNamed("LoadingView", owner: self, options: nil)![0] as! UIView
return Bundle(for: self).loadNibNamed("LoadingView", owner: self, options: nil)!.first as! UIView
}
}

public extension UIView {

struct LoadingViewConstants {
static let Tag = 1000
}

public func showLoading() {

func showLoading() {
if self.viewWithTag(LoadingViewConstants.Tag) != nil {
// If loading view is already found in current view hierachy, do nothing
return
}

let loadingXibView = LoadingView.designCodeLoadingView()
loadingXibView.frame = self.bounds
loadingXibView.tag = LoadingViewConstants.Tag
self.addSubview(loadingXibView)

loadingXibView.alpha = 0
SpringAnimation.spring(duration: 0.7, animations: {
loadingXibView.alpha = 1
})
}

public func hideLoading() {

func hideLoading() {
if let loadingXibView = self.viewWithTag(LoadingViewConstants.Tag) {
loadingXibView.alpha = 1

SpringAnimation.springWithCompletion(duration: 0.7, animations: {
loadingXibView.alpha = 0
loadingXibView.transform = CGAffineTransform(scaleX: 3, y: 3)
Expand All @@ -81,6 +80,6 @@ public extension UIView {
})
}
}

}

#endif
Loading