Prechádzať zdrojové kódy

* Parser for every remote table.
* Indent with tabs.

Iñigo Valentin 9 rokov pred
rodič
commit
91a49fc9c3

+ 3 - 3
MenuCollectionViewCell.swift

@@ -24,8 +24,8 @@ import UIKit
  Extension of UICollectionViewCell for the main menu.
  */
 class MenuCollectionViewCell: UICollectionViewCell {
-    
-    @IBOutlet weak var label: UILabel!
+	
+	@IBOutlet weak var label: UILabel!
  
-    @IBOutlet weak var bar: UIView!
+	@IBOutlet weak var bar: UIView!
 }

BIN
app.xcodeproj/project.xcworkspace/xcuserdata/seavenois.xcuserdatad/UserInterfaceState.xcuserstate


+ 79 - 79
app/AppDelegate.swift

@@ -24,85 +24,85 @@ import CoreData
 @UIApplicationMain
 class AppDelegate: UIResponder, UIApplicationDelegate {
 
-    var window: UIWindow?
-
-
-    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
-        // Override point for customization after application launch.
-        
-        return true
-    }
-
-    func applicationWillResignActive(_ application: UIApplication) {
-        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
-        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
-    }
-
-    func applicationDidEnterBackground(_ application: UIApplication) {
-        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
-        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
-    }
-
-    func applicationWillEnterForeground(_ application: UIApplication) {
-        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
-    }
-
-    func applicationDidBecomeActive(_ application: UIApplication) {
-        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
-    }
-
-    func applicationWillTerminate(_ application: UIApplication) {
-        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
-        // Saves changes in the application's managed object context before the application terminates.
-        //self.saveContext()
-    }
-
-    // MARK: - Core Data stack
-    
-    //Check: Why is this here?
-
-    /*lazy var persistentContainer: NSPersistentContainer = {
-        /*
-         The persistent container for the application. This implementation
-         creates and returns a container, having loaded the store for the
-         application to it. This property is optional since there are legitimate
-         error conditions that could cause the creation of the store to fail.
-        */
-        let container = NSPersistentContainer(name: "app")
-        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
-            if let error = error as NSError? {
-                // Replace this implementation with code to handle the error appropriately.
-                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
-                 
-                /*
-                 Typical reasons for an error here include:
-                 * The parent directory does not exist, cannot be created, or disallows writing.
-                 * The persistent store is not accessible, due to permissions or data protection when the device is locked.
-                 * The device is out of space.
-                 * The store could not be migrated to the current model version.
-                 Check the error message to determine what the actual problem was.
-                 */
-                fatalError("Unresolved error \(error), \(error.userInfo)")
-            }
-        })
-        return container
-    }()
-
-    // MARK: - Core Data Saving support
-
-    func saveContext () {
-        let context = persistentContainer.viewContext
-        if context.hasChanges {
-            do {
-                try context.save()
-            } catch {
-                // Replace this implementation with code to handle the error appropriately.
-                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
-                let nserror = error as NSError
-                fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
-            }
-        }
-    }*/
+	var window: UIWindow?
+
+
+	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+		// Override point for customization after application launch.
+		
+		return true
+	}
+
+	func applicationWillResignActive(_ application: UIApplication) {
+		// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+		// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
+	}
+
+	func applicationDidEnterBackground(_ application: UIApplication) {
+		// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+		// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+	}
+
+	func applicationWillEnterForeground(_ application: UIApplication) {
+		// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
+	}
+
+	func applicationDidBecomeActive(_ application: UIApplication) {
+		// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+	}
+
+	func applicationWillTerminate(_ application: UIApplication) {
+		// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+		// Saves changes in the application's managed object context before the application terminates.
+		//self.saveContext()
+	}
+
+	// MARK: - Core Data stack
+	
+	//Check: Why is this here?
+
+	/*lazy var persistentContainer: NSPersistentContainer = {
+		/*
+		 The persistent container for the application. This implementation
+		 creates and returns a container, having loaded the store for the
+		 application to it. This property is optional since there are legitimate
+		 error conditions that could cause the creation of the store to fail.
+		*/
+		let container = NSPersistentContainer(name: "app")
+		container.loadPersistentStores(completionHandler: { (storeDescription, error) in
+			if let error = error as NSError? {
+				// Replace this implementation with code to handle the error appropriately.
+				// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+				 
+				/*
+				 Typical reasons for an error here include:
+				 * The parent directory does not exist, cannot be created, or disallows writing.
+				 * The persistent store is not accessible, due to permissions or data protection when the device is locked.
+				 * The device is out of space.
+				 * The store could not be migrated to the current model version.
+				 Check the error message to determine what the actual problem was.
+				 */
+				fatalError("Unresolved error \(error), \(error.userInfo)")
+			}
+		})
+		return container
+	}()
+
+	// MARK: - Core Data Saving support
+
+	func saveContext () {
+		let context = persistentContainer.viewContext
+		if context.hasChanges {
+			do {
+				try context.save()
+			} catch {
+				// Replace this implementation with code to handle the error appropriately.
+				// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+				let nserror = error as NSError
+				fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
+			}
+		}
+	}*/
 
 }
 

+ 46 - 46
app/HomeView.swift

@@ -25,50 +25,50 @@ import UIKit
  Class to handle the home view.
  */
 class HomeView: UIView {
-    
-    //The main scroll view.
-    @IBOutlet weak var scrollView: UIScrollView!
-    
-    //The container of the view.
-    @IBOutlet weak var container: UIView!
-    
-    //Each of the sections of the view.
-    @IBOutlet weak var locationSection: Section!
-    @IBOutlet weak var lablancaSection: Section!
-    @IBOutlet weak var futureActivitiesSection: Section!
-    @IBOutlet weak var blogSection: Section!
-    @IBOutlet weak var gallerySection: Section!
-    @IBOutlet weak var pastActivitiesSection: Section!
-    @IBOutlet weak var socialSection: Section!
-    
-    /**
-     Run when the view is started.
-    */
-    required init?(coder aDecoder: NSCoder) {
-        
-        super.init(coder: aDecoder)
-        
-        //Load the contents of the HomeView.xib file.
-        Bundle.main.loadNibNamed("HomeView", owner: self, options: nil)
-        self.addSubview(container)
-        container.frame = self.bounds
-        
-        //Set titles for each section
-        locationSection.setTitle(text: "Encuentranos")
-        lablancaSection.setTitle(text: "La Blanca")
-        futureActivitiesSection.setTitle(text: "Proximas actividades")
-        blogSection.setTitle(text: "Ultimos posts")
-        gallerySection.setTitle(text: "Ultimas fotos")
-        pastActivitiesSection.setTitle(text: "Ultimas actividades")
-        socialSection.setTitle(text: "Siguenos")
-        
-        //Always at the end: update scrollview
-        var h: Int = 0
-        for view in scrollView.subviews {
-            //contentRect = contentRect.union(view.frame);
-            h = h + Int(view.frame.height) + 30 //Why 30?
-            print("curh: \(h)")
-        }
-        self.scrollView.contentSize.height = CGFloat(h);
-    }
+	
+	//The main scroll view.
+	@IBOutlet weak var scrollView: UIScrollView!
+	
+	//The container of the view.
+	@IBOutlet weak var container: UIView!
+	
+	//Each of the sections of the view.
+	@IBOutlet weak var locationSection: Section!
+	@IBOutlet weak var lablancaSection: Section!
+	@IBOutlet weak var futureActivitiesSection: Section!
+	@IBOutlet weak var blogSection: Section!
+	@IBOutlet weak var gallerySection: Section!
+	@IBOutlet weak var pastActivitiesSection: Section!
+	@IBOutlet weak var socialSection: Section!
+	
+	/**
+	 Run when the view is started.
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		
+		super.init(coder: aDecoder)
+		
+		//Load the contents of the HomeView.xib file.
+		Bundle.main.loadNibNamed("HomeView", owner: self, options: nil)
+		self.addSubview(container)
+		container.frame = self.bounds
+		
+		//Set titles for each section
+		locationSection.setTitle(text: "Encuentranos")
+		lablancaSection.setTitle(text: "La Blanca")
+		futureActivitiesSection.setTitle(text: "Proximas actividades")
+		blogSection.setTitle(text: "Ultimos posts")
+		gallerySection.setTitle(text: "Ultimas fotos")
+		pastActivitiesSection.setTitle(text: "Ultimas actividades")
+		socialSection.setTitle(text: "Siguenos")
+		
+		//Always at the end: update scrollview
+		var h: Int = 0
+		for view in scrollView.subviews {
+			//contentRect = contentRect.union(view.frame);
+			h = h + Int(view.frame.height) + 30 //Why 30?
+			print("curh: \(h)")
+		}
+		self.scrollView.contentSize.height = CGFloat(h);
+	}
 }

+ 29 - 29
app/Section.swift

@@ -25,33 +25,33 @@ import UIKit
   Extension of UIView to be formatted as sections.
  */
 class Section: UIView {
-    
-    //The container.
-    @IBOutlet weak var container: UIView!
-    
-    //The section title.
-    @IBOutlet weak var title: UITextView!
-    
-    //The content of the section.
-    @IBOutlet weak var content: UIView!
-    
-    /**
-     Run when the section is loaded.
-    */
-    required init?(coder aDecoder: NSCoder) {
-        super.init(coder: aDecoder)
-        
-        //Load the contents of the Section.xib file.
-        Bundle.main.loadNibNamed("Section", owner: self, options: nil)
-        self.addSubview(container)
-        container.frame = self.bounds
-    }
-    
-    /**
-     Chancges the title of the section.
-     :param: title The new title.
-    */
-    func setTitle(text: String){
-        title.text = text
-    }
+	
+	//The container.
+	@IBOutlet weak var container: UIView!
+	
+	//The section title.
+	@IBOutlet weak var title: UITextView!
+	
+	//The content of the section.
+	@IBOutlet weak var content: UIView!
+	
+	/**
+	 Run when the section is loaded.
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+		
+		//Load the contents of the Section.xib file.
+		Bundle.main.loadNibNamed("Section", owner: self, options: nil)
+		self.addSubview(container)
+		container.frame = self.bounds
+	}
+	
+	/**
+	 Chancges the title of the section.
+	 :param: title The new title.
+	*/
+	func setTitle(text: String){
+		title.text = text
+	}
 }

+ 40 - 40
app/String.swift

@@ -9,44 +9,44 @@
 import Foundation
 
 extension String {
-    var length:Int {
-        return self.characters.count
-    }
-    
-    func indexOf(target: String) -> Int? {
-        
-        let range = (self as NSString).range(of: target)
-        
-        guard range.toRange() != nil else {
-            return nil
-        }
-        
-        return range.location
-        
-    }
-    func lastIndexOf(target: String) -> Int? {
-        
-        
-        
-        let range = (self as NSString).range(of: target, options: NSString.CompareOptions.backwards)
-        
-        guard range.toRange() != nil else {
-            return nil
-        }
-        
-        return self.length - range.location - 1
-        
-    }
-    func contains(s: String) -> Bool {
-        return (self.range(of: s) != nil) ? true : false
-    }
-    
-    func subStr(start: Int, end: Int) -> String{
-        
-        let st = self.index(self.startIndex, offsetBy: start)
-        var ed = self.index(self.startIndex, offsetBy: end)
-        
-        let range = st...ed
-        return self[range]
-    }
+	var length:Int {
+		return self.characters.count
+	}
+	
+	func indexOf(target: String) -> Int? {
+		
+		let range = (self as NSString).range(of: target)
+		
+		guard range.toRange() != nil else {
+			return nil
+		}
+		
+		return range.location
+		
+	}
+	func lastIndexOf(target: String) -> Int? {
+		
+		
+		
+		let range = (self as NSString).range(of: target, options: NSString.CompareOptions.backwards)
+		
+		guard range.toRange() != nil else {
+			return nil
+		}
+		
+		return self.length - range.location - 1
+		
+	}
+	func contains(s: String) -> Bool {
+		return (self.range(of: s) != nil) ? true : false
+	}
+	
+	func subStr(start: Int, end: Int) -> String{
+		
+		let st = self.index(self.startIndex, offsetBy: start)
+		var ed = self.index(self.startIndex, offsetBy: end)
+		
+		let range = st...ed
+		return self[range]
+	}
 }

+ 100 - 73
app/Sync.swift

@@ -24,78 +24,105 @@ import Foundation
  Class to handle server sync.
  */
 class Sync{
-    
-    /**
-     Starts the sync process.
-    */
-    init(){
-        let url = buildUrl();
-        sync(url: url)
-    
-    }
-    
-    /**
-     Builds the URL to perform the sync against.
-     :returns: The URL.
-    */
-    func buildUrl() -> URL{
-        let url = URL(string: "https://margolariak.com/API/v1/sync.php?client=com.margolariak.app")
-        //TODO add parameters
-        return url!
-        
-    }
-    
-    /**
-     Performs an asynchronous sync.
-     It fethes the info from the server and stores as Core Data
-     :param: url The url to sync.
-    */
-    func sync(url: URL){
-        
-        //Synchronously get data
-        let task = URLSession.shared.dataTask(with: url) { data, response, error in
-            guard error == nil else {
-                print("error")
-                return
-            }
-            guard let data = data else {
-                print("Data is empty")
-                return
-            }
-            
-            print("Got the Sync JSON")
-            
-            var strData = String(data:data, encoding: String.Encoding.utf8)
-            
-            let dataIdx = strData?.indexOf(target: "{\"data\"")
-            strData = strData!.subStr(start: dataIdx!, end: strData!.length - 1)
-            
-            //TODO: do something with versions
-            
-            let dataActivities : [String] = self.getTable(data: strData!, table: "activity")
-            
-        }
-        
-        task.resume()
+	
+	/**
+	 Starts the sync process.
+	*/
+	init(){
+		let url = buildUrl();
+		sync(url: url)
+	
+	}
+	
+	/**
+	 Builds the URL to perform the sync against.
+	 :returns: The URL.
+	*/
+	func buildUrl() -> URL{
+		let url = URL(string: "https://margolariak.com/API/v1/sync.php?client=com.margolariak.app")
+		//TODO add parameters
+		return url!
+		
+	}
+	
+	/**
+	 Performs an asynchronous sync.
+	 It fethes the info from the server and stores as Core Data
+	 :param: url The url to sync.
+	*/
+	func sync(url: URL){
+		
+		//Synchronously get data
+		let task = URLSession.shared.dataTask(with: url) { data, response, error in
+			guard error == nil else {
+				print("error")
+				return
+			}
+			guard let data = data else {
+				print("Data is empty")
+				return
+			}
+			
+			print("Got the Sync JSON")
+			
+			var strData = String(data:data, encoding: String.Encoding.utf8)
+			
+			let dataIdx = strData?.indexOf(target: "{\"data\"")
+			strData = strData!.subStr(start: dataIdx!, end: strData!.length - 1)
+			
+			//TODO: do something with versions
+			
+			//Get tables
+			let dataActivity : [String] = self.getTable(data: strData!, table: "activity")
+			let dataActivityComment : [String] = self.getTable(data: strData!, table: "activity_comment")
+			let dataActivityImage : [String] = self.getTable(data: strData!, table: "activity_image")
+			let dataActivityTag : [String] = self.getTable(data: strData!, table: "activity_tag")
+			let dataAlbum : [String] = self.getTable(data: strData!, table: "album")
+			let dataFestival : [String] = self.getTable(data: strData!, table: "festival")
+			let dataFestivalDay : [String] = self.getTable(data: strData!, table: "festival_day")
+			let dataFestivalEvent : [String] = self.getTable(data: strData!, table: "festival_event")
+			let dataFestivalEventImage : [String] = self.getTable(data: strData!, table: "festival_event_image")
+			let dataFestivalOffer : [String] = self.getTable(data: strData!, table: "festival_offer")
+			let dataPeople : [String] = self.getTable(data: strData!, table: "people")
+			let dataPhoto : [String] = self.getTable(data: strData!, table: "photo")
+			let dataPhotoAlbum : [String] = self.getTable(data: strData!, table: "photo_album")
+			let dataPhotoComment : [String] = self.getTable(data: strData!, table: "photo_comment")
+			let dataPlace : [String] = self.getTable(data: strData!, table: "place")
+			let dataPost : [String] = self.getTable(data: strData!, table: "post")
+			let dataPostComment : [String] = self.getTable(data: strData!, table: "post_comment")
+			let dataPostImage : [String] = self.getTable(data: strData!, table: "post_image")
+			let dataPostTag : [String] = self.getTable(data: strData!, table: "post_tag")
+			let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
+			
+			//One by one, save the received data
+			//self.saveActivities(dataActivity)
+		}
+		
+		task.resume()
 
-    }
-    
-    func getTable(data: String, table: String) -> [String]{
-        let iS : Int? = data.indexOf(target: table)
-        var str = data.subStr(start: iS!, end: data.length - 1)
-        let iE : Int? = str.indexOf(target: "}]}")!
-        str = str.subStr(start: 0, end: iE!)
-        str = str.subStr(start: table.length + 3,end: str.length - 1)
-        
-        //Separate the entries
-        var entries : [String] = str.components(separatedBy: "},{")
-        
-        //Modify the first and the last one to remove bracers
-        entries[0] = entries[0].subStr(start: 1, end: entries[0].length - 1)
-        entries[entries.count - 1] = entries[entries.count - 1].subStr(start: 0, end: entries[entries.count - 1].length - 2)
-        
-        //Return the array
-        return entries
-    }
-    
+	}
+	
+	func getTable(data: String, table: String) -> [String]{
+			//Does the table exists?
+			if data.indexOf(target: table) == nil{
+				print("No data in table \(table)")
+				return [String]()
+			}
+			let iS : Int? = data.indexOf(target: table)
+			var str = data.subStr(start: iS!, end: data.length - 1)
+			let iE : Int? = str.indexOf(target: "}]}")!
+			str = str.subStr(start: 0, end: iE!)
+			str = str.subStr(start: table.length + 3,end: str.length - 1)
+		
+			//Separate the entries
+			var entries : [String] = str.components(separatedBy: "},{")
+		
+			//Modify the first and the last one to remove bracers
+			entries[0] = entries[0].subStr(start: 1, end: entries[0].length - 1)
+			entries[entries.count - 1] = entries[entries.count - 1].subStr(start: 0, end: entries[entries.count - 1].length - 2)
+		
+			//Return the array
+			return entries
+	}
+	
 }

+ 34 - 34
app/UIView.swift

@@ -25,38 +25,38 @@ import UIKit
  builder.
  */
 @IBDesignable extension UIView {
-    
-    //Border color.
-    @IBInspectable var borderColor:UIColor? {
-        set {
-            layer.borderColor = newValue!.cgColor
-        }
-        get {
-            if let color = layer.borderColor {
-                return UIColor(cgColor:color)
-            }
-            else {
-                return nil
-            }
-        }
-    }
-    
-    //Border width.
-    @IBInspectable var borderWidth:CGFloat {
-        set {
-            layer.borderWidth = newValue
-        }
-        get {
-            return layer.borderWidth
-        }
-    }
-    @IBInspectable var cornerRadius:CGFloat {
-        set {
-            layer.cornerRadius = newValue
-            clipsToBounds = newValue > 0
-        }
-        get {
-            return layer.cornerRadius
-        }
-    }
+	
+	//Border color.
+	@IBInspectable var borderColor:UIColor? {
+		set {
+			layer.borderColor = newValue!.cgColor
+		}
+		get {
+			if let color = layer.borderColor {
+				return UIColor(cgColor:color)
+			}
+			else {
+				return nil
+			}
+		}
+	}
+	
+	//Border width.
+	@IBInspectable var borderWidth:CGFloat {
+		set {
+			layer.borderWidth = newValue
+		}
+		get {
+			return layer.borderWidth
+		}
+	}
+	@IBInspectable var cornerRadius:CGFloat {
+		set {
+			layer.cornerRadius = newValue
+			clipsToBounds = newValue > 0
+		}
+		get {
+			return layer.cornerRadius
+		}
+	}
 }

+ 161 - 161
app/ViewController.swift

@@ -24,169 +24,169 @@ import UIKit
   The view controller of the app.
  */
 class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
-    
-    //The menu collection.
-    var sectionCollection: UICollectionView!
+	
+	//The menu collection.
+	var sectionCollection: UICollectionView!
 
-    //Each of the sections of the app.
-    @IBOutlet weak var containerViewGallery: UIView!
-    @IBOutlet weak var containerViewBlog: UIView!
-    @IBOutlet weak var containerViewActivities: UIView!
-    @IBOutlet weak var containerViewLablanca: UIView!
-    @IBOutlet weak var containerViewLocation: UIView!
-    @IBOutlet weak var containerViewHome: HomeView!
-    
-    /**
-     Run when the app loads.
-    */
-    override func viewDidLoad() {
-        
-        //Hide all sections, except for the first one
-        self.containerViewLocation.alpha = 0
-        self.containerViewLablanca.alpha = 0
-        self.containerViewActivities.alpha = 0
-        self.containerViewBlog.alpha = 0
-        self.containerViewGallery.alpha = 0
-        
-        print("ViewController:viewDidLoad()")
-        Sync()
-        
-        super.viewDidLoad()
-        // Do any additional setup after loading the view, typically from a nib.
-    }
+	//Each of the sections of the app.
+	@IBOutlet weak var containerViewGallery: UIView!
+	@IBOutlet weak var containerViewBlog: UIView!
+	@IBOutlet weak var containerViewActivities: UIView!
+	@IBOutlet weak var containerViewLablanca: UIView!
+	@IBOutlet weak var containerViewLocation: UIView!
+	@IBOutlet weak var containerViewHome: HomeView!
+	
+	/**
+	 Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		//Hide all sections, except for the first one
+		self.containerViewLocation.alpha = 0
+		self.containerViewLablanca.alpha = 0
+		self.containerViewActivities.alpha = 0
+		self.containerViewBlog.alpha = 0
+		self.containerViewGallery.alpha = 0
+		
+		print("ViewController:viewDidLoad()")
+		Sync()
+		
+		super.viewDidLoad()
+		// Do any additional setup after loading the view, typically from a nib.
+	}
 
-    /**
-     Dispose of any resources that can be recreated.
-    */
-    override func didReceiveMemoryWarning() {
-        super.didReceiveMemoryWarning()
-    }
-    
-    
-    //Menu items.
-    let reuseIdentifier = "cell"
-    var selected = 0
-    var items = ["Home", "Location", "La Blanca", "Actividades", "Blog", "Gallery"]
-    
-    // MARK: - UICollectionViewDataSource protocol
-    
-    //Tell the collection view how many cells to make
-    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return self.items.count
-    }
-    
-    //Make a cell for each section
-    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        
-        print("SET: \(selected)/\(indexPath.item)")
-        
-        //Get a reference to our storyboard cell
-        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! MenuCollectionViewCell
-        
-        //Set text
-        cell.label.text = self.items[indexPath.item]
-        
-        //Mark the first cell as selected...
-        if indexPath.item == selected{
-            cell.bar.backgroundColor = UIColor(red: 90/255, green: 180/255, blue: 255/255, alpha: 1)
-            cell.label.font = UIFont.boldSystemFont(ofSize: cell.label.font.pointSize)
-        }
-            
-        //... and the others as unselected
-        else{
-            cell.bar.backgroundColor = UIColor(red: 148/255, green: 209/255, blue: 255/255, alpha: 1)
-            cell.label.font = UIFont.systemFont(ofSize: cell.label.font.pointSize)
-        }
-        
-        return cell
-    }
-    
-    // MARK: - UICollectionViewDelegate protocol
-    
-    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        sectionCollection = collectionView
-        showComponent(selected: indexPath.item)
-    }
-    
-    @IBAction func showComponent(selected: Int) {
-        //Activate label
-        var i = 0
-        for cell in sectionCollection.visibleCells as! [MenuCollectionViewCell]{ //TODO: Not only visibles!
-            if i == selected + 1{
-                cell.bar.backgroundColor = UIColor(red: 90/255, green: 180/255, blue: 255/255, alpha: 1)
-                cell.label.font = UIFont.boldSystemFont(ofSize: cell.label.font.pointSize)
-            }
-            else{
-                cell.bar.backgroundColor = UIColor(red: 148/255, green: 209/255, blue: 255/255, alpha: 1)
-                cell.label.font = UIFont.systemFont(ofSize: cell.label.font.pointSize)
-                
-            }
-            i = i + 1
-        }
-        
-        //Show the view
-        if selected == 0 {
-            UIView.animate(withDuration: 0.5, animations: {
-                self.containerViewHome.alpha = 1
-                self.containerViewLocation.alpha = 0
-                self.containerViewLablanca.alpha = 0
-                self.containerViewActivities.alpha = 0
-                self.containerViewBlog.alpha = 0
-                self.containerViewGallery.alpha = 0
-            })
-        }
-        else if selected == 1 {
-            UIView.animate(withDuration: 0.5, animations: {
-                self.containerViewHome.alpha = 0
-                self.containerViewLocation.alpha = 1
-                self.containerViewLablanca.alpha = 0
-                self.containerViewActivities.alpha = 0
-                self.containerViewBlog.alpha = 0
-                self.containerViewGallery.alpha = 0
-            })
-        }
-        else if selected == 2 {
-            UIView.animate(withDuration: 0.5, animations: {
-                self.containerViewHome.alpha = 0
-                self.containerViewLocation.alpha = 0
-                self.containerViewLablanca.alpha = 1
-                self.containerViewActivities.alpha = 0
-                self.containerViewBlog.alpha = 0
-                self.containerViewGallery.alpha = 0
-            })
-        }
-        else if selected == 3 {
-            UIView.animate(withDuration: 0.5, animations: {
-                self.containerViewHome.alpha = 0
-                self.containerViewLocation.alpha = 0
-                self.containerViewLablanca.alpha = 0
-                self.containerViewActivities.alpha = 1
-                self.containerViewBlog.alpha = 0
-                self.containerViewGallery.alpha = 0
-            })
-        }
-        else if selected == 4 {
-            UIView.animate(withDuration: 0.5, animations: {
-                self.containerViewHome.alpha = 0
-                self.containerViewLocation.alpha = 0
-                self.containerViewLablanca.alpha = 0
-                self.containerViewActivities.alpha = 0
-                self.containerViewBlog.alpha = 1
-                self.containerViewGallery.alpha = 0
-            })
-        }
-        else if selected == 5 {
-            UIView.animate(withDuration: 0.5, animations: {
-                self.containerViewHome.alpha = 0
-                self.containerViewLocation.alpha = 0
-                self.containerViewLablanca.alpha = 0
-                self.containerViewActivities.alpha = 0
-                self.containerViewBlog.alpha = 0
-                self.containerViewGallery.alpha = 1
-            })
-        }
-        
-    }
+	/**
+	 Dispose of any resources that can be recreated.
+	*/
+	override func didReceiveMemoryWarning() {
+		super.didReceiveMemoryWarning()
+	}
+	
+	
+	//Menu items.
+	let reuseIdentifier = "cell"
+	var selected = 0
+	var items = ["Home", "Location", "La Blanca", "Actividades", "Blog", "Gallery"]
+	
+	// MARK: - UICollectionViewDataSource protocol
+	
+	//Tell the collection view how many cells to make
+	func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+		return self.items.count
+	}
+	
+	//Make a cell for each section
+	func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+		
+		print("SET: \(selected)/\(indexPath.item)")
+		
+		//Get a reference to our storyboard cell
+		let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! MenuCollectionViewCell
+		
+		//Set text
+		cell.label.text = self.items[indexPath.item]
+		
+		//Mark the first cell as selected...
+		if indexPath.item == selected{
+			cell.bar.backgroundColor = UIColor(red: 90/255, green: 180/255, blue: 255/255, alpha: 1)
+			cell.label.font = UIFont.boldSystemFont(ofSize: cell.label.font.pointSize)
+		}
+			
+		//... and the others as unselected
+		else{
+			cell.bar.backgroundColor = UIColor(red: 148/255, green: 209/255, blue: 255/255, alpha: 1)
+			cell.label.font = UIFont.systemFont(ofSize: cell.label.font.pointSize)
+		}
+		
+		return cell
+	}
+	
+	// MARK: - UICollectionViewDelegate protocol
+	
+	func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+		sectionCollection = collectionView
+		showComponent(selected: indexPath.item)
+	}
+	
+	@IBAction func showComponent(selected: Int) {
+		//Activate label
+		var i = 0
+		for cell in sectionCollection.visibleCells as! [MenuCollectionViewCell]{ //TODO: Not only visibles!
+			if i == selected + 1{
+				cell.bar.backgroundColor = UIColor(red: 90/255, green: 180/255, blue: 255/255, alpha: 1)
+				cell.label.font = UIFont.boldSystemFont(ofSize: cell.label.font.pointSize)
+			}
+			else{
+				cell.bar.backgroundColor = UIColor(red: 148/255, green: 209/255, blue: 255/255, alpha: 1)
+				cell.label.font = UIFont.systemFont(ofSize: cell.label.font.pointSize)
+				
+			}
+			i = i + 1
+		}
+		
+		//Show the view
+		if selected == 0 {
+			UIView.animate(withDuration: 0.5, animations: {
+				self.containerViewHome.alpha = 1
+				self.containerViewLocation.alpha = 0
+				self.containerViewLablanca.alpha = 0
+				self.containerViewActivities.alpha = 0
+				self.containerViewBlog.alpha = 0
+				self.containerViewGallery.alpha = 0
+			})
+		}
+		else if selected == 1 {
+			UIView.animate(withDuration: 0.5, animations: {
+				self.containerViewHome.alpha = 0
+				self.containerViewLocation.alpha = 1
+				self.containerViewLablanca.alpha = 0
+				self.containerViewActivities.alpha = 0
+				self.containerViewBlog.alpha = 0
+				self.containerViewGallery.alpha = 0
+			})
+		}
+		else if selected == 2 {
+			UIView.animate(withDuration: 0.5, animations: {
+				self.containerViewHome.alpha = 0
+				self.containerViewLocation.alpha = 0
+				self.containerViewLablanca.alpha = 1
+				self.containerViewActivities.alpha = 0
+				self.containerViewBlog.alpha = 0
+				self.containerViewGallery.alpha = 0
+			})
+		}
+		else if selected == 3 {
+			UIView.animate(withDuration: 0.5, animations: {
+				self.containerViewHome.alpha = 0
+				self.containerViewLocation.alpha = 0
+				self.containerViewLablanca.alpha = 0
+				self.containerViewActivities.alpha = 1
+				self.containerViewBlog.alpha = 0
+				self.containerViewGallery.alpha = 0
+			})
+		}
+		else if selected == 4 {
+			UIView.animate(withDuration: 0.5, animations: {
+				self.containerViewHome.alpha = 0
+				self.containerViewLocation.alpha = 0
+				self.containerViewLablanca.alpha = 0
+				self.containerViewActivities.alpha = 0
+				self.containerViewBlog.alpha = 1
+				self.containerViewGallery.alpha = 0
+			})
+		}
+		else if selected == 5 {
+			UIView.animate(withDuration: 0.5, animations: {
+				self.containerViewHome.alpha = 0
+				self.containerViewLocation.alpha = 0
+				self.containerViewLablanca.alpha = 0
+				self.containerViewActivities.alpha = 0
+				self.containerViewBlog.alpha = 0
+				self.containerViewGallery.alpha = 1
+			})
+		}
+		
+	}
 
 
 }