Skip to content

Instantly share code, notes, and snippets.

View DejanEnspyra's full-sized avatar

Dejan Atanasov DejanEnspyra

View GitHub Profile
@DejanEnspyra
DejanEnspyra / ReoderGesture.swift
Created August 1, 2017 15:44
Reodering gesture used for controlling drag and drop feature in UICollectionView
fileprivate var longPressGesture: UILongPressGestureRecognizer!
override func viewDidLoad() {
super.viewDidLoad()
longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongGesture(gesture:)))
reorderCollectionView.addGestureRecognizer(longPressGesture)
}
@objc func handleLongGesture(gesture: UILongPressGestureRecognizer) {
@DejanEnspyra
DejanEnspyra / testmodel.swift
Created September 20, 2017 15:48
CleanSwift architecture - Models component
import UIKit
struct TestModel{
struct Fetch {
struct Request
{
var itemId = 0
var keyword: String?
var count: String?
}
@DejanEnspyra
DejanEnspyra / testrouter.swift
Last active September 20, 2017 16:39
CleanSwift architecture - Router component
import UIKit
protocol TestRouterInput {
func showSomeVC()
}
class TestRouter: TestRouterInput
{
weak var viewController: ViewController!
@DejanEnspyra
DejanEnspyra / testworker.swift
Last active September 20, 2017 17:06
Clean Swift architecture - Worker component
typealias responseHandler = (_ response:TestModel.Fetch.Response) ->()
class TestWorker{
func fetch(itemId:Int!, keyword:String!, count: String!, success:@escaping(responseHandler), fail:@escaping(responseHandler))
{
// NOTE: Do the work
//call network etc.
let manager = YourApiManager()
@DejanEnspyra
DejanEnspyra / testinteractor.swift
Created September 20, 2017 17:17
Clean Swift Architecture - Interactor Component
import UIKit
protocol TestInteractorInput
{
func fetchItems(request: TestModel.Fetch.Request)
}
protocol TestInteractorOutput
{
func presentFetchResults(response: TestModel.Fetch.Response);
@DejanEnspyra
DejanEnspyra / testpresenter.swift
Created September 20, 2017 17:33
Clean Swift - Presenter Component
import UIKit
protocol TestPresenterInput
{
func presentFetchResults(response: TestModel.Fetch.Response);
}
protocol TestPresenterOutput: class
{
func successFetchedItems(viewModel: TestModel.Fetch.ViewModel)
@DejanEnspyra
DejanEnspyra / testconfigurator.swift
Created September 20, 2017 17:44
Clean Swift Architecture - Configurator component
import UIKit
// MARK: - Connect View, Interactor, and Presenter
extension ViewController: TestPresenterOutput
{
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
router.passDataToNextScene(segue: segue)
}
@DejanEnspyra
DejanEnspyra / markerdragging.swift
Created October 3, 2017 17:47
Marker Dragging using GoogleMaps iOS SDK
extension ViewController: GMSMapViewDelegate{
//MARK - GMSMarker Dragging
func mapView(_ mapView: GMSMapView, didBeginDragging marker: GMSMarker) {
print("didBeginDragging")
}
func mapView(_ mapView: GMSMapView, didDrag marker: GMSMarker) {
print("didDrag")
}
func mapView(_ mapView: GMSMapView, didEndDragging marker: GMSMarker) {
@DejanEnspyra
DejanEnspyra / tapcoordinate.swift
Created October 3, 2017 18:18
Tap Coordinate Google Maps iOS SDK
extension ViewController: GMSMapViewDelegate{
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D){
marker.position = coordinate
}
}
@DejanEnspyra
DejanEnspyra / ViewController.swift
Last active October 3, 2017 19:22
Initialization Google Maps SDK iOS
import UIKit
import GoogleMaps
class ViewController: UIViewController {
@IBOutlet fileprivate weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.camera(withLatitude: 37.36, longitude: -122.0, zoom: 6.0)