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
/// Global extension to remove all padding from all UITextView's. | |
extension UITextView { | |
open override func setNeedsDisplay() { | |
super.setNeedsDisplay() | |
textContainerInset = UIEdgeInsets.zero | |
textContainer.lineFragmentPadding = 0 | |
} | |
} |
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
// | |
// OneLineForEachSectionLayout.swift | |
// | |
// Created by Philipp Kinschel on 28/11/2016. | |
// | |
// | |
// | |
// very basic solution to layout one section in one line without linebreaks | |
// TODO: find name for the class | |
// |
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
/* | |
* Custom Ordering Field: Descending | |
* - Trust me, this is the simplest way to do this with Firebase. 🤘 | |
*/ | |
imageObj["order"] = -image.uploadedAt.timeIntervalSince1970 | |
/* */ | |
FirebaseDatabaseReference.photos |
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
extension Int { | |
static func random(range: Range<Int>) -> Int { | |
var offset = 0 | |
if range.lowerBound < 0 { | |
offset = abs(range.lowerBound) | |
} | |
let mini = UInt32(range.lowerBound + offset) | |
let maxi = UInt32(range.upperBound + offset) |
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
@IBDesignable class UITextViewFixed: UITextView { | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
setup() | |
} | |
func setup() { | |
textContainerInset = UIEdgeInsets.zero | |
textContainer.lineFragmentPadding = 0 | |
} | |
} |
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
func add(asChildViewController viewController: UIViewController) { | |
// Add Child View Controller | |
self.addChildViewController(viewController) | |
// Add Child View as Subview | |
self.drawerContainerView.addSubview(viewController.view) | |
// self.view.addSubview(viewController.view) | |
// Configure Child View |
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
// Instantiate | |
self.mapViewController = self.storyboard?.instantiateViewController(withIdentifier: "MapViewController") as? MapViewController | |
if let mapViewController = self.mapViewController { | |
// Add to Container View | |
self.mapViewContainerView.addSubview(mapViewController.view) | |
self.addChildViewController(mapViewController) | |
mapViewController.didMove(toParentViewController: self) | |
} |
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
func scrollViewDidScroll(_ scrollView: UIScrollView) { | |
// Move ContainerView based on pagination from custom pagingScrollView | |
if scrollView == pagingScrollView { | |
// Calculate offset | |
let offset = (self.view.frame.size.height - bottomPeekMargin) - scrollView.contentOffset.y | |
// Overlay value (interpolates between 0.0 and 1.0 for end value) | |
// Note to self: contentOffset divided by endValue (where you end the animation) |
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
// Conform to Hashable | |
extension ChargeConnector: Hashable { | |
var hashValue: Int { | |
return id.hashValue ^ id.hashValue | |
} | |
static func == (lhs: ChargeConnector, rhs: ChargeConnector) -> Bool { | |
return lhs.id == rhs.id | |
} |
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
- (void)mapView:(GMSMapView*)mapView idleAtCameraPosition:(GMSCameraPosition*)position | |
{ | |
CLLocationCoordinate2D topLeft = mapView.projection.visibleRegion.farLeft; | |
CLLocationCoordinate2D bottomLeft = mapView.projection.visibleRegion.nearLeft; | |
double lat = fabs(topLeft.latitude - bottomLeft.latitude); | |
double mpp = cos(lat * M_PI / 180) * 2 * M_PI * 6378137 / (256 * pow(2, mapView.camera.zoom)); | |
double distance = mpp * mapView.frame.size.width; | |
[[SearchManager shareInstance] distance: distance]; | |
} |