Last active
January 28, 2016 16:45
-
-
Save loganwright/5e57e962bc7c50c66e29 to your computer and use it in GitHub Desktop.
Bag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal extension SequenceType { | |
func ip_splitFilter(@noescape filter: (Generator.Element) throws -> Bool) rethrows -> (passed: [Generator.Element], failed: [Generator.Element]) { | |
var passed: [Generator.Element] = [] | |
var failed: [Generator.Element] = [] | |
try forEach { | |
if try filter($0) { | |
passed.append($0) | |
} else { | |
failed.append($0) | |
} | |
} | |
return (passed, failed) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
****************** THIS IS SAVED FOR REASONS UNKNOWN TO YOU IF YOU'VE FOUND IT >> DO NOT USE IT ***************************** | |
// TODO: Make Better -- Super sketch mc_getch right now | |
/** | |
At some point, this will be replaced w/ the 'c' logo. | |
For now, the reason for it serves the purpose of being an | |
easy to use indicator for loading | |
*/ | |
import IP_UIKit_Wisdom | |
final class GlobalLoader: UIView { | |
private let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .WhiteLarge) | |
internal static func show() { | |
let new = GlobalLoader() | |
guard let window = (UIApplication.sharedApplication() | |
.delegate as? AppDelegate)?.window else { fatalError("NO WINDOW") } | |
window.addSubview(new) | |
window.constrainViewToAllEdges(new) | |
} | |
internal static func hide() { | |
guard let window = (UIApplication.sharedApplication() | |
.delegate as? AppDelegate)?.window else { fatalError("NO WINDOW") } | |
window.subviews.filter { $0 is GlobalLoader } .forEach { $0.removeFromSuperview() } | |
} | |
// MARK: Initialization | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
setup() | |
} | |
private convenience init() { | |
self.init(frame: CGRectZero) | |
} | |
private override init(frame: CGRect) { | |
super.init(frame: frame) | |
setup() | |
} | |
required init(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
// MARK: Setup | |
private func setup() { | |
backgroundColor = .cyanColor() | |
activityIndicator.color = .blueColor() | |
activityIndicator.tintColor = .redColor() | |
activityIndicator.startAnimating() | |
addSubview(activityIndicator) | |
} | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
activityIndicator.center = bounds.ip_center | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment