Update podspec only Source

This commit is contained in:
mrustaa committed 2021-11-16 15:03:18 +03:00
1 parent 3c2848ffd1
commit f2e8d4411f
159 files changed
+2 -12319

No files matched your search

@@ -1,134 +0,0 @@
import UIKit
@IBDesignable
class DesignButton: UIButton {
@IBInspectable var hideAnimation: Bool = true
@IBInspectable var fillColor: UIColor = .clear
@IBInspectable var gradientColor: UIColor?
@IBInspectable var gradientOffset: CGPoint = CGPoint(x: 0, y: 1)
@IBInspectable var cornerRadius: CGFloat = 0.0
@IBInspectable var shadowColor: UIColor = .clear
@IBInspectable var shadowOffset: CGSize = CGSize.zero
@IBInspectable var shadowRadius: CGFloat = 0.0
@IBInspectable var shadowOpacity: CGFloat = 0.0
@IBInspectable var borderColor: UIColor = .clear
@IBInspectable var borderWidth: CGFloat = 0.0
override func draw(_ rect: CGRect) {
if let gradientColor = gradientColor {
let glayer = CAGradientLayer()
glayer.frame = bounds
glayer.colors = [fillColor.cgColor, gradientColor.cgColor]
glayer.startPoint = CGPoint.zero
glayer.endPoint = gradientOffset
glayer.cornerRadius = radius()
layer.insertSublayer(glayer, at: 0)
} else {
layer.backgroundColor = fillColor.cgColor
}
layer.cornerRadius = radius()
layer.shadowOffset = shadowOffset
layer.shadowOpacity = Float(shadowOpacity / 10.0)
layer.shadowRadius = shadowRadius
layer.shadowColor = shadowColor.cgColor
layer.borderColor = borderColor.cgColor
layer.borderWidth = borderWidth
}
override var isSelected: Bool {
didSet {
super.isSelected = isSelected
}
}
override var isHighlighted: Bool {
didSet {
// super.isHighlighted = isHighlighted
}
}
override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
selectedLayer(show: true)
return super.beginTracking(touch, with: event)
}
override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
let point = touch.location(in: self)
let someFrame = bounds
let highlighted = someFrame.contains(point)
selectedLayer(show: highlighted)
return super.continueTracking(touch, with: event)
}
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
selectedLayer(show: false)
super.endTracking(touch, with: event)
}
override func cancelTracking(with event: UIEvent?) {
selectedLayer(show: false)
super.cancelTracking(with: event)
}
func radius() -> CGFloat {
let minSize = min(frame.size.width, frame.size.height)
let radius = ((cornerRadius < 0) ? (minSize / 2) : cornerRadius)
return radius
}
func selectedLayer(show: Bool) {
func selectAnimationHide(show: Bool) {
if show {
alpha = 0.5
} else {
UIView.animate(withDuration: 0.35, animations: {
self.alpha = 1
})
}
}
func selectAnimationShadow(show: Bool) {
let tag = 1
let view = viewWithTag(tag)
if show {
if view == nil {
let view = UIView(frame: bounds)
view.backgroundColor = UIColor.init(white: 0.0, alpha: 0.2)
view.tag = tag
view.layer.cornerRadius = radius()
addSubview(view)
}
} else {
if let view = view {
UIView.animate(withDuration: 0.35, animations: {
view.alpha = 0
}) { (fin: Bool) in
view.removeFromSuperview()
}
}
}
}
if hideAnimation {
selectAnimationHide(show: show)
} else {
selectAnimationShadow(show: show)
}
}
}
@@ -1,73 +0,0 @@
import UIKit
@IBDesignable
class DesignView: UIView {
@IBInspectable var fillColor: UIColor = .clear
//MARK: - Gradient
@IBInspectable var gradientColor: UIColor?
@IBInspectable var gradientColor2: UIColor?
@IBInspectable var gradientColor3: UIColor?
@IBInspectable var gradientStartPoint: CGPoint = CGPoint.zero
@IBInspectable var gradientOffset: CGPoint = CGPoint(x: 0, y: 1)
//MARK: - Shadow
@IBInspectable var shadowColor: UIColor = .clear
@IBInspectable var shadowOffset: CGSize = CGSize.zero
@IBInspectable var shadowRadius: CGFloat = 0.0
@IBInspectable var shadowOpacity: CGFloat = 0.0
//MARK: - Radius
@IBInspectable var cornerRadius: CGFloat = 0.0
//MARK: - Border
@IBInspectable var borderColor: UIColor = .clear
@IBInspectable var borderWidth: CGFloat = 0.0
override func draw(_ rect: CGRect) {
if let gradientColor = gradientColor {
var colors: [CGColor] = []
colors.append(fillColor.cgColor)
colors.append(gradientColor.cgColor)
if let gradientColor2 = gradientColor2 { colors.append(gradientColor2.cgColor) }
if let gradientColor3 = gradientColor3 { colors.append(gradientColor3.cgColor) }
let glayer = CAGradientLayer()
glayer.frame = bounds
glayer.colors = colors
glayer.startPoint = gradientStartPoint
glayer.endPoint = gradientOffset
glayer.cornerRadius = radius()
layer.insertSublayer(glayer, at: 0)
} else {
layer.backgroundColor = fillColor.cgColor
}
layer.cornerRadius = radius()
layer.shadowOffset = shadowOffset
layer.shadowOpacity = Float(shadowOpacity / 10.0)
layer.shadowRadius = shadowRadius
layer.shadowColor = shadowColor.cgColor
layer.borderColor = borderColor.cgColor
layer.borderWidth = borderWidth
}
func radius() -> CGFloat {
let minSize = min(width, height)
let radius = ((cornerRadius < 0) ? (minSize / 2) : cornerRadius)
return radius
}
}
@@ -1,31 +0,0 @@
//
// StoryboardController.swift
// PatternsSwift
//
// Created by mrustaa on 20/04/2020.
// Copyright © 2020 mrustaa. All rights reserved.
//
import UIKit
@IBDesignable
class StoryboardController: UIViewController {
class func instantiate() -> UIViewController {
return fromStoryboardController()
}
class func fromStoryboardController() -> UIViewController {
let className = String(describing: self)
let storyboard = UIStoryboard.init(name: className, bundle: nil)
// if let initialViewController = storyboard.instantiateInitialViewController() {
// return initialViewController
// } else {
// fatalError("Can't initialize view controller \(self)")
// }
return storyboard.instantiateViewController(withIdentifier: className)
}
}
@@ -1,99 +0,0 @@
//
// XibView.swift
// PatternsSwift
//
// Created by mrustaa on 19/04/2020.
// Copyright © 2020 mrustaa. All rights reserved.
//
import UIKit
class XibView: UIView {
// MARK: - Properties
public weak var contentView: UIView?
// MARK: - Initialize
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
contentView = fromNib()
loadedFromNib()
}
public init() {
super.init(frame: CGRect.zero)
contentView = fromNib()
frame = contentView?.frame ?? frame
loadedFromNib()
}
// MARK: - Postflight
open func loadedFromNib() {
}
// MARK: - Load Nib
func fromNibWithoutConstraints() -> UIView? {
guard let contentView = Bundle(for: type(of: self)).loadNibNamed(String(describing: type(of: self)), owner: self, options: nil)?.first as? UIView else {
return nil
}
contentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentView)
return contentView
}
func fromNib() -> UIView? {
guard let contentView = fromNibWithoutConstraints() else { return nil }
let bottomConstraint = NSLayoutConstraint(
item: contentView,
attribute: NSLayoutConstraint.Attribute.bottom,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: self,
attribute: NSLayoutConstraint.Attribute.bottom,
multiplier: 1,
constant: 0
)
let trailingConstraint = NSLayoutConstraint(
item: contentView,
attribute: NSLayoutConstraint.Attribute.trailing,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: self,
attribute: NSLayoutConstraint.Attribute.trailing,
multiplier: 1,
constant: 0
)
let topConstraint = NSLayoutConstraint(
item: contentView,
attribute: NSLayoutConstraint.Attribute.top,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: self,
attribute: NSLayoutConstraint.Attribute.top,
multiplier: 1,
constant: 0
)
let leadingConstraint = NSLayoutConstraint(
item: contentView,
attribute: NSLayoutConstraint.Attribute.leading,
relatedBy: NSLayoutConstraint.Relation.equal,
toItem: self,
attribute: NSLayoutConstraint.Attribute.leading,
multiplier: 1,
constant: 0
)
addConstraints([bottomConstraint, trailingConstraint, topConstraint, leadingConstraint])
return contentView
}
}
@@ -1,59 +0,0 @@
import UIKit
extension UIColor {
var redValue: CGFloat{ return CIColor(color: self).red }
var greenValue: CGFloat{ return CIColor(color: self).green }
var blueValue: CGFloat{ return CIColor(color: self).blue }
var alphaValue: CGFloat{ return CIColor(color: self).alpha }
}
class Colors {
class func rgba( _ red: CGFloat, _ green: CGFloat, _ blue: CGFloat, _ alpha: CGFloat) -> UIColor {
return UIColor(red: red / 255, green: green / 255, blue: blue / 255, alpha: alpha)
}
class func rgb( _ red: CGFloat, _ green: CGFloat, _ blue: CGFloat) -> UIColor {
return rgba(red, green, blue, 1)
}
class func grayLevel(_ gray: CGFloat) -> UIColor {
return rgb(gray * 255, gray * 255, gray * 255)
}
class func blackAlpha(_ alpha: CGFloat) -> UIColor {
return rgba(0, 0, 0, alpha)
}
// MARK: - Properties
static public let lightGray = blackAlpha(0.1)
static public let slightlyDark = blackAlpha(0.3)
static public let halfBlack = blackAlpha(0.5)
static public let black = grayLevel(0) // 0 %
static public let gray = grayLevel(127) // 49 %
static public let lightInactiveGray = grayLevel(178) // 69 %
static public let silver = grayLevel(229) // 89 %
static public let inactiveGray = grayLevel(246) // 96 %
static public let white = grayLevel(255) // 100 %
static public let transparentGray = rgba(225, 225, 225, 0.3)
static public let lightOrange = rgba(255, 105, 0, 0.1)
static public let red = rgb(255, 59, 48)
static public let blue = rgb(44, 174, 233)
static public let yellow = rgb(254, 219, 6)
static public let orange = rgb(255, 105, 0)
static public let purple = rgb(128, 0, 128)
static public let gold = rgb(226, 201, 127)
static public let beige = rgb(245, 245, 220)
static public let brand = rgb(255, 105, 0)
static public let approveGreen = rgb(49, 183, 0)
static public let darkBlue = rgb(74, 144, 226)
static public let semidarkBlue = rgb(0, 107, 202)
static public let darkGray = rgb(142, 142, 147)
static public let lightYellow = rgb(254, 229, 6)
}
@@ -1,193 +0,0 @@
//
// UIView+Positioning.swift
//
// Created by Shai Mishali on 1/19/15.
// Copyright (c) 2015 Shai Mishali. All rights reserved.
//
import UIKit
public extension UIView {
// MARK: - Basic Properties
/// X Axis value of UIView.
var x: CGFloat {
set { self.frame = CGRect(x: _pixelIntegral(newValue),
y: self.y,
width: self.width,
height: self.height)
}
get { return self.frame.origin.x }
}
/// Y Axis value of UIView.
var y: CGFloat {
set { self.frame = CGRect(x: self.x,
y: _pixelIntegral(newValue),
width: self.width,
height: self.height)
}
get { return self.frame.origin.y }
}
/// Width of view.
var width: CGFloat {
set { self.frame = CGRect(x: self.x,
y: self.y,
width: _pixelIntegral(newValue),
height: self.height)
}
get { return self.frame.size.width }
}
/// Height of view.
var height: CGFloat {
set { self.frame = CGRect(x: self.x,
y: self.y,
width: self.width,
height: _pixelIntegral(newValue))
}
get { return self.frame.size.height }
}
// MARK: - Origin and Size
/// View's Origin point.
var origin: CGPoint {
set { self.frame = CGRect(x: _pixelIntegral(newValue.x),
y: _pixelIntegral(newValue.y),
width: self.width,
height: self.height)
}
get { return self.frame.origin }
}
/// View's size.
var size: CGSize {
set { self.frame = CGRect(x: self.x,
y: self.y,
width: _pixelIntegral(newValue.width),
height: _pixelIntegral(newValue.height))
}
get { return self.frame.size }
}
// MARK: - Extra Properties
/// View's right side (x + width).
var right: CGFloat {
set { self.x = newValue - self.width }
get { return self.x + self.width }
}
/// View's bottom (y + height).
var bottom: CGFloat {
set { self.y = newValue - self.height }
get { return self.y + self.height }
}
/// View's top (y).
var top: CGFloat {
set { self.y = newValue }
get { return self.y }
}
/// View's left side (x).
var left: CGFloat {
set { self.x = newValue }
get { return self.x }
}
/// View's center X value (center.x).
var centerX: CGFloat {
set { self.center = CGPoint(x: newValue, y: self.centerY) }
get { return self.center.x }
}
/// View's center Y value (center.y).
var centerY: CGFloat {
set { self.center = CGPoint(x: self.centerX, y: newValue) }
get { return self.center.y }
}
/// Last subview on X Axis.
var lastSubviewOnX: UIView? {
return self.subviews.reduce(UIView(frame: .zero)) {
return $1.x > $0.x ? $1 : $0
}
}
/// Last subview on Y Axis.
var lastSubviewOnY: UIView? {
return self.subviews.reduce(UIView(frame: .zero)) {
return $1.y > $0.y ? $1 : $0
}
}
// MARK: - Bounds Methods
/// X value of bounds (bounds.origin.x).
var boundsX: CGFloat {
set { self.bounds = CGRect(x: _pixelIntegral(newValue),
y: self.boundsY,
width: self.boundsWidth,
height: self.boundsHeight)
}
get { return self.bounds.origin.x }
}
/// Y value of bounds (bounds.origin.y).
var boundsY: CGFloat {
set { self.frame = CGRect(x: self.boundsX,
y: _pixelIntegral(newValue),
width: self.boundsWidth,
height: self.boundsHeight)
}
get { return self.bounds.origin.y }
}
/// Width of bounds (bounds.size.width).
var boundsWidth: CGFloat {
set { self.frame = CGRect(x: self.boundsX,
y: self.boundsY,
width: _pixelIntegral(newValue),
height: self.boundsHeight)
}
get { return self.bounds.size.width }
}
/// Height of bounds (bounds.size.height).
var boundsHeight: CGFloat {
set { self.frame = CGRect(x: self.boundsX,
y: self.boundsY,
width: self.boundsWidth,
height: _pixelIntegral(newValue))
}
get { return self.bounds.size.height }
}
// MARK: - Useful Methods
/// Center view to it's parent view.
// func centerToParent() {
// guard let superview = self.superview else { return }
//
// switch UIApplication.shared.statusBarOrientation {
// case .landscapeLeft, .landscapeRight:
// self.origin = CGPoint(x: (superview.height / 2) - (self.width / 2),
// y: (superview.width / 2) - (self.height / 2))
// case .portrait, .portraitUpsideDown:
// self.origin = CGPoint(x: (superview.width / 2) - (self.width / 2),
// y: (superview.height / 2) - (self.height / 2))
// case .unknown:
// return
// }
// }
// MARK: - Private Methods
fileprivate func _pixelIntegral(_ pointValue: CGFloat) -> CGFloat {
let scale = UIScreen.main.scale
return (round(pointValue * scale) / scale)
}
}