Переглянути джерело

Merge branch 'BaseProject' into Activities

Iñigo Valentin 9 роки тому
батько
коміт
5c4409ebe7

+ 26 - 0
MenuCollectionViewCell.swift

@@ -28,4 +28,30 @@ class MenuCollectionViewCell: UICollectionViewCell {
 	@IBOutlet weak var label: UILabel!
 	@IBOutlet weak var label: UILabel!
  
  
 	@IBOutlet weak var bar: UIView!
 	@IBOutlet weak var bar: UIView!
+	
+	
+	override var isHighlighted: Bool {
+		willSet {
+			onSelected(newValue)
+		}
+	}
+	override var isSelected: Bool {
+		willSet {
+			onSelected(newValue)
+		}
+	}
+	func onSelected(_ newValue: Bool) {
+
+		guard selectedBackgroundView == nil else { return }
+		if newValue == true {
+			self.bar.backgroundColor = UIColor(red: 148/255, green: 209/255, blue: 255/255, alpha: 1)
+			self.label.font = UIFont.boldSystemFont(ofSize: self.label.font.pointSize)
+			self.label.textColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)
+		}
+		else{
+			self.bar.backgroundColor = UIColor(red: 90/255, green: 180/255, blue: 255/255, alpha: 1)
+			self.label.font = UIFont.systemFont(ofSize: self.label.font.pointSize)
+			self.label.textColor = UIColor(red: 200/255, green: 200/255, blue: 200/255, alpha: 1)
+		}
+	}
 }
 }

+ 4 - 4
README.es-ES.md

@@ -1,6 +1,5 @@
 ---
 ---
-[Informazioa euskaraz](README.es-EU.md) 
-[Information in english](README.md)
+[Informazioa euskaraz](README.es-EU.md) - [Information in english](README.md)
 ---
 ---
 
 
 
 
@@ -13,8 +12,9 @@ Una aplicacion para iOS para miembros de [Gasteizko Margolariak](https://margola
 Hay funciones diseñadas especificamente para las Fiestas de La Blanca, y solo estarán disponibles en esas fechas.
 Hay funciones diseñadas especificamente para las Fiestas de La Blanca, y solo estarán disponibles en esas fechas.
 
 
 * [NO IMPLEMENTADO] Consulta en tu teléfono el Programa de Fiestas, encuentra actos alrededor tuyo ydescubre como llegar hasta ellos.
 * [NO IMPLEMENTADO] Consulta en tu teléfono el Programa de Fiestas, encuentra actos alrededor tuyo ydescubre como llegar hasta ellos.
-* [NO IMPLEMENTADO] Consulta el Programa de Fiestas de Gasteizko Margolariak, detallado y con la ubicación de cada actividad...
-* [NO IMPLEMENTADO] ... pero, como no somos famosos por nuestra puntualidad, comprueba nuestra ubicación en tiempo real.
+* Consulta el Programa de Fiestas de Gasteizko Margolariak, detallado y con la ubicación de cada actividad...
+* ... pero, como no somos famosos por nuestra puntualidad, comprueba nuestra ubicación en tiempo real.
+* [NO IMPLEMENTADO] Descubre eventos a tu alrededor.
 
 
 
 
 ### Durante el resto del año ###
 ### Durante el resto del año ###

+ 4 - 4
README.es-EU.md

@@ -1,6 +1,5 @@
 ---
 ---
-[Informacion en castellano](README.es-ES.md) 
-[Information in english](README.md)
+[Informacion en castellano](README.es-ES.md) - [Information in english](README.md)
 ---
 ---
 
 
 
 
@@ -13,8 +12,9 @@ Una aplicacion para iOS para miembros de [Gasteizko Margolariak](https://margola
 Hay funciones diseñadas especificamente para las Fiestas de La Blanca, y solo estarán disponibles en esas fechas.
 Hay funciones diseñadas especificamente para las Fiestas de La Blanca, y solo estarán disponibles en esas fechas.
 
 
 * [NO IMPLEMENTADO] Consulta en tu teléfono el Programa de Fiestas, encuentra actos alrededor tuyo ydescubre como llegar hasta ellos.
 * [NO IMPLEMENTADO] Consulta en tu teléfono el Programa de Fiestas, encuentra actos alrededor tuyo ydescubre como llegar hasta ellos.
-* [NO IMPLEMENTADO] Consulta el Programa de Fiestas de Gasteizko Margolariak, detallado y con la ubicación de cada actividad...
-* [NO IMPLEMENTADO] ... pero, como no somos famosos por nuestra puntualidad, comprueba nuestra ubicación en tiempo real.
+* Consulta el Programa de Fiestas de Gasteizko Margolariak, detallado y con la ubicación de cada actividad...
+* ... pero, como no somos famosos por nuestra puntualidad, comprueba nuestra ubicación en tiempo real.
+* Descubre eventos a tu alrededor.
 
 
 
 
 ### Durante el resto del año ###
 ### Durante el resto del año ###

+ 3 - 4
README.md

@@ -1,6 +1,5 @@
 ---
 ---
-[Información en castellano](README.es-ES.md) 
-[Informazioa euskaraz](README.es-EU.md)
+[Información en castellano](README.es-ES.md) - [Informazioa euskaraz](README.es-EU.md)
 ---
 ---
 
 
 
 
@@ -13,8 +12,8 @@ An iOS app intended for members of [Gasteizko Margolariak](https://margolariak.c
 This features will be only available during the city festivals.
 This features will be only available during the city festivals.
 
 
 * [TODO] Check out the festival schedule, discover events all around the city, and get their location.
 * [TODO] Check out the festival schedule, discover events all around the city, and get their location.
-* [TODO] Check out the schedule for the members of Gasteizko Margolariak, indicating the location of every event and activity...
-* [TODO] ... but, since we are not known for our puntuality, check out the location of Gasteizko Margolariak in real time.
+* Check out the schedule for the members of Gasteizko Margolariak, indicating the location of every event and activity...
+* ... but, since we are not known for our puntuality, check out the location of Gasteizko Margolariak in real time.
 * [TODO] Approximate distance to important event around the city.
 * [TODO] Approximate distance to important event around the city.
 
 
 
 

+ 4 - 0
app.xcodeproj/project.pbxproj

@@ -87,6 +87,7 @@
 		93E0C5EE1EBE25BD00905811 /* RowLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5ED1EBE25BC00905811 /* RowLabel.swift */; };
 		93E0C5EE1EBE25BD00905811 /* RowLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5ED1EBE25BC00905811 /* RowLabel.swift */; };
 		93E0C5F21EBE264F00905811 /* RowLabel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5F11EBE264F00905811 /* RowLabel.xib */; };
 		93E0C5F21EBE264F00905811 /* RowLabel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5F11EBE264F00905811 /* RowLabel.xib */; };
 		93E0C5F41EBE306900905811 /* ScheduleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5F31EBE306900905811 /* ScheduleViewController.swift */; };
 		93E0C5F41EBE306900905811 /* ScheduleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5F31EBE306900905811 /* ScheduleViewController.swift */; };
+		93E5058F1EEB0DCC00560B4A /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E5058E1EEB0DCC00560B4A /* PhotoViewController.swift */; };
 		93EB2F0C1EBF5AEB00F64186 /* RowSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */; };
 		93EB2F0C1EBF5AEB00F64186 /* RowSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */; };
 		93EB2F0E1EBF5BF500F64186 /* RowSchedule.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */; };
 		93EB2F0E1EBF5BF500F64186 /* RowSchedule.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */; };
 		93EE9ECB1EE9B87100288F6E /* PastActivityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EE9ECA1EE9B87100288F6E /* PastActivityViewController.swift */; };
 		93EE9ECB1EE9B87100288F6E /* PastActivityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EE9ECA1EE9B87100288F6E /* PastActivityViewController.swift */; };
@@ -176,6 +177,7 @@
 		93E0C5ED1EBE25BC00905811 /* RowLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowLabel.swift; sourceTree = "<group>"; };
 		93E0C5ED1EBE25BC00905811 /* RowLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowLabel.swift; sourceTree = "<group>"; };
 		93E0C5F11EBE264F00905811 /* RowLabel.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowLabel.xib; sourceTree = "<group>"; };
 		93E0C5F11EBE264F00905811 /* RowLabel.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowLabel.xib; sourceTree = "<group>"; };
 		93E0C5F31EBE306900905811 /* ScheduleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduleViewController.swift; sourceTree = "<group>"; };
 		93E0C5F31EBE306900905811 /* ScheduleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduleViewController.swift; sourceTree = "<group>"; };
+		93E5058E1EEB0DCC00560B4A /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; };
 		93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowSchedule.swift; sourceTree = "<group>"; };
 		93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowSchedule.swift; sourceTree = "<group>"; };
 		93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowSchedule.xib; sourceTree = "<group>"; };
 		93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowSchedule.xib; sourceTree = "<group>"; };
 		93EE9ECA1EE9B87100288F6E /* PastActivityViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PastActivityViewController.swift; sourceTree = "<group>"; };
 		93EE9ECA1EE9B87100288F6E /* PastActivityViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PastActivityViewController.swift; sourceTree = "<group>"; };
@@ -296,6 +298,7 @@
 				93D8B0971EF1B99A008BD946 /* RowItinerary.swift */,
 				93D8B0971EF1B99A008BD946 /* RowItinerary.swift */,
 				93D8B0991EF1BA03008BD946 /* RowItinerary.xib */,
 				93D8B0991EF1BA03008BD946 /* RowItinerary.xib */,
 				93D8B0951EF1B98E008BD946 /* FutureActivityViewController.swift */,
 				93D8B0951EF1B98E008BD946 /* FutureActivityViewController.swift */,
+				93E5058E1EEB0DCC00560B4A /* PhotoViewController.swift */,
 			);
 			);
 			path = app;
 			path = app;
 			sourceTree = "<group>";
 			sourceTree = "<group>";
@@ -446,6 +449,7 @@
 				93D9EA761DE3ACBB00089002 /* Sync.swift in Sources */,
 				93D9EA761DE3ACBB00089002 /* Sync.swift in Sources */,
 				93E0C5EA1EBDFFB400905811 /* RowPastActivity.swift in Sources */,
 				93E0C5EA1EBDFFB400905811 /* RowPastActivity.swift in Sources */,
 				93BAD2F41E585EE6009DF853 /* RowHomeFutureActivities.swift in Sources */,
 				93BAD2F41E585EE6009DF853 /* RowHomeFutureActivities.swift in Sources */,
+				93E5058F1EEB0DCC00560B4A /* PhotoViewController.swift in Sources */,
 				931AA5891E1AFF8C003A2290 /* String.swift in Sources */,
 				931AA5891E1AFF8C003A2290 /* String.swift in Sources */,
 				935AE18A1EC6138D0055E71F /* SyncController.swift in Sources */,
 				935AE18A1EC6138D0055E71F /* SyncController.swift in Sources */,
 				93B84B9C1D9C31AB006C0F67 /* ViewController.swift in Sources */,
 				93B84B9C1D9C31AB006C0F67 /* ViewController.swift in Sources */,

+ 0 - 1
app/ActivitiesView.swift

@@ -89,7 +89,6 @@ class ActivitiesView: UIView {
 		do {
 		do {
 			let searchResults = try self.context?.fetch(fetchRequest)
 			let searchResults = try self.context?.fetch(fetchRequest)
 			if searchResults?.count == 0{
 			if searchResults?.count == 0{
-				NSLog(":ACTIVITIES:DEBUG: No future activities: \(String(describing: searchResults?.count))")
 				let row: RowLabel = RowLabel.init(s: "rowFutureActivity0", i: 0)
 				let row: RowLabel = RowLabel.init(s: "rowFutureActivity0", i: 0)
 				row.setText(text: "No hay actividades planeadas proximamente. Pronto organizaremos algo!")
 				row.setText(text: "No hay actividades planeadas proximamente. Pronto organizaremos algo!")
 				self.futureList?.addArrangedSubview(row)
 				self.futureList?.addArrangedSubview(row)

+ 3 - 3
app/ActivitiesView.xib

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     </dependencies>
     <objects>
     <objects>
@@ -24,7 +24,7 @@
                 <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xyM-cc-W1r">
                 <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xyM-cc-W1r">
                     <rect key="frame" x="0.0" y="0.0" width="375" height="666"/>
                     <rect key="frame" x="0.0" y="0.0" width="375" height="666"/>
                     <subviews>
                     <subviews>
-                        <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="gvi-ij-s5Q">
+                        <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="gvi-ij-s5Q">
                             <rect key="frame" x="0.0" y="0.0" width="375" height="306"/>
                             <rect key="frame" x="0.0" y="0.0" width="375" height="306"/>
                             <subviews>
                             <subviews>
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jdf-74-tJS" customClass="Section" customModule="app">
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jdf-74-tJS" customClass="Section" customModule="app">

+ 56 - 4
app/AlbumViewController.swift

@@ -40,6 +40,7 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 	
 	
 	// Id received from segue.
 	// Id received from segue.
 	var passId: Int = -1
 	var passId: Int = -1
+	var passAlbum: Int = -1
 	
 	
 	
 	
 	/**
 	/**
@@ -61,6 +62,27 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		
 		
 		// Set button action
 		// Set button action
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+		
+		// Set this controller in the delegate
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.delegate?.albumController = self
+		
+		// Get album title
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
+		do {
+			let results = try context.fetch(fetchRequest)
+			let r = results[0]
+			let title: String = r.value(forKey: "title_\(lang)")! as! String
+			self.albumTitle.text = " \(title.decode().stripHtml())"
+		}
+		catch {
+			NSLog(":GALLERYCONTROLLER:ERROR: Error getting album info: \(error)")
+		}
 	}
 	}
 	
 	
 	
 	
@@ -102,14 +124,15 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
 			var image: String
 			var image: String
 			
 			
-			NSLog(":GALLERYCONTROLLER:DEBUG: Total photos: \(searchResults.count)")
-			
 			for i in (0..<searchResults.count) where i % 2 == 0 {
 			for i in (0..<searchResults.count) where i % 2 == 0 {
 				
 				
 				var r = searchResults[i]
 				var r = searchResults[i]
 				var photoId = r.value(forKey: "photo")! as! Int
 				var photoId = r.value(forKey: "photo")! as! Int
+				var leftId: Int = -1
+				var rightId: Int = -1
 				
 				
 				row = RowAlbum.init(s: "rowAlbum\(i)", i: i)
 				row = RowAlbum.init(s: "rowAlbum\(i)", i: i)
+				row.id = id
 				
 				
 				// Get photo info from Photo entity
 				// Get photo info from Photo entity
 				let imgFetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
 				let imgFetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
@@ -122,17 +145,20 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 					var imgSearchResults = try context.fetch(imgFetchRequest)
 					var imgSearchResults = try context.fetch(imgFetchRequest)
 					var imgR = imgSearchResults[0]
 					var imgR = imgSearchResults[0]
 					image = imgR.value(forKey: "file")! as! String
 					image = imgR.value(forKey: "file")! as! String
+					leftId = imgR.value(forKey: "id")! as! Int
 					NSLog(":GALLERYCONTROLLER:LOG: Image Row \(i) left: \(image)")
 					NSLog(":GALLERYCONTROLLER:LOG: Image Row \(i) left: \(image)")
 					row.setImage(idx: 0, filename: image)
 					row.setImage(idx: 0, filename: image)
 					if i + 1 < searchResults.count {
 					if i + 1 < searchResults.count {
 						r = searchResults[i + 1]
 						r = searchResults[i + 1]
 						photoId = r.value(forKey: "photo")! as! Int
 						photoId = r.value(forKey: "photo")! as! Int
+						
 						imgFetchRequest.predicate = NSPredicate(format: "id == %i", photoId)
 						imgFetchRequest.predicate = NSPredicate(format: "id == %i", photoId)
 						imgSearchResults = try context.fetch(imgFetchRequest)
 						imgSearchResults = try context.fetch(imgFetchRequest)
 						
 						
 						
 						
 						imgR = imgSearchResults[0]
 						imgR = imgSearchResults[0]
 						image = imgR.value(forKey: "file")! as! String
 						image = imgR.value(forKey: "file")! as! String
+						rightId = imgR.value(forKey: "id")! as! Int
 						NSLog(":GALLERYCONTROLLER:LOG: Image Row \(i) right: \(image)")
 						NSLog(":GALLERYCONTROLLER:LOG: Image Row \(i) right: \(image)")
 						row.setImage(idx: 1, filename: image)
 						row.setImage(idx: 1, filename: image)
 					}
 					}
@@ -145,12 +171,13 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 					NSLog(":GALLERYCONTROLLER:ERROR: Error getting image for post \(id): \(error)")
 					NSLog(":GALLERYCONTROLLER:ERROR: Error getting image for post \(id): \(error)")
 				}
 				}
 				
 				
-				NSLog(":GALLERYCONTROLLER:DEBUG: Adding row: height: \(row.frame.height)")
+				row.setIds(left: leftId, right: rightId)
 				albumContainer.addArrangedSubview(row)
 				albumContainer.addArrangedSubview(row)
 				
 				
 				rowcount = rowcount + 1
 				rowcount = rowcount + 1
 			}
 			}
-		} catch {
+		}
+		catch {
 			NSLog(":GALLERYCONTROLLER:ERROR: Error with request: \(error)")
 			NSLog(":GALLERYCONTROLLER:ERROR: Error with request: \(error)")
 		}
 		}
 	}
 	}
@@ -171,5 +198,30 @@ class AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
 		}
 		}
 	}
 	}
 	
 	
+	
+	/**
+	Run before performing a segue.
+	Assigns id if neccessary.
+	:param: segue The segue to perform.
+	:sender: The calling view.
+	*/
+	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+		if segue.identifier == "SeguePhotoAlbum"{
+			(segue.destination as! PhotoViewController).albumId = passAlbum
+			(segue.destination as! PhotoViewController).photoId = passId
+		}
+	}
+	
+	
+	/**
+	Shows a photo.
+	:param: id The album id.
+	*/
+	func showPhoto(album: Int, photo: Int){
+		self.passAlbum = album
+		self.passId = photo
+		performSegue(withIdentifier: "SeguePhotoAlbum", sender: nil)
+	}
+	
 }
 }
 
 

+ 1 - 0
app/AppDelegate.swift

@@ -27,6 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
 
 	var window: UIWindow?
 	var window: UIWindow?
 	var controller: ViewController?
 	var controller: ViewController?
+	var albumController: AlbumViewController?
 
 
 	
 	
 	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
 	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

+ 220 - 10
app/Base.lproj/Main.storyboard

@@ -85,12 +85,12 @@
                                                         <constraint firstAttribute="width" constant="100" id="eKL-ga-53F"/>
                                                         <constraint firstAttribute="width" constant="100" id="eKL-ga-53F"/>
                                                     </constraints>
                                                     </constraints>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                    <color key="textColor" red="0.78431372549019607" green="0.78431372549019607" blue="0.78431372549019607" alpha="1" colorSpace="calibratedRGB"/>
                                                     <nil key="highlightedColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 </label>
                                                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZNu-9N-o6K">
                                                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZNu-9N-o6K">
                                                     <rect key="frame" x="4" y="38" width="92" height="4"/>
                                                     <rect key="frame" x="4" y="38" width="92" height="4"/>
-                                                    <color key="backgroundColor" red="0.80000000000000004" green="0.80000000000000004" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                    <color key="backgroundColor" red="0.3529411764705882" green="0.70588235294117641" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                                                     <constraints>
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="4" id="Si5-HX-bjR"/>
                                                         <constraint firstAttribute="height" constant="4" id="Si5-HX-bjR"/>
                                                     </constraints>
                                                     </constraints>
@@ -201,6 +201,7 @@
                         <segue destination="3o1-ab-AT4" kind="show" identifier="SegueSync" id="E96-mK-gE9"/>
                         <segue destination="3o1-ab-AT4" kind="show" identifier="SegueSync" id="E96-mK-gE9"/>
                         <segue destination="jfx-Q2-RtY" kind="show" identifier="SeguePastActivity" id="MmG-k2-wHn"/>
                         <segue destination="jfx-Q2-RtY" kind="show" identifier="SeguePastActivity" id="MmG-k2-wHn"/>
                         <segue destination="DDO-dI-c0J" kind="show" identifier="SegueFutureActivity" id="ec7-aO-4Ac"/>
                         <segue destination="DDO-dI-c0J" kind="show" identifier="SegueFutureActivity" id="ec7-aO-4Ac"/>
+                        <segue destination="hRA-2q-Tv9" kind="show" identifier="SeguePhoto" id="XIb-zK-EYd"/>
                     </connections>
                     </connections>
                 </viewController>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
@@ -382,13 +383,13 @@
                                                                 <rect key="frame" x="8" y="8" width="339" height="949"/>
                                                                 <rect key="frame" x="8" y="8" width="339" height="949"/>
                                                                 <subviews>
                                                                 <subviews>
                                                                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="u3M-mi-Tyn" userLabel="Image">
                                                                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="u3M-mi-Tyn" userLabel="Image">
-                                                                        <rect key="frame" x="0.0" y="10" width="339" height="71"/>
+                                                                        <rect key="frame" x="10" y="10" width="319" height="180"/>
                                                                         <constraints>
                                                                         <constraints>
-                                                                            <constraint firstAttribute="height" constant="71" id="fQp-wR-eLU"/>
+                                                                            <constraint firstAttribute="height" constant="180" id="fQp-wR-eLU"/>
                                                                         </constraints>
                                                                         </constraints>
                                                                     </imageView>
                                                                     </imageView>
                                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2i2-HF-HyI" userLabel="Text">
                                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2i2-HF-HyI" userLabel="Text">
-                                                                        <rect key="frame" x="17" y="91" width="305.5" height="826"/>
+                                                                        <rect key="frame" x="17" y="200" width="305.5" height="717"/>
                                                                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                                         <nil key="textColor"/>
                                                                         <nil key="textColor"/>
                                                                         <nil key="highlightedColor"/>
                                                                         <nil key="highlightedColor"/>
@@ -412,7 +413,7 @@
                                                                 </subviews>
                                                                 </subviews>
                                                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                                                 <constraints>
                                                                 <constraints>
-                                                                    <constraint firstItem="u3M-mi-Tyn" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" id="4ZF-fF-btB"/>
+                                                                    <constraint firstItem="u3M-mi-Tyn" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" constant="-20" id="4ZF-fF-btB"/>
                                                                     <constraint firstItem="tAc-xa-mg2" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="Bf4-vV-UnB"/>
                                                                     <constraint firstItem="tAc-xa-mg2" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="Bf4-vV-UnB"/>
                                                                     <constraint firstItem="pX4-mq-dj0" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" multiplier="0.9" id="Dqr-hS-PV9"/>
                                                                     <constraint firstItem="pX4-mq-dj0" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" multiplier="0.9" id="Dqr-hS-PV9"/>
                                                                     <constraint firstItem="2i2-HF-HyI" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="Hoe-4Q-YTi"/>
                                                                     <constraint firstItem="2i2-HF-HyI" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="Hoe-4Q-YTi"/>
@@ -697,6 +698,7 @@
                         <outlet property="albumView" destination="YEF-04-q7Y" id="7tR-Lr-9nh"/>
                         <outlet property="albumView" destination="YEF-04-q7Y" id="7tR-Lr-9nh"/>
                         <outlet property="barButton" destination="Thj-0t-rxK" id="6bX-xo-abt"/>
                         <outlet property="barButton" destination="Thj-0t-rxK" id="6bX-xo-abt"/>
                         <outlet property="barTitle" destination="LLe-aQ-Sbj" id="bFR-jT-Xmq"/>
                         <outlet property="barTitle" destination="LLe-aQ-Sbj" id="bFR-jT-Xmq"/>
+                        <segue destination="hRA-2q-Tv9" kind="show" identifier="SeguePhotoAlbum" id="ftR-BO-YPe"/>
                     </connections>
                     </connections>
                 </viewController>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="GLj-OZ-Cqc" userLabel="First Responder" sceneMemberID="firstResponder"/>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="GLj-OZ-Cqc" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -1101,13 +1103,13 @@
                                                                 <rect key="frame" x="8" y="8" width="339" height="949"/>
                                                                 <rect key="frame" x="8" y="8" width="339" height="949"/>
                                                                 <subviews>
                                                                 <subviews>
                                                                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="8Jn-h7-TSJ" userLabel="Image">
                                                                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="8Jn-h7-TSJ" userLabel="Image">
-                                                                        <rect key="frame" x="0.0" y="10" width="339" height="71"/>
+                                                                        <rect key="frame" x="10" y="10" width="319" height="180"/>
                                                                         <constraints>
                                                                         <constraints>
-                                                                            <constraint firstAttribute="height" constant="71" id="lZg-2O-4LP"/>
+                                                                            <constraint firstAttribute="height" constant="180" id="lZg-2O-4LP"/>
                                                                         </constraints>
                                                                         </constraints>
                                                                     </imageView>
                                                                     </imageView>
                                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Usd-Rm-Tq2" userLabel="Text">
                                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Usd-Rm-Tq2" userLabel="Text">
-                                                                        <rect key="frame" x="17" y="91" width="305.5" height="826"/>
+                                                                        <rect key="frame" x="17" y="200" width="305.5" height="717"/>
                                                                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                                         <nil key="textColor"/>
                                                                         <nil key="textColor"/>
                                                                         <nil key="highlightedColor"/>
                                                                         <nil key="highlightedColor"/>
@@ -1140,7 +1142,7 @@
                                                                     <constraint firstItem="Usd-Rm-Tq2" firstAttribute="centerX" secondItem="Omg-cP-uvF" secondAttribute="centerX" id="SHM-nk-s9u"/>
                                                                     <constraint firstItem="Usd-Rm-Tq2" firstAttribute="centerX" secondItem="Omg-cP-uvF" secondAttribute="centerX" id="SHM-nk-s9u"/>
                                                                     <constraint firstItem="dvg-B2-xmI" firstAttribute="centerX" secondItem="Omg-cP-uvF" secondAttribute="centerX" id="XBR-sR-Yqg"/>
                                                                     <constraint firstItem="dvg-B2-xmI" firstAttribute="centerX" secondItem="Omg-cP-uvF" secondAttribute="centerX" id="XBR-sR-Yqg"/>
                                                                     <constraint firstItem="LmH-0o-Hku" firstAttribute="centerX" secondItem="Omg-cP-uvF" secondAttribute="centerX" id="a8v-br-EaA"/>
                                                                     <constraint firstItem="LmH-0o-Hku" firstAttribute="centerX" secondItem="Omg-cP-uvF" secondAttribute="centerX" id="a8v-br-EaA"/>
-                                                                    <constraint firstItem="8Jn-h7-TSJ" firstAttribute="width" secondItem="Omg-cP-uvF" secondAttribute="width" id="gm5-CU-FKw"/>
+                                                                    <constraint firstItem="8Jn-h7-TSJ" firstAttribute="width" secondItem="Omg-cP-uvF" secondAttribute="width" constant="-20" id="gm5-CU-FKw"/>
                                                                     <constraint firstItem="8Jn-h7-TSJ" firstAttribute="top" secondItem="Omg-cP-uvF" secondAttribute="top" constant="10" id="js6-Fg-pg1"/>
                                                                     <constraint firstItem="8Jn-h7-TSJ" firstAttribute="top" secondItem="Omg-cP-uvF" secondAttribute="top" constant="10" id="js6-Fg-pg1"/>
                                                                     <constraint firstAttribute="bottom" secondItem="dvg-B2-xmI" secondAttribute="bottom" id="lta-H9-CYI"/>
                                                                     <constraint firstAttribute="bottom" secondItem="dvg-B2-xmI" secondAttribute="bottom" id="lta-H9-CYI"/>
                                                                     <constraint firstItem="LmH-0o-Hku" firstAttribute="width" secondItem="Omg-cP-uvF" secondAttribute="width" multiplier="0.9" id="xmH-tU-ZFp"/>
                                                                     <constraint firstItem="LmH-0o-Hku" firstAttribute="width" secondItem="Omg-cP-uvF" secondAttribute="width" multiplier="0.9" id="xmH-tU-ZFp"/>
@@ -1256,6 +1258,22 @@
                                 <rect key="frame" x="0.0" y="20" width="375" height="30"/>
                                 <rect key="frame" x="0.0" y="20" width="375" height="30"/>
                                 <subviews>
                                 <subviews>
                                     <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FiC-sd-IGL">
                                     <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FiC-sd-IGL">
+        <!--Photo-->
+        <scene sceneID="Qxt-8f-I5l">
+            <objects>
+                <viewController title="Photo" id="hRA-2q-Tv9" customClass="PhotoViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="iD5-7d-BcL"/>
+                        <viewControllerLayoutGuide type="bottom" id="UVa-jE-Gqw"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="zXb-Ja-8dX" userLabel="Container">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XUY-te-9PN" userLabel="Toolbar">
+                                <rect key="frame" x="0.0" y="20" width="375" height="30"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4tx-eL-rur">
                                         <rect key="frame" x="0.0" y="0.0" width="56.5" height="30"/>
                                         <rect key="frame" x="0.0" y="0.0" width="56.5" height="30"/>
                                         <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                         <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                                         <state key="normal" title="&lt;">
                                         <state key="normal" title="&lt;">
@@ -1263,6 +1281,7 @@
                                         </state>
                                         </state>
                                     </button>
                                     </button>
                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Gasteizko Margolariak" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="v7W-BZ-qle">
                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Gasteizko Margolariak" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="v7W-BZ-qle">
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Gasteizko Margolariak" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ifO-mU-TPV">
                                         <rect key="frame" x="56.5" y="0.0" width="262.5" height="30"/>
                                         <rect key="frame" x="56.5" y="0.0" width="262.5" height="30"/>
                                         <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
                                         <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
                                         <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                         <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -1456,6 +1475,172 @@
                                     <constraint firstItem="Gqf-Sj-1VO" firstAttribute="centerX" secondItem="Sqd-hf-hGI" secondAttribute="centerX" id="bTt-jg-jEg"/>
                                     <constraint firstItem="Gqf-Sj-1VO" firstAttribute="centerX" secondItem="Sqd-hf-hGI" secondAttribute="centerX" id="bTt-jg-jEg"/>
                                     <constraint firstItem="Gqf-Sj-1VO" firstAttribute="top" secondItem="Sqd-hf-hGI" secondAttribute="top" id="wgm-EO-9Fw"/>
                                     <constraint firstItem="Gqf-Sj-1VO" firstAttribute="top" secondItem="Sqd-hf-hGI" secondAttribute="top" id="wgm-EO-9Fw"/>
                                     <constraint firstAttribute="bottom" secondItem="Gqf-Sj-1VO" secondAttribute="bottom" id="zBV-o0-Ah0"/>
                                     <constraint firstAttribute="bottom" secondItem="Gqf-Sj-1VO" secondAttribute="bottom" id="zBV-o0-Ah0"/>
+=======
+                                    <constraint firstItem="4tx-eL-rur" firstAttribute="centerY" secondItem="XUY-te-9PN" secondAttribute="centerY" id="AgA-QN-AMl"/>
+                                    <constraint firstItem="4tx-eL-rur" firstAttribute="width" secondItem="XUY-te-9PN" secondAttribute="width" multiplier="0.15" id="C5z-S4-EpK"/>
+                                    <constraint firstItem="ifO-mU-TPV" firstAttribute="centerY" secondItem="XUY-te-9PN" secondAttribute="centerY" id="DDx-b3-3ds"/>
+                                    <constraint firstItem="4tx-eL-rur" firstAttribute="leading" secondItem="XUY-te-9PN" secondAttribute="leading" id="W4J-mY-EF9"/>
+                                    <constraint firstItem="ifO-mU-TPV" firstAttribute="height" secondItem="XUY-te-9PN" secondAttribute="height" id="aKD-k3-Rn6"/>
+                                    <constraint firstItem="4tx-eL-rur" firstAttribute="height" secondItem="XUY-te-9PN" secondAttribute="height" id="msK-d2-NhX"/>
+                                    <constraint firstItem="ifO-mU-TPV" firstAttribute="centerX" secondItem="XUY-te-9PN" secondAttribute="centerX" id="r98-kb-UcD"/>
+                                    <constraint firstItem="ifO-mU-TPV" firstAttribute="width" secondItem="XUY-te-9PN" secondAttribute="width" multiplier="0.7" id="stn-gW-qHw"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dh0-OE-3US">
+                                <rect key="frame" x="0.0" y="50" width="375" height="617"/>
+                                <subviews>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bqh-wV-GNf" userLabel="Section">
+                                        <rect key="frame" x="10" y="10" width="355" height="597"/>
+                                        <subviews>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="Title" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="esM-2C-p2i" userLabel="Title">
+                                                <rect key="frame" x="0.0" y="0.0" width="355" height="30"/>
+                                                <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="30" id="RzN-hZ-tOL"/>
+                                                </constraints>
+                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
+                                                <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="78P-mw-WXM" userLabel="Content">
+                                                <rect key="frame" x="0.0" y="30" width="355" height="567"/>
+                                                <subviews>
+                                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jIN-Yy-3GU" userLabel="Photo">
+                                                        <rect key="frame" x="8" y="8" width="339" height="551"/>
+                                                        <subviews>
+                                                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="2wg-l8-Thi" userLabel="Image">
+                                                                <rect key="frame" x="10" y="10" width="319" height="413.5"/>
+                                                                <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                                                                <userDefinedRuntimeAttributes>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                                        <real key="value" value="2"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                                        <color key="value" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                                        <real key="value" value="4"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                </userDefinedRuntimeAttributes>
+                                                            </imageView>
+                                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="254" text="Date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vhb-gI-4I7" userLabel="Date">
+                                                                <rect key="frame" x="10.5" y="461" width="319" height="20"/>
+                                                                <constraints>
+                                                                    <constraint firstAttribute="height" constant="20" id="fXM-sB-Ii7"/>
+                                                                </constraints>
+                                                                <fontDescription key="fontDescription" type="italicSystem" pointSize="16"/>
+                                                                <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
+                                                                <nil key="highlightedColor"/>
+                                                            </label>
+                                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jcy-kv-ggg">
+                                                                <rect key="frame" x="10" y="501" width="149.5" height="40"/>
+                                                                <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
+                                                                <constraints>
+                                                                    <constraint firstAttribute="height" constant="40" id="voU-YV-2ln"/>
+                                                                </constraints>
+                                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                                                                <state key="normal" title="&lt;">
+                                                                    <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                                </state>
+                                                                <userDefinedRuntimeAttributes>
+                                                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                                        <color key="value" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                                        <real key="value" value="2"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                                        <real key="value" value="4"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                </userDefinedRuntimeAttributes>
+                                                            </button>
+                                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HOD-9J-wQK">
+                                                                <rect key="frame" x="179.5" y="501" width="149.5" height="40"/>
+                                                                <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
+                                                                <constraints>
+                                                                    <constraint firstAttribute="height" constant="40" id="6oc-MW-3JE"/>
+                                                                </constraints>
+                                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                                                                <state key="normal" title="&gt;">
+                                                                    <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                                </state>
+                                                                <userDefinedRuntimeAttributes>
+                                                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                                        <color key="value" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                                        <real key="value" value="2"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                                        <real key="value" value="4"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                </userDefinedRuntimeAttributes>
+                                                            </button>
+                                                        </subviews>
+                                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                        <constraints>
+                                                            <constraint firstItem="2wg-l8-Thi" firstAttribute="top" secondItem="jIN-Yy-3GU" secondAttribute="top" constant="10" id="D28-DF-HF9"/>
+                                                            <constraint firstAttribute="bottom" secondItem="Jcy-kv-ggg" secondAttribute="bottom" constant="10" id="HPg-ft-VEj"/>
+                                                            <constraint firstItem="2wg-l8-Thi" firstAttribute="centerX" secondItem="jIN-Yy-3GU" secondAttribute="centerX" id="KoA-A3-Ygf"/>
+                                                            <constraint firstItem="Vhb-gI-4I7" firstAttribute="bottom" secondItem="HOD-9J-wQK" secondAttribute="top" constant="-20" id="NVj-fY-b6d"/>
+                                                            <constraint firstAttribute="trailing" secondItem="HOD-9J-wQK" secondAttribute="trailing" constant="10" id="can-PT-Neg"/>
+                                                            <constraint firstAttribute="bottom" secondItem="HOD-9J-wQK" secondAttribute="bottom" constant="10" id="dsJ-0z-vOa"/>
+                                                            <constraint firstItem="Vhb-gI-4I7" firstAttribute="width" secondItem="jIN-Yy-3GU" secondAttribute="width" constant="-20" id="geF-9Y-pxJ"/>
+                                                            <constraint firstItem="Jcy-kv-ggg" firstAttribute="leading" secondItem="jIN-Yy-3GU" secondAttribute="leading" constant="10" id="grR-FP-FE3"/>
+                                                            <constraint firstItem="Vhb-gI-4I7" firstAttribute="centerX" secondItem="jIN-Yy-3GU" secondAttribute="centerX" id="hDr-cv-Tma"/>
+                                                            <constraint firstItem="HOD-9J-wQK" firstAttribute="width" secondItem="jIN-Yy-3GU" secondAttribute="width" multiplier="0.5" constant="-20" id="pQ0-vJ-Uv1"/>
+                                                            <constraint firstItem="Jcy-kv-ggg" firstAttribute="width" secondItem="jIN-Yy-3GU" secondAttribute="width" multiplier="0.5" constant="-20" id="rnQ-m4-XQ0"/>
+                                                            <constraint firstItem="2wg-l8-Thi" firstAttribute="height" secondItem="jIN-Yy-3GU" secondAttribute="height" multiplier="0.75" id="vhz-lJ-2fm"/>
+                                                            <constraint firstItem="2wg-l8-Thi" firstAttribute="width" secondItem="jIN-Yy-3GU" secondAttribute="width" constant="-20" id="wQB-Hs-vSs"/>
+                                                        </constraints>
+                                                        <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                                        <userDefinedRuntimeAttributes>
+                                                            <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                                <color key="value" red="0.42745098040000001" green="0.41176470590000003" blue="0.56470588239999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                            </userDefinedRuntimeAttribute>
+                                                            <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                                <real key="value" value="1"/>
+                                                            </userDefinedRuntimeAttribute>
+                                                            <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                                <real key="value" value="3"/>
+                                                            </userDefinedRuntimeAttribute>
+                                                        </userDefinedRuntimeAttributes>
+                                                    </view>
+                                                </subviews>
+                                                <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                            </stackView>
+                                        </subviews>
+                                        <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                        <constraints>
+                                            <constraint firstAttribute="bottom" secondItem="78P-mw-WXM" secondAttribute="bottom" id="JdO-O4-mee"/>
+                                            <constraint firstItem="esM-2C-p2i" firstAttribute="top" secondItem="bqh-wV-GNf" secondAttribute="top" id="KOQ-eg-hXm"/>
+                                            <constraint firstItem="78P-mw-WXM" firstAttribute="width" secondItem="bqh-wV-GNf" secondAttribute="width" id="PpI-M2-bDk"/>
+                                            <constraint firstItem="78P-mw-WXM" firstAttribute="centerX" secondItem="bqh-wV-GNf" secondAttribute="centerX" id="bEw-TV-GOh"/>
+                                            <constraint firstItem="78P-mw-WXM" firstAttribute="top" secondItem="esM-2C-p2i" secondAttribute="bottom" id="muK-Pd-v3M"/>
+                                            <constraint firstItem="esM-2C-p2i" firstAttribute="width" secondItem="bqh-wV-GNf" secondAttribute="width" id="vEo-Fa-qdK"/>
+                                            <constraint firstItem="esM-2C-p2i" firstAttribute="centerX" secondItem="bqh-wV-GNf" secondAttribute="centerX" id="zPh-03-gDc"/>
+                                        </constraints>
+                                        <edgeInsets key="layoutMargins" top="10" left="10" bottom="10" right="10"/>
+                                        <userDefinedRuntimeAttributes>
+                                            <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                <color key="value" red="0.0" green="0.0" blue="0.066666666669999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                            </userDefinedRuntimeAttribute>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                <real key="value" value="1"/>
+                                            </userDefinedRuntimeAttribute>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                <real key="value" value="8"/>
+                                            </userDefinedRuntimeAttribute>
+                                        </userDefinedRuntimeAttributes>
+                                    </view>
+                                </subviews>
+                                <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <constraints>
+                                    <constraint firstItem="bqh-wV-GNf" firstAttribute="width" secondItem="dh0-OE-3US" secondAttribute="width" constant="-20" id="8a3-am-7Ch"/>
+                                    <constraint firstItem="bqh-wV-GNf" firstAttribute="height" secondItem="dh0-OE-3US" secondAttribute="height" constant="-20" id="Tgd-YQ-aEQ"/>
+                                    <constraint firstItem="bqh-wV-GNf" firstAttribute="centerY" secondItem="dh0-OE-3US" secondAttribute="centerY" id="U2v-3X-Ub1"/>
+                                    <constraint firstItem="bqh-wV-GNf" firstAttribute="centerX" secondItem="dh0-OE-3US" secondAttribute="centerX" id="eI3-vW-bvZ"/>
                                 </constraints>
                                 </constraints>
                                 <userDefinedRuntimeAttributes>
                                 <userDefinedRuntimeAttributes>
                                     <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
                                     <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
@@ -1490,6 +1675,28 @@
                 <placeholder placeholderIdentifier="IBFirstResponder" id="IHt-fO-2Q0" userLabel="First Responder" sceneMemberID="firstResponder"/>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="IHt-fO-2Q0" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
             </objects>
             <point key="canvasLocation" x="1302" y="-403"/>
             <point key="canvasLocation" x="1302" y="-403"/>
+=======
+                            <constraint firstItem="XUY-te-9PN" firstAttribute="width" secondItem="zXb-Ja-8dX" secondAttribute="width" id="1gg-3z-VTT"/>
+                            <constraint firstItem="XUY-te-9PN" firstAttribute="top" secondItem="iD5-7d-BcL" secondAttribute="bottom" id="6xm-50-tbJ"/>
+                            <constraint firstItem="dh0-OE-3US" firstAttribute="top" secondItem="XUY-te-9PN" secondAttribute="bottom" id="Cwk-RG-Bdj"/>
+                            <constraint firstItem="dh0-OE-3US" firstAttribute="centerX" secondItem="zXb-Ja-8dX" secondAttribute="centerX" id="FEt-9c-pvb"/>
+                            <constraint firstItem="dh0-OE-3US" firstAttribute="width" secondItem="zXb-Ja-8dX" secondAttribute="width" id="MlH-pm-QQM"/>
+                            <constraint firstItem="XUY-te-9PN" firstAttribute="centerX" secondItem="zXb-Ja-8dX" secondAttribute="centerX" id="vfQ-Yn-21i"/>
+                            <constraint firstItem="UVa-jE-Gqw" firstAttribute="top" secondItem="dh0-OE-3US" secondAttribute="bottom" id="w47-kr-EXB"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="barButton" destination="4tx-eL-rur" id="fAC-j7-Kuv"/>
+                        <outlet property="barTitle" destination="ifO-mU-TPV" id="Yba-nJ-MyQ"/>
+                        <outlet property="btNext" destination="HOD-9J-wQK" id="mc4-j1-seA"/>
+                        <outlet property="btPrev" destination="Jcy-kv-ggg" id="L1Q-2X-H43"/>
+                        <outlet property="photoDate" destination="Vhb-gI-4I7" id="pyP-a1-Iz7"/>
+                        <outlet property="photoImage" destination="2wg-l8-Thi" id="xgu-JA-6Zs"/>
+                        <outlet property="photoTitle" destination="esM-2C-p2i" id="ev5-QE-lS6"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="jtA-t8-aan" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
         </scene>
         </scene>
     </scenes>
     </scenes>
     <resources>
     <resources>
@@ -1497,4 +1704,7 @@
         <image name="Logo" width="83" height="83"/>
         <image name="Logo" width="83" height="83"/>
         <image name="PhotoPlaceholder" width="170" height="108"/>
         <image name="PhotoPlaceholder" width="170" height="108"/>
     </resources>
     </resources>
+    <inferredMetricsTieBreakers>
+        <segue reference="ftR-BO-YPe"/>
+    </inferredMetricsTieBreakers>
 </document>
 </document>

+ 11 - 35
app/BlogView.swift

@@ -60,19 +60,18 @@ class BlogView: UIView {
 		
 		
 		// Get viewController from StoryBoard
 		// Get viewController from StoryBoard
 		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
 		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
-		self.controller = storyboard?.instantiateViewController(withIdentifier: "GMViewController") as? ViewController
+		self.controller = storyboard?.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
 		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
-		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.delegate = UIApplication.shared.delegate as! AppDelegate
 		self.lang = getLanguage()
 		self.lang = getLanguage()
 		self.context?.persistentStoreCoordinator = delegate?.persistentStoreCoordinator
 		self.context?.persistentStoreCoordinator = delegate?.persistentStoreCoordinator
 		
 		
 		populate()
 		populate()
-		
 	}
 	}
 	
 	
 	
 	
 	/**
 	/**
-	Populates the section.
+	Actually populates the section.
 	*/
 	*/
 	func populate(){
 	func populate(){
 		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
 		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
@@ -87,18 +86,17 @@ class BlogView: UIView {
 			}
 			}
 			
 			
 			// Get the results
 			// Get the results
-			let searchResults = try self.context?.fetch(fetchRequest)			
+			let searchResults = try self.context?.fetch(fetchRequest)
 			
 			
+			var count: Int = 0
 			var row : RowBlog
 			var row : RowBlog
-			var count = 0
 			var id: Int
 			var id: Int
 			var title: String
 			var title: String
 			var text: String
 			var text: String
 			var image: String
 			var image: String
 			
 			
-			for r in searchResults! {
-				count = count + 1
-				
+			for r in searchResults as! [NSManagedObject] {
+								
 				//Create a new row
 				//Create a new row
 				row = RowBlog.init(s: "rowBlog\(count)", i: count)
 				row = RowBlog.init(s: "rowBlog\(count)", i: count)
 				id = r.value(forKey: "id")! as! Int
 				id = r.value(forKey: "id")! as! Int
@@ -106,6 +104,7 @@ class BlogView: UIView {
 				text = r.value(forKey: "text_\(lang!)")! as! String
 				text = r.value(forKey: "text_\(lang!)")! as! String
 				row.setTitle(text: title)
 				row.setTitle(text: title)
 				row.setText(text: text)
 				row.setText(text: text)
+				row.id = id
 				
 				
 				// Get main image
 				// Get main image
 				image = ""
 				image = ""
@@ -117,7 +116,7 @@ class BlogView: UIView {
 				imgFetchRequest.fetchLimit = 1
 				imgFetchRequest.fetchLimit = 1
 				do{
 				do{
 					let imgSearchResults = try context?.fetch(imgFetchRequest)
 					let imgSearchResults = try context?.fetch(imgFetchRequest)
-					for imgR in imgSearchResults!{
+					for imgR in imgSearchResults as! [NSManagedObject]{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
 						row.setImage(filename: image)
 						row.setImage(filename: image)
 					}
 					}
@@ -127,13 +126,7 @@ class BlogView: UIView {
 				
 				
 				
 				
 				self.postList?.addArrangedSubview(row)
 				self.postList?.addArrangedSubview(row)
-				
-				// TODO: Do this on the row didLoad method
-				// Set tap recognizer
-				//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
-				//row.isUserInteractionEnabled = true
-				//row.addGestureRecognizer(tapRecognizer)
-				
+				count = count + 1
 			}
 			}
 
 
 			// Trigger a layout update
 			// Trigger a layout update
@@ -143,25 +136,8 @@ class BlogView: UIView {
 		} catch {
 		} catch {
 			NSLog(":BLOG:ERROR: Error with request: \(error)")
 			NSLog(":BLOG:ERROR: Error with request: \(error)")
 		}
 		}
-		NSLog(":BLOG:DEBUG: Finished populating BlogView")
 	}
 	}
-	
-	
-	/*func openPost(){//(_ sender:UITapGestureRecognizer? = nil){
-		print("BLOG:DEBUG: getting delegate and showing post.")
-		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		delegate.controller?.showPost(id: 4)
-		
-	print("BLOG:DEBUG: Post should be shown.")
-	}
-	
-	func openPost(_ sender:UITapGestureRecognizer? = nil){
-		print("BLOG:DEBUG: getting delegate and showing post.")
-		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		delegate.controller?.showPost(id: 4)
-		print("BLOG:DEBUG: Post should be shown.")
-	}*/
-	
+
 	
 	
 	/**
 	/**
 	Gets the device language. The only recognized languages are Spanish, English and Basque.
 	Gets the device language. The only recognized languages are Spanish, English and Basque.

+ 0 - 1
app/FetchLocation.swift

@@ -50,7 +50,6 @@ class FetchLocation{
 			if status == 200{
 			if status == 200{
 			
 			
 				guard let data = data else {
 				guard let data = data else {
-					NSLog(":LOCATION:DEBUG: No data received.")
 					return
 					return
 				}
 				}
 
 

+ 1 - 3
app/GalleryView.swift

@@ -73,7 +73,7 @@ class GalleryView: UIView {
 		let lang : String = getLanguage()
 		let lang : String = getLanguage()
 		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
 		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
 		let fetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
-		let sortDescriptor = NSSortDescriptor(key: "time", ascending: false)
+		let sortDescriptor = NSSortDescriptor(key: "id", ascending: false)
 		let sortDescriptors = [sortDescriptor]
 		let sortDescriptors = [sortDescriptor]
 		fetchRequest.sortDescriptors = sortDescriptors
 		fetchRequest.sortDescriptors = sortDescriptors
 		
 		
@@ -164,7 +164,6 @@ class GalleryView: UIView {
 	*/
 	*/
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 		let id = (sender?.view as! RowGallery).id
 		let id = (sender?.view as! RowGallery).id
-		NSLog(":GALLERY:DEBUG: getting delegate and showing album \(id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showAlbum(id: id)
 		delegate.controller?.showAlbum(id: id)
 	}
 	}
@@ -190,7 +189,6 @@ class GalleryView: UIView {
 	Handles the click events to open albums.
 	Handles the click events to open albums.
 	*/
 	*/
 	func setUpRowsTapRecognizers(){
 	func setUpRowsTapRecognizers(){
-		NSLog(":GALLERY:DEBUG: Setting up tap recognizers")
 		for row in self.rows{
 		for row in self.rows{
 			let tapRecognizer = UITapGestureRecognizer(target: row, action: #selector(openAlbum(_:)))
 			let tapRecognizer = UITapGestureRecognizer(target: row, action: #selector(openAlbum(_:)))
 			row.isUserInteractionEnabled = true
 			row.isUserInteractionEnabled = true

+ 251 - 56
app/HomeView.swift

@@ -29,9 +29,12 @@ class HomeView: UIView {
 	// Outlets
 	// Outlets
 	@IBOutlet weak var scrollView: UIScrollView!
 	@IBOutlet weak var scrollView: UIScrollView!
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
+	@IBOutlet weak var locationMessage: UILabel!
+	@IBOutlet weak var lablancaImage: UIImageView!
+	@IBOutlet weak var lablancaText: UILabel!
 	
 	
 	//Each of the sections of the view.
 	//Each of the sections of the view.
-	@IBOutlet weak var locationSection: Section!
+	@IBOutlet weak var locationSection: UIView!
 	@IBOutlet weak var lablancaSection: Section!
 	@IBOutlet weak var lablancaSection: Section!
 	@IBOutlet weak var futureActivitiesSection: Section!
 	@IBOutlet weak var futureActivitiesSection: Section!
 	@IBOutlet weak var blogSection: Section!
 	@IBOutlet weak var blogSection: Section!
@@ -42,17 +45,30 @@ class HomeView: UIView {
 	var moc: NSManagedObjectContext? = nil
 	var moc: NSManagedObjectContext? = nil
 	var delegate: AppDelegate? = nil
 	var delegate: AppDelegate? = nil
 	var lang: String? = nil
 	var lang: String? = nil
+	var locationTimer: Timer? = nil
+	var controller: ViewController
+	var storyboard: UIStoryboard
 	
 	
+	
+	/**
+	Default constructor for the storyboard.
+	:param: frame View frame.
+	*/
 	override init(frame: CGRect){
 	override init(frame: CGRect){
+		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
+		self.controller = storyboard.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
 		super.init(frame: frame)
 		super.init(frame: frame)
 		
 		
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	 Run when the view is started.
 	 Run when the view is started.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
 		
 		
+		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
+		self.controller = storyboard.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 		
 		
 		//Load the contents of the HomeView.xib file.
 		//Load the contents of the HomeView.xib file.
@@ -60,16 +76,12 @@ class HomeView: UIView {
 		self.addSubview(container)
 		self.addSubview(container)
 		container.frame = self.bounds
 		container.frame = self.bounds
 		
 		
-
-		
 		//Set titles for each section
 		//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")
+		futureActivitiesSection.setTitle(text: "Próximas actividades")
+		blogSection.setTitle(text: "Últimos posts")
+		gallerySection.setTitle(text: "Últimas fotos")
+		pastActivitiesSection.setTitle(text: "Últimas actividades")
+		socialSection.setTitle(text: "Síguenos")
 		
 		
 		//Get info to populate sections
 		//Get info to populate sections
 		self.moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		self.moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
@@ -78,20 +90,21 @@ class HomeView: UIView {
 		self.moc?.persistentStoreCoordinator = self.delegate?.persistentStoreCoordinator
 		self.moc?.persistentStoreCoordinator = self.delegate?.persistentStoreCoordinator
 		self.lang = getLanguage()
 		self.lang = getLanguage()
 		
 		
+		
+		// Populate section.
 		populate()
 		populate()
 		
 		
-		/*//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?
-
-		}
-		// TODO: Calculate at the end
-		self.scrollView.contentSize.height = 1300// CGFloat(h);*/
+		
+		// Special case: Location
+		// Set up once and start and periodically witha  timer.
+		setUpLocation()
+		Timer.scheduledTimer(timeInterval: 60, target: self, selector: #selector(setUpLocation), userInfo: nil, repeats: true)
 	}
 	}
 	
 	
+	
+	/**
+	Sets all the sections up
+	*/
 	func populate(){
 	func populate(){
 	
 	
 		//Populate sections
 		//Populate sections
@@ -100,12 +113,10 @@ class HomeView: UIView {
 		setUpFutureActivities(context: self.moc!, delegate: self.delegate!, lang: self.lang!, parent: self.futureActivitiesSection.getContentStack())
 		setUpFutureActivities(context: self.moc!, delegate: self.delegate!, lang: self.lang!, parent: self.futureActivitiesSection.getContentStack())
 		setUpSocial(parent: self.socialSection.getContentStack())
 		setUpSocial(parent: self.socialSection.getContentStack())
 		setUpGallery(context: self.moc!, delegate: self.delegate!, parent: self.gallerySection.getContentStack())
 		setUpGallery(context: self.moc!, delegate: self.delegate!, parent: self.gallerySection.getContentStack())
-		
-		
-		//pastActivitiesSection.expandSection()
-
+		setUpLablanca(context: self.moc!, delegate: self.delegate!, lang: self.lang!)
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Gets the device language. The only recognized languages are Spanish, English and Basque.
 	Gets the device language. The only recognized languages are Spanish, English and Basque.
 	If the device has another language, Spanish will be selected by default.
 	If the device has another language, Spanish will be selected by default.
@@ -122,8 +133,115 @@ class HomeView: UIView {
 	}
 	}
 	
 	
 	
 	
+	/**
+	Sets up the location section.
+	If no location is reported, it hiddes the section.
+	*/
+	func setUpLocation(){
+		// TODO: Also set up tap recognizer.
+		let defaults = UserDefaults.standard
+		if (defaults.value(forKey: "GMLocLat") != nil && defaults.value(forKey: "GMLocLon") != nil){
+			let lat = defaults.value(forKey: "GMLocLat") as! Double
+			let lon = defaults.value(forKey: "GMLocLon") as! Double
+			let time = defaults.value(forKey: "GMLocTime") as! Date
+			let cTime = Date()
+			let minutes = Calendar.current.dateComponents([.minute], from: time, to: cTime).minute
+			if (minutes! < 30){
+				self.locationSection.isHidden = false
+				
+				// Set tap recognizer.
+				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (HomeView.openLocation (_:)))
+				tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+				self.locationSection.addGestureRecognizer(tapRecognizer)
+				
+				let location = self.controller.getLocation()
+				if location != nil {
+					let d: Int = calculateDistance(lat1: location.latitude, lon1: location.longitude, lat2: lat, lon2: lon)
+					
+					if d <= 1000 {
+						self.locationMessage.text = "¡Gasteizko Margolariak está por ahí! A \(d) metros de ti."
+					}
+					else{
+						self.locationMessage.text = "¡Gasteizko Margolariak está por ahí! A \(Int(d/1000)) kilómetros de ti."
+					}
+				}
+				else{
+					self.locationMessage.text = "¡Gasteizko Margolariak está por ahí!"
+				}
+			}
+			else{
+				self.locationSection.isHidden = true
+			}
+		}
+		else{
+			self.locationSection.isHidden = true
+		}
+	}
+	
+	
+	/**
+	Sets up the La Blanca secction.
+	Hiddes it if no current festivals.
+	:param: context App context.
+	:param: delegate App delegate.
+	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
+	*/
+	func setUpLablanca(context : NSManagedObjectContext, delegate: AppDelegate, lang: String){
+		
+		let defaults = UserDefaults.standard
+		if (defaults.value(forKey: "festivals") != nil){
+			let festivals = defaults.value(forKey: "festivals") as! Int
+			if festivals == 1{
+				
+				// Set tap recognizer
+				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (HomeView.openLablanca (_:)))
+				tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+				self.lablancaSection.addGestureRecognizer(tapRecognizer)
+				
+				// TODO: Get current year
+				let year = 2017
+				
+				// Get info about festivals
+				let fetchRequest: NSFetchRequest<Festival> = Festival.fetchRequest()
+				fetchRequest.predicate = NSPredicate(format: "year = %i", year)
+				
+				do {
+					
+					// Get info from festivals
+					let searchResults = try context.fetch(fetchRequest)
+					
+					if searchResults.count > 0 {
+						let r = searchResults[0]
+						
+						// Set image and text
+						self.lablancaText.text = (r.value(forKey: "text_\(lang)") as! String?)?.decode().stripHtml()
+						let filename: String = r.value(forKey: "img") as! String
+						if (filename == ""){
+							// Hide the imageview
+							self.lablancaImage.isHidden = true;
+						}
+						else{
+							let path = "img/blog/thumb/\(filename)"
+							self.lablancaImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+						}
+					}
+					
+				}
+				catch {
+					NSLog(":LABLANCA:ERROR: Error getting festivals info: \(error)")
+				}
+			}
+			else{
+				self.lablancaSection.isHidden = true
+			}
+		}
+	}
+	
+	
 	/**
 	/**
 	Sets up the future activities section.
 	Sets up the future activities section.
+	If none, it hiddes the section.
+	:param: context App context.
 	:param: delegate App delegate.
 	:param: delegate App delegate.
 	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
 	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
 	:param: parent Stack view to load the rows in.
 	:param: parent Stack view to load the rows in.
@@ -146,41 +264,46 @@ class HomeView: UIView {
 			var text: String
 			var text: String
 			var image: String
 			var image: String
 			
 			
-			for r in searchResults as [NSManagedObject] {
-				count = count + 1
+			if searchResults.count == 0{
+				self.futureActivitiesSection.isHidden = true
+			}
+			else{
+				for r in searchResults as [NSManagedObject] {
+					count = count + 1
 				
 				
-				//Create a new row
-				row = RowHomeFutureActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
-				id = r.value(forKey: "id")! as! Int
-				title = r.value(forKey: "title_\(lang)")! as! String
-				text = r.value(forKey: "text_\(lang)")! as! String
-				row.setTitle(text: title)
-				row.setText(text: text)
-				row.id = id
+					//Create a new row
+					row = RowHomeFutureActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
+					id = r.value(forKey: "id")! as! Int
+					title = r.value(forKey: "title_\(lang)")! as! String
+					text = r.value(forKey: "text_\(lang)")! as! String
+					row.setTitle(text: title)
+					row.setText(text: text)
+					row.id = id
 				
 				
-				// Get main image
-				image = ""
-				let imgFetchRequest: NSFetchRequest<Activity_image> = Activity_image.fetchRequest()
-				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
-				let imgSortDescriptors = [imgSortDescriptor]
-				imgFetchRequest.sortDescriptors = imgSortDescriptors
-				imgFetchRequest.predicate = NSPredicate(format: "activity == %i", id)
-				imgFetchRequest.fetchLimit = 1
-				do{
-					let imgSearchResults = try context.fetch(imgFetchRequest)
-					for imgR in imgSearchResults as [NSManagedObject]{
-						image = imgR.value(forKey: "image")! as! String
-						row.setImage(filename: image)
+					// Get main image
+					image = ""
+					let imgFetchRequest: NSFetchRequest<Activity_image> = Activity_image.fetchRequest()
+					let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
+					let imgSortDescriptors = [imgSortDescriptor]
+					imgFetchRequest.sortDescriptors = imgSortDescriptors
+					imgFetchRequest.predicate = NSPredicate(format: "activity == %i", id)
+					imgFetchRequest.fetchLimit = 1
+					do{
+						let imgSearchResults = try context.fetch(imgFetchRequest)
+						for imgR in imgSearchResults as [NSManagedObject]{
+							image = imgR.value(forKey: "image")! as! String
+							row.setImage(filename: image)
+						}
+					}
+					catch {
+						NSLog(":HOME:ERROR: Error getting image for activity \(id): \(error)")
 					}
 					}
-				}
-				catch {
-					NSLog(":HOME:ERROR: Error getting image for activity \(id): \(error)")
-				}
-				
-				parent.addArrangedSubview(row)
 				
 				
+					parent.addArrangedSubview(row)
+				}
 			}
 			}
-		} catch {
+		}
+		catch {
 			NSLog(":HOME:ERROR: Error loading future activities: \(error)")
 			NSLog(":HOME:ERROR: Error loading future activities: \(error)")
 		}
 		}
 	}
 	}
@@ -188,6 +311,7 @@ class HomeView: UIView {
 	
 	
 	/**
 	/**
 	Sets up the blog section.
 	Sets up the blog section.
+	:param: context App context.
 	:param: delegate App delegate.
 	:param: delegate App delegate.
 	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
 	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
 	:param: parent Stack view to load the rows in.
 	:param: parent Stack view to load the rows in.
@@ -256,6 +380,7 @@ class HomeView: UIView {
 	
 	
 	/**
 	/**
 	Sets up the past activities section.
 	Sets up the past activities section.
+	:param: context App context.
 	:param: delegate App delegate.
 	:param: delegate App delegate.
 	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
 	:param: lang Language code (two letter code, lowercase. Only 'es', 'en' and 'eu' supported).
 	:param: parent Stack view to load the rows in.
 	:param: parent Stack view to load the rows in.
@@ -318,8 +443,10 @@ class HomeView: UIView {
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Sets up the future activities section.
 	Sets up the future activities section.
+	:param: context App context.
 	:param: delegate App delegate.
 	:param: delegate App delegate.
 	:param: parent Stack view to load the rows in.
 	:param: parent Stack view to load the rows in.
 	*/
 	*/
@@ -342,13 +469,30 @@ class HomeView: UIView {
 	
 	
 			var id: Int
 			var id: Int
 			var image: String
 			var image: String
+			var albumId: Int
 			var i = 0
 			var i = 0
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
 				
 				
 				image = r.value(forKey: "file")! as! String
 				image = r.value(forKey: "file")! as! String
+				id = r.value(forKey: "id")! as! Int
+				
+				// TODO Get album id
+				// Get album title
+				let albumFetchRequest: NSFetchRequest<Photo_album> = Photo_album.fetchRequest()
+				albumFetchRequest.predicate = NSPredicate(format: "photo = %i", id)
+				do {
+					let results = try context.fetch(albumFetchRequest)
+					let r = results[0]
+					albumId = r.value(forKey: "album")! as! Int
+					row.albumIds[i] = albumId
+				}
+				catch {
+					NSLog(":GALLERYCONTROLLER:ERROR: Error getting album info: \(error)")
+				}
+				
 				row.setImage(idx: i, filename: image)
 				row.setImage(idx: i, filename: image)
+				row.photoIds[i] = id
 				
 				
-				//TODO Set click listener
 				i = i + 1
 				i = i + 1
 			}
 			}
 		}
 		}
@@ -370,12 +514,63 @@ class HomeView: UIView {
 	}
 	}
 	
 	
 	
 	
+	/**
+	Converts degrees to radians.
+	:params: degrees Angle in degrees.
+	:return: Angle in radians.
+	*/
+	func degreesToRadians(degrees: Double) -> Double {
+		return degrees * Double.pi / 180;
+	}
+	
+	
+	/**
+	Calculates the distance between two coordinates.
+	:param: lat1 Latitude of the first coordinate.
+	:param: lon1 Longitude of the first coordinate.
+	:param: lat2 Latitude of the second coordinate.
+	:param: lon2 Longitude of the second coordinate.
+	:return: Distance between the points, in meters.
+	*/
+	func calculateDistance(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> Int {
+		let eRadius: Double = 6371
+		
+		let dLat: Double = degreesToRadians(degrees: lat2-lat1)
+		let dLon: Double = degreesToRadians(degrees: lon2-lon1)
+		
+		let l1: Double = degreesToRadians(degrees: lat1)
+		let l2: Double = degreesToRadians(degrees: lat2)
+		
+		let a: Double = sin(dLat/2) * sin(dLat/2) + sin(dLon/2) * sin(dLon/2) * cos(l1) * cos(l2)
+		let c: Double = 2 * atan2(sqrt(a), sqrt(1-a))
+		let m: Double = eRadius * c * 1000
+		return Int(m)
+	}
+	
+	
 	/**
 	/**
 	Opens a post.
 	Opens a post.
 	*/
 	*/
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":HOME:DEBUG: Getting delegate and showing post.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
 		delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
 	}
 	}
+	
+	
+	/**
+	Opens the La Blanca section when tapping the section.
+	*/
+	func openLablanca(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showComponent(selected: 2)
+	}
+	
+	
+	/**
+	Opens the Location section when tapping the section.
+	*/
+	func openLocation(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showComponent(selected: 1)
+	}
 }
 }

+ 202 - 11
app/HomeView.xib

@@ -15,7 +15,10 @@
                 <outlet property="container" destination="iN0-l3-epB" id="cfT-rm-jA0"/>
                 <outlet property="container" destination="iN0-l3-epB" id="cfT-rm-jA0"/>
                 <outlet property="futureActivitiesSection" destination="FQo-nm-4Mo" id="TAU-5k-Sc5"/>
                 <outlet property="futureActivitiesSection" destination="FQo-nm-4Mo" id="TAU-5k-Sc5"/>
                 <outlet property="gallerySection" destination="v6A-Ya-esA" id="TPS-Ut-DK1"/>
                 <outlet property="gallerySection" destination="v6A-Ya-esA" id="TPS-Ut-DK1"/>
+                <outlet property="lablancaImage" destination="gkF-He-baV" id="pCZ-g7-TMf"/>
                 <outlet property="lablancaSection" destination="9nu-j1-wGI" id="3eu-wW-jM4"/>
                 <outlet property="lablancaSection" destination="9nu-j1-wGI" id="3eu-wW-jM4"/>
+                <outlet property="lablancaText" destination="YsW-Bq-7gd" id="Oce-9m-0Io"/>
+                <outlet property="locationMessage" destination="JXP-eW-H8r" id="fic-KB-N90"/>
                 <outlet property="locationSection" destination="Ljm-NP-c4e" id="bCD-0M-vqb"/>
                 <outlet property="locationSection" destination="Ljm-NP-c4e" id="bCD-0M-vqb"/>
                 <outlet property="pastActivitiesSection" destination="fZk-r1-Tca" id="U8D-Sh-TpR"/>
                 <outlet property="pastActivitiesSection" destination="fZk-r1-Tca" id="U8D-Sh-TpR"/>
                 <outlet property="scrollView" destination="Poy-ba-9jX" id="PyU-Nb-kOS"/>
                 <outlet property="scrollView" destination="Poy-ba-9jX" id="PyU-Nb-kOS"/>
@@ -31,25 +34,203 @@
                     <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
                     <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
                     <subviews>
                     <subviews>
                         <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="gOz-rr-CeQ">
                         <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="gOz-rr-CeQ">
-                            <rect key="frame" x="0.0" y="0.0" width="320" height="780"/>
+                            <rect key="frame" x="0.0" y="0.0" width="320" height="1144"/>
                             <subviews>
                             <subviews>
-                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ljm-NP-c4e" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
+                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ljm-NP-c4e">
+                                    <rect key="frame" x="0.0" y="0.0" width="320" height="157"/>
+                                    <subviews>
+                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZvF-yV-TQm" userLabel="LocationContainer">
+                                            <rect key="frame" x="10" y="9.5" width="300" height="137"/>
+                                            <subviews>
+                                                <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="Encuéntranos" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="xcx-xq-doc">
+                                                    <rect key="frame" x="0.0" y="0.0" width="300" height="27"/>
+                                                    <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="27" id="GLS-4B-sku"/>
+                                                    </constraints>
+                                                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
+                                                    <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                                                </textView>
+                                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qqh-sw-MbH" userLabel="Entry">
+                                                    <rect key="frame" x="10" y="37" width="280" height="90"/>
+                                                    <subviews>
+                                                        <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PinpointGM" translatesAutoresizingMaskIntoConstraints="NO" id="HgA-hw-nFb">
+                                                            <rect key="frame" x="10" y="19.5" width="40" height="50"/>
+                                                            <constraints>
+                                                                <constraint firstAttribute="width" constant="40" id="LL7-qW-58P"/>
+                                                                <constraint firstAttribute="height" constant="50" id="Ye3-b8-p9O"/>
+                                                            </constraints>
+                                                        </imageView>
+                                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¡Gasteizko Margolariak está por ahí!" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JXP-eW-H8r" userLabel="Text">
+                                                            <rect key="frame" x="65" y="10" width="205" height="70"/>
+                                                            <constraints>
+                                                                <constraint firstAttribute="height" constant="70" id="EF3-nL-xJE"/>
+                                                            </constraints>
+                                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                            <nil key="textColor"/>
+                                                            <nil key="highlightedColor"/>
+                                                        </label>
+                                                    </subviews>
+                                                    <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                    <constraints>
+                                                        <constraint firstItem="HgA-hw-nFb" firstAttribute="leading" secondItem="qqh-sw-MbH" secondAttribute="leading" constant="10" id="K2O-i3-xXX"/>
+                                                        <constraint firstItem="HgA-hw-nFb" firstAttribute="centerY" secondItem="qqh-sw-MbH" secondAttribute="centerY" id="KM1-Yd-1CZ"/>
+                                                        <constraint firstItem="JXP-eW-H8r" firstAttribute="height" secondItem="qqh-sw-MbH" secondAttribute="height" constant="-20" id="KPu-k0-bCe"/>
+                                                        <constraint firstItem="JXP-eW-H8r" firstAttribute="leading" secondItem="HgA-hw-nFb" secondAttribute="trailing" constant="15" id="aTU-Xn-urr"/>
+                                                        <constraint firstAttribute="trailing" secondItem="JXP-eW-H8r" secondAttribute="trailing" constant="10" id="gOz-7L-IQ6"/>
+                                                        <constraint firstItem="JXP-eW-H8r" firstAttribute="centerY" secondItem="qqh-sw-MbH" secondAttribute="centerY" id="yEV-Vl-cMY"/>
+                                                    </constraints>
+                                                    <userDefinedRuntimeAttributes>
+                                                        <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                            <color key="value" red="0.42745098040000001" green="0.41176470590000003" blue="0.56470588239999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                        </userDefinedRuntimeAttribute>
+                                                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                            <real key="value" value="1"/>
+                                                        </userDefinedRuntimeAttribute>
+                                                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                            <real key="value" value="3"/>
+                                                        </userDefinedRuntimeAttribute>
+                                                    </userDefinedRuntimeAttributes>
+                                                </view>
+                                            </subviews>
+                                            <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                            <constraints>
+                                                <constraint firstItem="xcx-xq-doc" firstAttribute="top" secondItem="ZvF-yV-TQm" secondAttribute="top" id="1Hp-p6-gXS"/>
+                                                <constraint firstItem="qqh-sw-MbH" firstAttribute="width" secondItem="ZvF-yV-TQm" secondAttribute="width" constant="-20" id="FS5-DP-F6y"/>
+                                                <constraint firstItem="xcx-xq-doc" firstAttribute="centerX" secondItem="ZvF-yV-TQm" secondAttribute="centerX" id="Xq6-tK-aZf"/>
+                                                <constraint firstAttribute="bottom" secondItem="qqh-sw-MbH" secondAttribute="bottom" constant="10" id="gAr-Ar-e57"/>
+                                                <constraint firstItem="qqh-sw-MbH" firstAttribute="top" secondItem="xcx-xq-doc" secondAttribute="bottom" constant="10" id="kOJ-wR-oGj"/>
+                                                <constraint firstItem="xcx-xq-doc" firstAttribute="width" secondItem="ZvF-yV-TQm" secondAttribute="width" id="ldg-HY-G9g"/>
+                                                <constraint firstItem="qqh-sw-MbH" firstAttribute="centerX" secondItem="ZvF-yV-TQm" secondAttribute="centerX" id="llP-Al-gqL"/>
+                                            </constraints>
+                                            <userDefinedRuntimeAttributes>
+                                                <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                    <color key="value" red="0.0" green="0.0" blue="0.066666666669999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                </userDefinedRuntimeAttribute>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                    <real key="value" value="1"/>
+                                                </userDefinedRuntimeAttribute>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                    <real key="value" value="8"/>
+                                                </userDefinedRuntimeAttribute>
+                                            </userDefinedRuntimeAttributes>
+                                        </view>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="ZvF-yV-TQm" firstAttribute="width" secondItem="Ljm-NP-c4e" secondAttribute="width" constant="-20" id="A3M-1s-2gK"/>
+                                        <constraint firstItem="ZvF-yV-TQm" firstAttribute="centerY" secondItem="Ljm-NP-c4e" secondAttribute="centerY" id="ZQZ-8v-OrW"/>
+                                        <constraint firstItem="ZvF-yV-TQm" firstAttribute="centerX" secondItem="Ljm-NP-c4e" secondAttribute="centerX" id="jhS-6W-MWI"/>
+                                        <constraint firstItem="ZvF-yV-TQm" firstAttribute="height" secondItem="Ljm-NP-c4e" secondAttribute="height" constant="-20" id="nie-wn-NTt"/>
+                                    </constraints>
+                                    <userDefinedRuntimeAttributes>
+                                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                            <real key="value" value="0.0"/>
+                                        </userDefinedRuntimeAttribute>
+                                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                            <real key="value" value="0.0"/>
+                                        </userDefinedRuntimeAttribute>
+                                    </userDefinedRuntimeAttributes>
                                 </view>
                                 </view>
-                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9nu-j1-wGI" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="60" width="320" height="50"/>
+                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9nu-j1-wGI">
+                                    <rect key="frame" x="0.0" y="167" width="320" height="157"/>
+                                    <subviews>
+                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RyS-ln-grn" userLabel="LablancaContainer">
+                                            <rect key="frame" x="9.5" y="10" width="300" height="137"/>
+                                            <subviews>
+                                                <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="La Blanca" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="ftX-qb-57S">
+                                                    <rect key="frame" x="0.0" y="0.0" width="300" height="27"/>
+                                                    <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="27" id="oV8-jh-6e5"/>
+                                                    </constraints>
+                                                    <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
+                                                    <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                                                </textView>
+                                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fBq-qg-fz9" userLabel="Entry">
+                                                    <rect key="frame" x="10" y="37" width="280" height="90"/>
+                                                    <subviews>
+                                                        <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="gkF-He-baV">
+                                                            <rect key="frame" x="10" y="9.5" width="70" height="70"/>
+                                                            <constraints>
+                                                                <constraint firstAttribute="width" constant="70" id="ChM-hX-OnO"/>
+                                                                <constraint firstAttribute="height" constant="70" id="hNg-Je-ufU"/>
+                                                            </constraints>
+                                                        </imageView>
+                                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="¡Gasteizko Margolariak está por ahí!" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YsW-Bq-7gd" userLabel="Text">
+                                                            <rect key="frame" x="95" y="10" width="175" height="70"/>
+                                                            <constraints>
+                                                                <constraint firstAttribute="height" constant="70" id="Txi-or-Pra"/>
+                                                            </constraints>
+                                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                            <nil key="textColor"/>
+                                                            <nil key="highlightedColor"/>
+                                                        </label>
+                                                    </subviews>
+                                                    <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                    <constraints>
+                                                        <constraint firstItem="gkF-He-baV" firstAttribute="centerY" secondItem="fBq-qg-fz9" secondAttribute="centerY" id="Pi9-t0-oOa"/>
+                                                        <constraint firstAttribute="trailing" secondItem="YsW-Bq-7gd" secondAttribute="trailing" constant="10" id="VAj-dj-MLd"/>
+                                                        <constraint firstItem="YsW-Bq-7gd" firstAttribute="centerY" secondItem="fBq-qg-fz9" secondAttribute="centerY" id="jjq-4v-b9d"/>
+                                                        <constraint firstItem="gkF-He-baV" firstAttribute="leading" secondItem="fBq-qg-fz9" secondAttribute="leading" constant="10" id="jtF-UZ-btH"/>
+                                                        <constraint firstItem="YsW-Bq-7gd" firstAttribute="height" secondItem="fBq-qg-fz9" secondAttribute="height" constant="-20" id="uVT-PP-R5k"/>
+                                                        <constraint firstItem="YsW-Bq-7gd" firstAttribute="leading" secondItem="gkF-He-baV" secondAttribute="trailing" constant="15" id="zdn-rO-ngp"/>
+                                                    </constraints>
+                                                    <userDefinedRuntimeAttributes>
+                                                        <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                            <color key="value" red="0.42745098040000001" green="0.41176470590000003" blue="0.56470588239999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                        </userDefinedRuntimeAttribute>
+                                                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                            <real key="value" value="1"/>
+                                                        </userDefinedRuntimeAttribute>
+                                                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                            <real key="value" value="3"/>
+                                                        </userDefinedRuntimeAttribute>
+                                                    </userDefinedRuntimeAttributes>
+                                                </view>
+                                            </subviews>
+                                            <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                            <constraints>
+                                                <constraint firstItem="fBq-qg-fz9" firstAttribute="centerX" secondItem="RyS-ln-grn" secondAttribute="centerX" id="AqL-EH-Tjq"/>
+                                                <constraint firstItem="ftX-qb-57S" firstAttribute="centerX" secondItem="RyS-ln-grn" secondAttribute="centerX" id="FJ5-wt-uIa"/>
+                                                <constraint firstItem="fBq-qg-fz9" firstAttribute="top" secondItem="ftX-qb-57S" secondAttribute="bottom" constant="10" id="G4N-Ok-LJL"/>
+                                                <constraint firstItem="ftX-qb-57S" firstAttribute="top" secondItem="RyS-ln-grn" secondAttribute="top" id="SEd-7H-WX5"/>
+                                                <constraint firstItem="fBq-qg-fz9" firstAttribute="width" secondItem="RyS-ln-grn" secondAttribute="width" constant="-20" id="ay3-po-Etb"/>
+                                                <constraint firstItem="ftX-qb-57S" firstAttribute="width" secondItem="RyS-ln-grn" secondAttribute="width" id="kFI-rY-JTv"/>
+                                                <constraint firstAttribute="bottom" secondItem="fBq-qg-fz9" secondAttribute="bottom" constant="10" id="vka-uG-rAI"/>
+                                            </constraints>
+                                            <userDefinedRuntimeAttributes>
+                                                <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                    <color key="value" red="0.0" green="0.0" blue="0.066666666669999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                </userDefinedRuntimeAttribute>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                    <real key="value" value="1"/>
+                                                </userDefinedRuntimeAttribute>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                    <real key="value" value="8"/>
+                                                </userDefinedRuntimeAttribute>
+                                            </userDefinedRuntimeAttributes>
+                                        </view>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="RyS-ln-grn" firstAttribute="height" secondItem="9nu-j1-wGI" secondAttribute="height" constant="-20" id="IVY-CC-5KF"/>
+                                        <constraint firstItem="RyS-ln-grn" firstAttribute="width" secondItem="9nu-j1-wGI" secondAttribute="width" constant="-20" id="Qen-Pe-Hql"/>
+                                        <constraint firstItem="RyS-ln-grn" firstAttribute="centerY" secondItem="9nu-j1-wGI" secondAttribute="centerY" id="TnC-Qy-tMy"/>
+                                        <constraint firstItem="RyS-ln-grn" firstAttribute="centerX" secondItem="9nu-j1-wGI" secondAttribute="centerX" id="wGj-v9-Ljw"/>
+                                    </constraints>
                                 </view>
                                 </view>
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FQo-nm-4Mo" customClass="Section" customModule="app">
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FQo-nm-4Mo" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="120" width="320" height="50"/>
+                                    <rect key="frame" x="0.0" y="334" width="320" height="50"/>
                                 </view>
                                 </view>
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uHa-Mu-U68" customClass="Section" customModule="app">
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uHa-Mu-U68" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="180" width="320" height="50"/>
+                                    <rect key="frame" x="0.0" y="394" width="320" height="50"/>
                                 </view>
                                 </view>
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="v6A-Ya-esA" customClass="Section" customModule="app" customModuleProvider="target">
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="v6A-Ya-esA" customClass="Section" customModule="app" customModuleProvider="target">
-                                    <rect key="frame" x="0.0" y="240" width="320" height="50"/>
+                                    <rect key="frame" x="0.0" y="454" width="320" height="200"/>
                                 </view>
                                 </view>
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fZk-r1-Tca" customClass="Section" customModule="app">
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fZk-r1-Tca" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="300" width="320" height="350"/>
+                                    <rect key="frame" x="0.0" y="664" width="320" height="350"/>
                                     <userDefinedRuntimeAttributes>
                                     <userDefinedRuntimeAttributes>
                                         <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
                                         <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
                                             <real key="value" value="0.0"/>
                                             <real key="value" value="0.0"/>
@@ -57,7 +238,7 @@
                                     </userDefinedRuntimeAttributes>
                                     </userDefinedRuntimeAttributes>
                                 </view>
                                 </view>
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dgk-s8-xje" customClass="Section" customModule="app">
                                 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dgk-s8-xje" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="660" width="320" height="120"/>
+                                    <rect key="frame" x="0.0" y="1024" width="320" height="120"/>
                                 </view>
                                 </view>
                             </subviews>
                             </subviews>
                             <color key="backgroundColor" red="1" green="1" blue="0.42787000868055558" alpha="1" colorSpace="calibratedRGB"/>
                             <color key="backgroundColor" red="1" green="1" blue="0.42787000868055558" alpha="1" colorSpace="calibratedRGB"/>
@@ -73,6 +254,7 @@
                                 <constraint firstItem="FQo-nm-4Mo" firstAttribute="centerX" secondItem="gOz-rr-CeQ" secondAttribute="centerX" id="aWZ-5w-1ke"/>
                                 <constraint firstItem="FQo-nm-4Mo" firstAttribute="centerX" secondItem="gOz-rr-CeQ" secondAttribute="centerX" id="aWZ-5w-1ke"/>
                                 <constraint firstItem="FQo-nm-4Mo" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="azo-MK-F5R"/>
                                 <constraint firstItem="FQo-nm-4Mo" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="azo-MK-F5R"/>
                                 <constraint firstItem="uHa-Mu-U68" firstAttribute="centerX" secondItem="gOz-rr-CeQ" secondAttribute="centerX" id="i5O-1b-eCi"/>
                                 <constraint firstItem="uHa-Mu-U68" firstAttribute="centerX" secondItem="gOz-rr-CeQ" secondAttribute="centerX" id="i5O-1b-eCi"/>
+                                <constraint firstAttribute="bottom" secondItem="dgk-s8-xje" secondAttribute="bottom" id="lUo-Rq-bAi"/>
                                 <constraint firstItem="uHa-Mu-U68" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="ljo-DJ-9M1"/>
                                 <constraint firstItem="uHa-Mu-U68" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="ljo-DJ-9M1"/>
                                 <constraint firstItem="Ljm-NP-c4e" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="s8R-dV-4ju"/>
                                 <constraint firstItem="Ljm-NP-c4e" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="s8R-dV-4ju"/>
                                 <constraint firstItem="9nu-j1-wGI" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="v1C-hQ-R98"/>
                                 <constraint firstItem="9nu-j1-wGI" firstAttribute="width" secondItem="gOz-rr-CeQ" secondAttribute="width" id="v1C-hQ-R98"/>
@@ -80,6 +262,8 @@
                         </stackView>
                         </stackView>
                     </subviews>
                     </subviews>
                     <constraints>
                     <constraints>
+                        <constraint firstAttribute="bottom" secondItem="gOz-rr-CeQ" secondAttribute="bottom" id="1aX-69-rIr"/>
+                        <constraint firstAttribute="trailing" secondItem="gOz-rr-CeQ" secondAttribute="trailing" id="53K-6k-eT3"/>
                         <constraint firstItem="gOz-rr-CeQ" firstAttribute="width" secondItem="Poy-ba-9jX" secondAttribute="width" id="Gw0-jw-ldE"/>
                         <constraint firstItem="gOz-rr-CeQ" firstAttribute="width" secondItem="Poy-ba-9jX" secondAttribute="width" id="Gw0-jw-ldE"/>
                         <constraint firstItem="gOz-rr-CeQ" firstAttribute="top" secondItem="Poy-ba-9jX" secondAttribute="top" id="Hmx-ri-LqQ"/>
                         <constraint firstItem="gOz-rr-CeQ" firstAttribute="top" secondItem="Poy-ba-9jX" secondAttribute="top" id="Hmx-ri-LqQ"/>
                         <constraint firstItem="gOz-rr-CeQ" firstAttribute="leading" secondItem="Poy-ba-9jX" secondAttribute="leading" id="k5u-hr-4th"/>
                         <constraint firstItem="gOz-rr-CeQ" firstAttribute="leading" secondItem="Poy-ba-9jX" secondAttribute="leading" id="k5u-hr-4th"/>
@@ -89,9 +273,16 @@
             <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
             <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
             <constraints>
             <constraints>
                 <constraint firstItem="Poy-ba-9jX" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="9SN-Tf-raC"/>
                 <constraint firstItem="Poy-ba-9jX" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="9SN-Tf-raC"/>
-                <constraint firstItem="Poy-ba-9jX" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="TFG-sf-YY4"/>
+                <constraint firstItem="Poy-ba-9jX" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Gar-uI-abW"/>
+                <constraint firstItem="Poy-ba-9jX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="gDS-mJ-c25"/>
+                <constraint firstItem="Poy-ba-9jX" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="k8Z-RL-IVb"/>
+                <constraint firstItem="Poy-ba-9jX" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="xvC-vv-ebb"/>
             </constraints>
             </constraints>
             <point key="canvasLocation" x="26" y="52"/>
             <point key="canvasLocation" x="26" y="52"/>
         </view>
         </view>
     </objects>
     </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+        <image name="PinpointGM" width="15" height="20"/>
+    </resources>
 </document>
 </document>

+ 2 - 2
app/Info.plist

@@ -17,9 +17,9 @@
 	<key>CFBundlePackageType</key>
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
 	<key>CFBundleShortVersionString</key>
-	<string>0.0.6</string>
+	<string>0.0.7</string>
 	<key>CFBundleVersion</key>
 	<key>CFBundleVersion</key>
-	<string>7</string>
+	<string>8</string>
 	<key>LSRequiresIPhoneOS</key>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<true/>
 	<key>NSLocationWhenInUseUsageDescription</key>
 	<key>NSLocationWhenInUseUsageDescription</key>

+ 0 - 6
app/LablancaView.swift

@@ -146,8 +146,6 @@ class LablancaView: UIView {
 			// Get info from festivals
 			// Get info from festivals
 			let offerSearchResults = try context.fetch(offerFetchRequest)
 			let offerSearchResults = try context.fetch(offerFetchRequest)
 			
 			
-			NSLog(":LABLANCA:DEBUG: \(offerSearchResults.count) offes found.")
-
 			var row: RowLablancaOffer
 			var row: RowLablancaOffer
 			var count: Int = 0
 			var count: Int = 0
 
 
@@ -245,10 +243,8 @@ class LablancaView: UIView {
 	:param: sender The view that triggered the event.
 	:param: sender The view that triggered the event.
 	*/
 	*/
 	func openSchedule(_ sender:UITapGestureRecognizer? = nil){
 	func openSchedule(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":LABLANCA:DEBUG: Getting delegate and showing schedule.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showSchedule(margolari: false)
 		delegate.controller?.showSchedule(margolari: false)
-		NSLog(":LABLANCA:DEBUG: Schedule should be shown.")
 	}
 	}
 
 
 
 
@@ -257,10 +253,8 @@ class LablancaView: UIView {
 	:param: sender The view that triggered the event.
 	:param: sender The view that triggered the event.
 	*/
 	*/
 	func openGMSchedule(_ sender:UITapGestureRecognizer? = nil){
 	func openGMSchedule(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":LABLANCA:DEBUG: Getting delegate and showing GM schedule.")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showSchedule(margolari: true)
 		delegate.controller?.showSchedule(margolari: true)
-		NSLog(":LABLANCA:DEBUG: GM schedule should be shown.")
 	}
 	}
 
 
 	
 	

+ 1 - 6
app/LocationView.swift

@@ -92,7 +92,7 @@ class LocationView: UIView {
 	Get new location
 	Get new location
 	*/
 	*/
 	func getNewLocation(){
 	func getNewLocation(){
-		NSLog(":LOCATION:DEBUG: Setting marker.")
+		NSLog(":LOCATION:LOG: Recalculating location.")
 		let defaults = UserDefaults.standard
 		let defaults = UserDefaults.standard
 		if (defaults.value(forKey: "GMLocLat") != nil && defaults.value(forKey: "GMLocLon") != nil){
 		if (defaults.value(forKey: "GMLocLat") != nil && defaults.value(forKey: "GMLocLon") != nil){
 			let lat = defaults.value(forKey: "GMLocLat") as! Double
 			let lat = defaults.value(forKey: "GMLocLat") as! Double
@@ -110,12 +110,10 @@ class LocationView: UIView {
 				marker.title = "Gasteizko Margolariak"
 				marker.title = "Gasteizko Margolariak"
 				//marker.snippet = "Australia"
 				//marker.snippet = "Australia"
 				marker.map = self.map
 				marker.map = self.map
-				NSLog(":LOCATION:DEBUG: Marker set.")
 			
 			
 				let location = self.controller.getLocation()
 				let location = self.controller.getLocation()
 				if location != nil {
 				if location != nil {
 					let d: Int = calculateDistance(lat1: location.latitude, lon1: location.longitude, lat2: lat, lon2: lon)
 					let d: Int = calculateDistance(lat1: location.latitude, lon1: location.longitude, lat2: lat, lon2: lon)
-					NSLog(":LOCATION:LOG: Distance (m): \(d)")
 				
 				
 					if d <= 1000 {
 					if d <= 1000 {
 						self.lbDistance.text = "A \(d) metros de ti."
 						self.lbDistance.text = "A \(d) metros de ti."
@@ -132,9 +130,6 @@ class LocationView: UIView {
 				self.lbNo.isHidden = false
 				self.lbNo.isHidden = false
 			}
 			}
 		}
 		}
-		else{
-			NSLog(":LOCATION:DEBUG: No location saved yet.")
-		}
 	}
 	}
 
 
 
 

+ 290 - 0
app/PhotoViewController.swift

@@ -0,0 +1,290 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import UIKit
+import CoreData
+
+/**
+The view controller of the app.
+*/
+class PhotoViewController: UIViewController, UIGestureRecognizerDelegate {
+
+	@IBOutlet weak var barButton: UIButton!
+	@IBOutlet weak var barTitle: UILabel!
+	@IBOutlet weak var photoTitle: UILabel!
+	@IBOutlet weak var photoImage: UIImageView!
+	@IBOutlet weak var photoDate: UILabel!
+	@IBOutlet weak var btPrev: UIButton!
+	@IBOutlet weak var btNext: UIButton!
+	
+	var albumId: Int = -1
+	var photoId: Int = -1
+	var photoIds: [Int] = []
+	var photoIdx: Int = 0
+	var passPhotoId: Int = -1
+	var passAlbumId: Int = -1
+	var albumTitle: String = ""
+	var delegate: AppDelegate?
+	
+	
+	/**
+	Gets the application context.
+	:return: The application context.
+	*/
+	func getContext () -> NSManagedObjectContext {
+		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
+	}
+	
+	
+	/**
+	Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		// Populate photo array.
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Photo_album> = Photo_album.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "album = %i", albumId)
+		do {
+			let searchResults = try context.fetch(fetchRequest)
+			
+			var id: Int
+			var i = 0
+			
+			for r in searchResults as [NSManagedObject] {
+				
+				id = r.value(forKey: "photo")! as! Int
+				photoIds.append(id)
+				if id == photoId{
+					photoIdx = i
+				}
+				i = i + 1
+			}
+			
+			// Get album title
+			let albumFetchRequest: NSFetchRequest<Album> = Album.fetchRequest()
+			albumFetchRequest.predicate = NSPredicate(format: "id = %i", albumId)
+			do {
+				let results = try context.fetch(albumFetchRequest)
+				let r = results[0]
+				self.albumTitle = r.value(forKey: "title_\(lang)")! as! String
+			}
+			catch {
+				NSLog(":GALLERYCONTROLLER:ERROR: Error getting album info: \(error)")
+			}
+			
+		} catch {
+			NSLog(":PHOTO:ERROR: Error getting infor from album \(albumId): \(error)")
+		}
+		
+		// Set up buttons
+		let tapRecognizerNext = UITapGestureRecognizer(target: self, action: #selector(nextPhoto(_:)))
+		btNext.isUserInteractionEnabled = true
+		btNext.addGestureRecognizer(tapRecognizerNext)
+		let tapRecognizerPrev = UITapGestureRecognizer(target: self, action: #selector(prevPhoto(_:)))
+		btPrev.isUserInteractionEnabled = true
+		btPrev.addGestureRecognizer(tapRecognizerPrev)
+		
+		super.viewDidLoad()
+		self.loadPhoto(id: photoId)
+		
+		// Set button action
+		self.barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+	}
+	
+	
+	/**
+	Dismisses the controller.
+	*/
+	func back() {
+		self.dismiss(animated: true, completion: nil)
+	}
+	
+	
+	/**
+	Dispose of any resources that can be recreated.
+	*/
+	override func didReceiveMemoryWarning() {
+		super.didReceiveMemoryWarning()
+	}
+	
+	
+	/**
+	Opens the next photo.
+	*/
+	func nextPhoto(_ sender:UITapGestureRecognizer? = nil){
+		photoIdx = photoIdx + 1
+		loadPhoto(id: photoIds[photoIdx])
+	}
+	
+	
+	/**
+	Opens the previous photo.
+	*/
+	func prevPhoto(_ sender:UITapGestureRecognizer? = nil){
+		photoIdx = photoIdx - 1
+		loadPhoto(id: photoIds[photoIdx])
+	}
+	
+	
+	/**
+	Loads a photo in the viewer.
+	:param: id
+	*/
+	public func loadPhoto(id: Int){
+		
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
+		
+		do {
+			let searchResults = try context.fetch(fetchRequest)
+			
+			var sTitle: String
+			var sText: String
+			var image: String
+			var date: NSDate
+			
+			for r in searchResults as [NSManagedObject] {
+				
+				sTitle = r.value(forKey: "title_\(lang)")! as! String
+				if sTitle == "" || sTitle == "ul" {
+					sTitle = self.albumTitle
+				}
+				self.photoTitle.text = "  \(sTitle.decode().stripHtml())"
+				
+				// Enable or disable buttons
+				if photoIdx == 0{
+					self.btPrev.isEnabled = false
+					self.btPrev.alpha = 0.5
+				}
+				else{
+					self.btPrev.isEnabled = true
+					self.btPrev.alpha = 1
+				}
+				if photoIdx == photoIds.count - 1{
+					self.btNext.isEnabled = false
+					self.btNext.alpha = 0.5
+				}
+				else{
+					self.btNext.isEnabled = true
+					self.btNext.alpha = 1
+				}
+				
+				// Get image
+				image = ""
+				let imgFetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
+				imgFetchRequest.predicate = NSPredicate(format: "id == %i", id)
+				do{
+					let imgSearchResults = try context.fetch(imgFetchRequest)
+					let r: NSManagedObject = imgSearchResults[0]
+					image = r.value(forKey: "file")! as! String
+					date = r.value(forKey: "uploaded")! as! NSDate
+					let path = "img/galeria/preview/\(image)"
+					// TODO: Every time, set placeholder image
+					self.photoImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+					self.photoDate.text = formatDate(date: date, lang: lang)
+				}
+				catch {
+					NSLog(":PHOTO:ERROR: Error getting image for post \(id): \(error)")
+				}
+				
+			}
+		} catch {
+			NSLog(":PHOTO:ERROR: Error setting up photo \(id): \(error)")
+		}
+	}
+	
+
+	
+	/**
+	Formats a date to the desired language.
+	:param: text The date.
+	:param: lang Device language (only 'es', 'en', or 'eu').
+	*/
+	func formatDate(date: NSDate, lang: String) -> String{
+		
+		let months_es = ["0index", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
+		let months_en = ["0index", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
+		let months_eu = ["0index", "urtarrilaren", "otsailaren", "martxoaren", "abrilaren", "maiatzaren", "ekainaren", "ustailaren", "abustuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"]
+		let days_es = ["0index", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado", "Domingo"]
+		let days_en = ["0index", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
+		let days_eu = ["0index", "Astelehena", "Asteartea", "Asteazkena", "Osteguna", "Ostirala", "Larumbata", "Igandea"]
+		
+		let calendar = Calendar.current
+		let year = calendar.component(.year, from: date as Date)
+		let day = calendar.component(.day, from: date as Date)
+		let month = calendar.component(.month, from: date as Date)
+		let weekday = calendar.component(.weekday, from: date as Date)
+		var strDate = ""
+		
+		switch lang{
+		case "en":
+			
+			var dayNum = ""
+			switch day{
+			case 1:
+				dayNum = "1th"
+				break
+			case 2:
+				dayNum = "2nd"
+				break;
+			case 3:
+				dayNum = "3rd"
+				break;
+			default:
+				dayNum = "\(weekday)th"
+			}
+			
+			strDate = "\(days_en[weekday]), \(months_en[month]) \(dayNum), \(year)"
+			break
+		case "eu":
+			strDate = "\(year)ko \(days_eu[weekday]) \(months_eu[month]) \(day)an"
+			break
+		default:
+			strDate = "\(days_es[weekday]) \(day) de \(months_es[month]) de \(year)"
+		}
+		
+		return strDate
+	}
+	
+	
+	/**
+	Gets the device language. The only recognized languages are Spanish, English and Basque.
+	If the device has another language, Spanish will be selected by default.
+	:return: Two-letter language code.
+	*/
+	func getLanguage() -> String{
+		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
+		if(pre == "es" || pre == "en" || pre == "eu"){
+			return pre
+		}
+		else{
+			return "es"
+		}
+	}
+}
+

+ 21 - 24
app/PostViewController.swift

@@ -26,20 +26,17 @@ The view controller of the app.
 */
 */
 class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 	
 	
+	
 	@IBOutlet weak var barTitle: UILabel!
 	@IBOutlet weak var barTitle: UILabel!
 	@IBOutlet weak var barButton: UIButton!
 	@IBOutlet weak var barButton: UIButton!
 	@IBOutlet weak var postText: UILabel!
 	@IBOutlet weak var postText: UILabel!
 	@IBOutlet weak var postTitle: UILabel!
 	@IBOutlet weak var postTitle: UILabel!
 	@IBOutlet weak var postImage: UIImageView!
 	@IBOutlet weak var postImage: UIImageView!
-	var id: Int = -1
-	var delegate: AppDelegate?
 	
 	
+	var id: Int = -1
 	var passId: Int = -1
 	var passId: Int = -1
+	var delegate: AppDelegate?
 	
 	
-	/**
-	Get the app context.
-	:return: The app context.
-	*/
 	func getContext () -> NSManagedObjectContext {
 	func getContext () -> NSManagedObjectContext {
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 	}
 	}
@@ -49,18 +46,16 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 	Run when the app loads.
 	Run when the app loads.
 	*/
 	*/
 	override func viewDidLoad() {
 	override func viewDidLoad() {
+		
 		super.viewDidLoad()
 		super.viewDidLoad()
 		self.loadPost(id: id)
 		self.loadPost(id: id)
+		
 		// Set button action
 		// Set button action
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
 	}
 	}
+		
 	
 	
-	
-	/**
-	Dismisses the controller.
-	*/
 	func back() {
 	func back() {
-		print("POSTCONTROLLER:DEBUG: Back")
 		self.dismiss(animated: true, completion: nil)
 		self.dismiss(animated: true, completion: nil)
 	}
 	}
 	
 	
@@ -72,15 +67,8 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 		super.didReceiveMemoryWarning()
 		super.didReceiveMemoryWarning()
 	}
 	}
 	
 	
-	
-	/**
-	Loads the selected post.
-	:param: id Post id.
-	*/
 	public func loadPost(id: Int){
 	public func loadPost(id: Int){
 		
 		
-		NSLog(":POSTCONTROLLER:DEBUG: Loading post \(id)")
-		
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let lang : String = getLanguage()
 		let lang : String = getLanguage()
@@ -89,18 +77,20 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
 		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
 		
 		
 		do {
 		do {
+			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
 			let searchResults = try context.fetch(fetchRequest)
-			var count = 0
+			
 			var sTitle: String
 			var sTitle: String
 			var sText: String
 			var sText: String
 			var image: String
 			var image: String
 			
 			
+			//You need to convert to NSManagedObject to use 'for' loops
 			for r in searchResults as [NSManagedObject] {
 			for r in searchResults as [NSManagedObject] {
-				count = count + 1
+				
 				sTitle = r.value(forKey: "title_\(lang)")! as! String
 				sTitle = r.value(forKey: "title_\(lang)")! as! String
 				sText = r.value(forKey: "text_\(lang)")! as! String
 				sText = r.value(forKey: "text_\(lang)")! as! String
-				postTitle.text = "  \(sTitle)"
-				postText.text = sText.stripHtml()
+				postTitle.text = "  \(sTitle.decode().stripHtml())"
+				postText.text = sText.decode().stripHtml()
 				
 				
 				// Get main image
 				// Get main image
 				image = ""
 				image = ""
@@ -110,12 +100,18 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 				imgFetchRequest.sortDescriptors = imgSortDescriptors
 				imgFetchRequest.sortDescriptors = imgSortDescriptors
 				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
 				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
 				imgFetchRequest.fetchLimit = 1
 				imgFetchRequest.fetchLimit = 1
+				//TODO get more images
 				do{
 				do{
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					let imgSearchResults = try context.fetch(imgFetchRequest)
 					for imgR in imgSearchResults as [NSManagedObject]{
 					for imgR in imgSearchResults as [NSManagedObject]{
 						image = imgR.value(forKey: "image")! as! String
 						image = imgR.value(forKey: "image")! as! String
-						let path = "img/blog/preview/\(image)"
-						self.postImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+						if image == ""{
+							self.postImage.isHidden = true
+						}
+						else{
+							let path = "img/blog/thumb/\(image)"
+							self.postImage.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+						}
 					}
 					}
 				} catch {
 				} catch {
 					NSLog(":POST:ERROR: Error getting image for post \(id): \(error)")
 					NSLog(":POST:ERROR: Error getting image for post \(id): \(error)")
@@ -127,6 +123,7 @@ class PostViewController: UIViewController, UIGestureRecognizerDelegate {
 		}
 		}
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Gets the device language. The only recognized languages are Spanish, English and Basque.
 	Gets the device language. The only recognized languages are Spanish, English and Basque.
 	If the device has another language, Spanish will be selected by default.
 	If the device has another language, Spanish will be selected by default.

+ 30 - 7
app/RowAlbum.swift

@@ -34,6 +34,9 @@ Extension of UIView to be formatted as sections.
 	// Album ID
 	// Album ID
 	var id = -1
 	var id = -1
 	
 	
+	// Photo ids
+	var photoIds: [Int] = [-1, -1]
+	
 	// Array with the imageviews
 	// Array with the imageviews
 	var preview: [UIImageView] = []
 	var preview: [UIImageView] = []
 
 
@@ -70,7 +73,6 @@ Extension of UIView to be formatted as sections.
 	:param: i Custom identifier
 	:param: i Custom identifier
 	*/
 	*/
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
-		NSLog(":ROWALBUM:DEBUG: Init \(s), \(i)")
 		
 		
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
@@ -95,29 +97,50 @@ Extension of UIView to be formatted as sections.
 		super.init(frame: frame)
 		super.init(frame: frame)
 	}
 	}
 	
 	
-	func openPhoto(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":ROWALBUM:DEBUG: Getting delegate and showing photo.")
-		// TODO
-		//let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
-		//delegate.controller?.showAlbum(id: self.id)
+	func openLeftPhoto(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.albumController?.showPhoto(album: self.id, photo: self.photoIds[0])
+	}
+	
+	func openRightPhoto(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.albumController?.showPhoto(album: self.id, photo: self.photoIds[1])
 	}
 	}
 	
 	
 	
 	
 	/**
 	/**
 	Changes the preview image of the photos.
 	Changes the preview image of the photos.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
+	It also sets the tap listener to show the photo.
 	:param: idx Id of the image in the row. 0 for left, 1 for right.
 	:param: idx Id of the image in the row. 0 for left, 1 for right.
 	:param: filename Filename of the image.
 	:param: filename Filename of the image.
 	*/
 	*/
 	func setImage(idx: Int, filename: String){
 	func setImage(idx: Int, filename: String){
 		if (filename == ""){
 		if (filename == ""){
 			self.preview[idx].isHidden = true
 			self.preview[idx].isHidden = true
-			//TODO hide the imageview
 		}
 		}
 		else{
 		else{
 			let path = "img/galeria/thumb/\(filename)"
 			let path = "img/galeria/thumb/\(filename)"
 			self.preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 			self.preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			// Set tap listener
+			if idx == 0 {
+				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowAlbum.openLeftPhoto(_:)))
+				tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+				self.preview[idx].isUserInteractionEnabled = true
+				self.preview[idx].addGestureRecognizer(tapRecognizer)
+			}
+			else{
+				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowAlbum.openRightPhoto(_:)))
+				tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+				self.preview[idx].isUserInteractionEnabled = true
+				self.preview[idx].addGestureRecognizer(tapRecognizer)
+			}
 		}
 		}
 	}
 	}
 	
 	
+	func setIds(left: Int, right: Int){
+		self.photoIds[0] = left
+		self.photoIds[1] = right
+	}
+	
 }
 }

+ 16 - 20
app/RowBlog.swift

@@ -22,25 +22,20 @@ import Foundation
 import UIKit
 import UIKit
 
 
 /**
 /**
-Extension of UIView to be formatted as sections.
+Extension of UIView to be formatted as post rows.
 */
 */
 @IBDesignable class RowBlog: UIView {
 @IBDesignable class RowBlog: UIView {
 	
 	
-	//The container.
+	// Outlets.
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
-	
-	//The entry
 	@IBOutlet weak var entry: UIView!
 	@IBOutlet weak var entry: UIView!
-
-	//The post title.
 	@IBOutlet weak var title: UILabel!
 	@IBOutlet weak var title: UILabel!
-	
-	//The post description.
 	@IBOutlet weak var descrip: UILabel!
 	@IBOutlet weak var descrip: UILabel!
-
-	//The post image.
 	@IBOutlet weak var image: UIImageView!
 	@IBOutlet weak var image: UIImageView!
 	
 	
+	// Post ID.
+	var id = -1
+	
 	
 	
 	/**
 	/**
 	Default constructor
 	Default constructor
@@ -51,14 +46,15 @@ Extension of UIView to be formatted as sections.
 	
 	
 	
 	
 	/**
 	/**
-	Loads the view in the xib file with the same name.
+	Loads the view from the xib with the same name as the class.
 	*/
 	*/
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
 	}
 	}
 	
 	
+	
 	/**
 	/**
 	Default constructor.
 	Default constructor.
 	:param: s Custom identifier
 	:param: s Custom identifier
@@ -77,10 +73,9 @@ Extension of UIView to be formatted as sections.
 		self.addSubview(self.container)
 		self.addSubview(self.container)
 		
 		
 		// Set tap recognizer
 		// Set tap recognizer
-		/*print("ROW_BLOG:DEBUG: set tap recognizer")
-		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (self.openPost (_:)))
+		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowBlog.openPost (_:)))
 		tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
 		tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
-		addGestureRecognizer(tapRecognizer)*/
+		self.addGestureRecognizer(tapRecognizer)
 	}
 	}
 	
 	
 	
 	
@@ -97,7 +92,7 @@ Extension of UIView to be formatted as sections.
 	:param: text The new title.
 	:param: text The new title.
 	*/
 	*/
 	func setTitle(text: String){
 	func setTitle(text: String){
-		self.title.text = text.decode().stripHtml()
+		title.text = text.decode().stripHtml()
 	}
 	}
 	
 	
 	
 	
@@ -106,10 +101,11 @@ Extension of UIView to be formatted as sections.
 	:param: text The new text.
 	:param: text The new text.
 	*/
 	*/
 	func setText(text: String){
 	func setText(text: String){
-		self.descrip.text = text.decode()
+		descrip.text = text.decode().stripHtml()
 	}
 	}
 	
 	
 	
 	
+	
 	/**
 	/**
 	Changes the image of the post.
 	Changes the image of the post.
 	If null or empty, the igage is hidden.
 	If null or empty, the igage is hidden.
@@ -128,10 +124,10 @@ Extension of UIView to be formatted as sections.
 	
 	
 	
 	
 	/**
 	/**
-	Opens a post.
+	Opens an activity.
 	*/
 	*/
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
-		// TODO implement openPost.
-		NSLog(":ROW_BLOG:DEBUG: openpost")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPost(id: self.id)
 	}
 	}
 }
 }

+ 1 - 1
app/RowBlog.xib

@@ -36,7 +36,7 @@
                                     <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
                                     <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
                                     <nil key="highlightedColor"/>
                                     <nil key="highlightedColor"/>
                                 </label>
                                 </label>
-                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="6hA-MD-OsD" userLabel="Image">
+                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="6hA-MD-OsD" userLabel="Image">
                                     <rect key="frame" x="10" y="40" width="71" height="64"/>
                                     <rect key="frame" x="10" y="40" width="71" height="64"/>
                                     <constraints>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="64" id="68z-jj-fIa"/>
                                         <constraint firstAttribute="height" constant="64" id="68z-jj-fIa"/>

+ 0 - 1
app/RowFutureActivity.swift

@@ -203,7 +203,6 @@ Extension of UIView to be formatted as future activity rows.
 	Opens an activity.
 	Opens an activity.
 	*/
 	*/
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":ROWFUTUREACTIVITY:DEBUG: Getting delegate and showing past activity \(self.id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showFutureActivity(id: self.id)
 		delegate.controller?.showFutureActivity(id: self.id)
 	}
 	}

+ 1 - 0
app/RowFutureActivity.xib

@@ -46,6 +46,7 @@
                                 </label>
                                 </label>
                                 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="xIf-kY-gPW" userLabel="Image">
                                 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="xIf-kY-gPW" userLabel="Image">
                                     <rect key="frame" x="10" y="69" width="71" height="64"/>
                                     <rect key="frame" x="10" y="69" width="71" height="64"/>
+                                    <rect key="frame" x="10" y="53" width="71" height="64"/>
                                     <constraints>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="64" id="GGt-lC-syI"/>
                                         <constraint firstAttribute="height" constant="64" id="GGt-lC-syI"/>
                                     </constraints>
                                     </constraints>

+ 0 - 2
app/RowGallery.swift

@@ -100,7 +100,6 @@ Extension of UIView to be formatted as sections.
 	Opens an album.
 	Opens an album.
 	*/
 	*/
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
 	func openAlbum(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":ROW_GALLERY:DEBUG: Getting delegate and showing album \(self.id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showAlbum(id: self.id)
 		delegate.controller?.showAlbum(id: self.id)
 	}
 	}
@@ -122,7 +121,6 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func setImage(idx: Int, filename: String){
 	func setImage(idx: Int, filename: String){
 		if (filename == ""){
 		if (filename == ""){
-			NSLog(":ROWGALLERY:DEBUG: No image for album \(self.id) at index \(idx).")
 			self.preview[idx].isHidden = true
 			self.preview[idx].isHidden = true
 		}
 		}
 		else{
 		else{

+ 24 - 17
app/RowHomeBlog.swift

@@ -26,23 +26,16 @@ Extension of UIView to be formatted as sections.
 */
 */
 @IBDesignable class RowHomeBlog: UIView {
 @IBDesignable class RowHomeBlog: UIView {
 
 
-	var id: Int!
-	
-	//The container.
+	// Outlets.
 	@IBOutlet weak var container: UIView!
 	@IBOutlet weak var container: UIView!
-	
-	//The entry
 	@IBOutlet weak var entry: UIView!
 	@IBOutlet weak var entry: UIView!
-	
-	//The post title.
 	@IBOutlet weak var title: UILabel!
 	@IBOutlet weak var title: UILabel!
-	
-	//The post text.
 	@IBOutlet weak var descrip: UILabel!
 	@IBOutlet weak var descrip: UILabel!
-	
-	//The image.
 	@IBOutlet weak var image: UIImageView!
 	@IBOutlet weak var image: UIImageView!
 	
 	
+	// Post ID.
+	var id: Int!
+	
 	
 	
 	/**
 	/**
 	Default constructor
 	Default constructor
@@ -58,7 +51,7 @@ Extension of UIView to be formatted as sections.
 	private func loadViewFromNib() {
 	private func loadViewFromNib() {
 		let bundle = Bundle(for: type(of: self))
 		let bundle = Bundle(for: type(of: self))
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
 		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
-		nib.instantiate(withOwner: self, options: nil).first
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
 	}
 	}
 	
 	
 	
 	
@@ -73,11 +66,16 @@ Extension of UIView to be formatted as sections.
 		self.frame = self.bounds
 		self.frame = self.bounds
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 		self.translatesAutoresizingMaskIntoConstraints = true
 		self.translatesAutoresizingMaskIntoConstraints = true
-		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-		container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
+		
+		self.container.frame = self.bounds
+		self.addSubview(self.container)
 		
 		
-		container.frame = self.bounds
-		self.addSubview(container)
+		// Set tap recognizer
+		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowHomeBlog.openPost (_:)))
+		tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+		self.addGestureRecognizer(tapRecognizer)
 	}
 	}
 	
 	
 	
 	
@@ -115,11 +113,20 @@ Extension of UIView to be formatted as sections.
 	func setImage(filename: String){
 	func setImage(filename: String){
 		if (filename == ""){
 		if (filename == ""){
 			// Hide the imageview
 			// Hide the imageview
-			self.image.isHidden = true
+			self.image.isHidden = true;
 		}
 		}
 		else{
 		else{
 			let path = "img/blog/thumb/\(filename)"
 			let path = "img/blog/thumb/\(filename)"
 			self.image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 			self.image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 		}
 		}
 	}
 	}
+	
+	
+	/**
+	Opens a post.
+	*/
+	func openPost(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPost(id: self.id)
+	}
 }
 }

+ 109 - 109
app/RowHomeBlog.xib

@@ -1,111 +1,111 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
-<device id="retina4_7" orientation="portrait">
-<adaptation id="fullscreen"/>
-</device>
-<dependencies>
-<deployment identifier="iOS"/>
-<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
-<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
-<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-</dependencies>
-<objects>
-<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeBlog" customModule="app">
-<connections>
-<outlet property="container" destination="2hI-rc-KPm" id="rWX-Vl-kOp"/>
-<outlet property="descrip" destination="f4E-5p-Bid" id="IF5-ck-qUL"/>
-<outlet property="entry" destination="wLM-VU-VYk" id="Gkq-yE-fdN"/>
-<outlet property="image" destination="WSe-uz-Uhz" id="iU4-jm-UzQ"/>
-<outlet property="title" destination="Bkz-DV-HVr" id="1ok-yI-Npt"/>
-</connections>
-</placeholder>
-<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-<view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomePastActivities" customClass="RowHomePastActivities" customModule="app">
-<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
-<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-<subviews>
-<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
-<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
-<subviews>
-<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
-<rect key="frame" x="10" y="10" width="355" height="667"/>
-<subviews>
-<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bkz-DV-HVr" userLabel="Title">
-<rect key="frame" x="10" y="10" width="335" height="21.5"/>
-<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
-<color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
-<nil key="highlightedColor"/>
-</label>
-<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
-<rect key="frame" x="10" y="40" width="89" height="64"/>
-<constraints>
-<constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
-</constraints>
-</imageView>
-<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
-<rect key="frame" x="98" y="40" width="214" height="64"/>
-<fontDescription key="fontDescription" type="system" pointSize="17"/>
-<nil key="textColor"/>
-<nil key="highlightedColor"/>
-</label>
-</subviews>
-<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
-<constraints>
-<constraint firstItem="WSe-uz-Uhz" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.2" id="9Lz-WQ-1aS"/>
-<constraint firstItem="f4E-5p-Bid" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Emi-Ob-27Q"/>
-<constraint firstItem="Bkz-DV-HVr" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="LSz-FM-x2V"/>
-<constraint firstItem="f4E-5p-Bid" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.7" id="MdM-ps-4b8"/>
-<constraint firstAttribute="trailing" secondItem="Bkz-DV-HVr" secondAttribute="trailing" constant="10" id="MdM-yF-pmK"/>
-<constraint firstItem="WSe-uz-Uhz" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Pyf-oT-PQl"/>
-<constraint firstItem="WSe-uz-Uhz" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="YG6-eX-oTj"/>
-<constraint firstItem="Bkz-DV-HVr" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="10" id="mwG-d2-HQL"/>
-<constraint firstAttribute="trailing" secondItem="f4E-5p-Bid" secondAttribute="trailing" constant="10" id="svU-xx-LsR"/>
-</constraints>
-<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
-<userDefinedRuntimeAttributes>
-<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
-<color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-</userDefinedRuntimeAttribute>
-<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
-<real key="value" value="1"/>
-</userDefinedRuntimeAttribute>
-<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
-<real key="value" value="3"/>
-</userDefinedRuntimeAttribute>
-</userDefinedRuntimeAttributes>
-</view>
-</subviews>
-<constraints>
-<constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
-<constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
-<constraint firstAttribute="height" constant="120" id="PdT-5v-I0r"/>
-<constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
-<constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
-</constraints>
-<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
-<userDefinedRuntimeAttributes>
-<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
-<real key="value" value="0.0"/>
-</userDefinedRuntimeAttribute>
-</userDefinedRuntimeAttributes>
-</view>
-</subviews>
-<constraints>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="Kwy-25-YES"/>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="htS-q0-otF"/>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
-</constraints>
-<nil key="simulatedStatusBarMetrics"/>
-<userDefinedRuntimeAttributes>
-<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
-<real key="value" value="0.0"/>
-</userDefinedRuntimeAttribute>
-</userDefinedRuntimeAttributes>
-<point key="canvasLocation" x="45.5" y="-43.5"/>
-</view>
-</objects>
-<resources>
-<image name="PhotoPlaceholder" width="170" height="108"/>
-</resources>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
+        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeBlog" customModule="app">
+            <connections>
+                <outlet property="container" destination="2hI-rc-KPm" id="rWX-Vl-kOp"/>
+                <outlet property="descrip" destination="f4E-5p-Bid" id="IF5-ck-qUL"/>
+                <outlet property="entry" destination="wLM-VU-VYk" id="Gkq-yE-fdN"/>
+                <outlet property="image" destination="WSe-uz-Uhz" id="iU4-jm-UzQ"/>
+                <outlet property="title" destination="Bkz-DV-HVr" id="1ok-yI-Npt"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomePastActivities" customClass="RowHomePastActivities" customModule="app">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
+                    <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="667"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bkz-DV-HVr" userLabel="Title">
+                                    <rect key="frame" x="10" y="10" width="335" height="21.5"/>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+                                    <color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
+                                    <rect key="frame" x="10" y="40" width="71" height="64"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
+                                    </constraints>
+                                </imageView>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
+                                    <rect key="frame" x="96.5" y="40" width="248.5" height="20.5"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <nil key="textColor"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                            </subviews>
+                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                            <constraints>
+                                <constraint firstItem="WSe-uz-Uhz" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.2" id="9Lz-WQ-1aS"/>
+                                <constraint firstItem="f4E-5p-Bid" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Emi-Ob-27Q"/>
+                                <constraint firstItem="Bkz-DV-HVr" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="LSz-FM-x2V"/>
+                                <constraint firstItem="f4E-5p-Bid" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.7" id="MdM-ps-4b8"/>
+                                <constraint firstAttribute="trailing" secondItem="Bkz-DV-HVr" secondAttribute="trailing" constant="10" id="MdM-yF-pmK"/>
+                                <constraint firstItem="WSe-uz-Uhz" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Pyf-oT-PQl"/>
+                                <constraint firstItem="WSe-uz-Uhz" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="YG6-eX-oTj"/>
+                                <constraint firstItem="Bkz-DV-HVr" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="10" id="mwG-d2-HQL"/>
+                                <constraint firstAttribute="trailing" secondItem="f4E-5p-Bid" secondAttribute="trailing" constant="10" id="svU-xx-LsR"/>
+                            </constraints>
+                            <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                            <userDefinedRuntimeAttributes>
+                                <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                    <color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                    <real key="value" value="1"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                    <real key="value" value="3"/>
+                                </userDefinedRuntimeAttribute>
+                            </userDefinedRuntimeAttributes>
+                        </view>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
+                        <constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
+                        <constraint firstAttribute="height" constant="120" id="PdT-5v-I0r"/>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
+                    </constraints>
+                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                            <real key="value" value="0.0"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </view>
+            </subviews>
+            <constraints>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="Kwy-25-YES"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="htS-q0-otF"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
+            </constraints>
+            <nil key="simulatedStatusBarMetrics"/>
+            <userDefinedRuntimeAttributes>
+                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                    <real key="value" value="0.0"/>
+                </userDefinedRuntimeAttribute>
+            </userDefinedRuntimeAttributes>
+            <point key="canvasLocation" x="45.5" y="-43.5"/>
+        </view>
+    </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
 </document>
 </document>

+ 0 - 1
app/RowHomeFutureActivities.swift

@@ -126,7 +126,6 @@ Extension of UIView to be formatted as sections.
 	Opens an activity.
 	Opens an activity.
 	*/
 	*/
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":ROWFUTUREACTIVITY:DEBUG: Getting delegate and showing past activity \(self.id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showFutureActivity(id: self.id)
 		delegate.controller?.showFutureActivity(id: self.id)
 	}
 	}

+ 109 - 109
app/RowHomeFutureActivities.xib

@@ -1,111 +1,111 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
-<device id="retina4_7" orientation="portrait">
-<adaptation id="fullscreen"/>
-</device>
-<dependencies>
-<deployment identifier="iOS"/>
-<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
-<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
-<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-</dependencies>
-<objects>
-<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeFutureActivities" customModule="app">
-<connections>
-<outlet property="container" destination="2hI-rc-KPm" id="rWX-Vl-kOp"/>
-<outlet property="descrip" destination="f4E-5p-Bid" id="IF5-ck-qUL"/>
-<outlet property="entry" destination="wLM-VU-VYk" id="Gkq-yE-fdN"/>
-<outlet property="image" destination="WSe-uz-Uhz" id="iU4-jm-UzQ"/>
-<outlet property="title" destination="Bkz-DV-HVr" id="1ok-yI-Npt"/>
-</connections>
-</placeholder>
-<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-<view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomePastActivities" customClass="RowHomePastActivities" customModule="app">
-<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
-<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-<subviews>
-<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
-<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
-<subviews>
-<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
-<rect key="frame" x="10" y="10" width="355" height="667"/>
-<subviews>
-<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bkz-DV-HVr" userLabel="Title">
-<rect key="frame" x="10" y="10" width="335" height="21.5"/>
-<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
-<color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
-<nil key="highlightedColor"/>
-</label>
-<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
-<rect key="frame" x="10" y="40" width="89" height="64"/>
-<constraints>
-<constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
-</constraints>
-</imageView>
-<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
-<rect key="frame" x="98" y="40" width="214" height="64"/>
-<fontDescription key="fontDescription" type="system" pointSize="17"/>
-<nil key="textColor"/>
-<nil key="highlightedColor"/>
-</label>
-</subviews>
-<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
-<constraints>
-<constraint firstItem="WSe-uz-Uhz" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.2" id="9Lz-WQ-1aS"/>
-<constraint firstItem="f4E-5p-Bid" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Emi-Ob-27Q"/>
-<constraint firstItem="Bkz-DV-HVr" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="LSz-FM-x2V"/>
-<constraint firstItem="f4E-5p-Bid" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.7" id="MdM-ps-4b8"/>
-<constraint firstAttribute="trailing" secondItem="Bkz-DV-HVr" secondAttribute="trailing" constant="10" id="MdM-yF-pmK"/>
-<constraint firstItem="WSe-uz-Uhz" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Pyf-oT-PQl"/>
-<constraint firstItem="WSe-uz-Uhz" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="YG6-eX-oTj"/>
-<constraint firstItem="Bkz-DV-HVr" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="10" id="mwG-d2-HQL"/>
-<constraint firstAttribute="trailing" secondItem="f4E-5p-Bid" secondAttribute="trailing" constant="10" id="svU-xx-LsR"/>
-</constraints>
-<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
-<userDefinedRuntimeAttributes>
-<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
-<color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-</userDefinedRuntimeAttribute>
-<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
-<real key="value" value="1"/>
-</userDefinedRuntimeAttribute>
-<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
-<real key="value" value="3"/>
-</userDefinedRuntimeAttribute>
-</userDefinedRuntimeAttributes>
-</view>
-</subviews>
-<constraints>
-<constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
-<constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
-<constraint firstAttribute="height" constant="120" id="PdT-5v-I0r"/>
-<constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
-<constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
-</constraints>
-<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
-<userDefinedRuntimeAttributes>
-<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
-<real key="value" value="0.0"/>
-</userDefinedRuntimeAttribute>
-</userDefinedRuntimeAttributes>
-</view>
-</subviews>
-<constraints>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="Kwy-25-YES"/>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="htS-q0-otF"/>
-<constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
-</constraints>
-<nil key="simulatedStatusBarMetrics"/>
-<userDefinedRuntimeAttributes>
-<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
-<real key="value" value="0.0"/>
-</userDefinedRuntimeAttribute>
-</userDefinedRuntimeAttributes>
-<point key="canvasLocation" x="45.5" y="-43.5"/>
-</view>
-</objects>
-<resources>
-<image name="PhotoPlaceholder" width="170" height="108"/>
-</resources>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
+        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeFutureActivities" customModule="app">
+            <connections>
+                <outlet property="container" destination="2hI-rc-KPm" id="rWX-Vl-kOp"/>
+                <outlet property="descrip" destination="f4E-5p-Bid" id="IF5-ck-qUL"/>
+                <outlet property="entry" destination="wLM-VU-VYk" id="Gkq-yE-fdN"/>
+                <outlet property="image" destination="WSe-uz-Uhz" id="iU4-jm-UzQ"/>
+                <outlet property="title" destination="Bkz-DV-HVr" id="1ok-yI-Npt"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomePastActivities" customClass="RowHomePastActivities" customModule="app">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
+                    <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="667"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bkz-DV-HVr" userLabel="Title">
+                                    <rect key="frame" x="10" y="10" width="335" height="21.5"/>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+                                    <color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
+                                    <rect key="frame" x="10" y="40" width="71" height="64"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
+                                    </constraints>
+                                </imageView>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
+                                    <rect key="frame" x="96.5" y="40" width="248.5" height="20.5"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <nil key="textColor"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                            </subviews>
+                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                            <constraints>
+                                <constraint firstItem="WSe-uz-Uhz" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.2" id="9Lz-WQ-1aS"/>
+                                <constraint firstItem="f4E-5p-Bid" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Emi-Ob-27Q"/>
+                                <constraint firstItem="Bkz-DV-HVr" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="LSz-FM-x2V"/>
+                                <constraint firstItem="f4E-5p-Bid" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.7" id="MdM-ps-4b8"/>
+                                <constraint firstAttribute="trailing" secondItem="Bkz-DV-HVr" secondAttribute="trailing" constant="10" id="MdM-yF-pmK"/>
+                                <constraint firstItem="WSe-uz-Uhz" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Pyf-oT-PQl"/>
+                                <constraint firstItem="WSe-uz-Uhz" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="YG6-eX-oTj"/>
+                                <constraint firstItem="Bkz-DV-HVr" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="10" id="mwG-d2-HQL"/>
+                                <constraint firstAttribute="trailing" secondItem="f4E-5p-Bid" secondAttribute="trailing" constant="10" id="svU-xx-LsR"/>
+                            </constraints>
+                            <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                            <userDefinedRuntimeAttributes>
+                                <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                    <color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                    <real key="value" value="1"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                    <real key="value" value="3"/>
+                                </userDefinedRuntimeAttribute>
+                            </userDefinedRuntimeAttributes>
+                        </view>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
+                        <constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
+                        <constraint firstAttribute="height" constant="120" id="PdT-5v-I0r"/>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
+                    </constraints>
+                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                            <real key="value" value="0.0"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </view>
+            </subviews>
+            <constraints>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="Kwy-25-YES"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="htS-q0-otF"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
+            </constraints>
+            <nil key="simulatedStatusBarMetrics"/>
+            <userDefinedRuntimeAttributes>
+                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                    <real key="value" value="0.0"/>
+                </userDefinedRuntimeAttribute>
+            </userDefinedRuntimeAttributes>
+            <point key="canvasLocation" x="45.5" y="-43.5"/>
+        </view>
+    </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
 </document>
 </document>

+ 77 - 1
app/RowHomeGallery.swift

@@ -34,6 +34,9 @@ Extension of UIView to be formatted as sections.
 	
 	
 	var photos: [UIImageView] = []
 	var photos: [UIImageView] = []
 	
 	
+	var photoIds: [Int] = [-1, -1, -1, -1]
+	var albumIds: [Int] = [-1, -1, -1, -1]
+	
 	
 	
 	/**
 	/**
 	Default constructor
 	Default constructor
@@ -61,7 +64,14 @@ Extension of UIView to be formatted as sections.
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()
-		self.addSubview(self.container)
+		
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		self.container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.container.translatesAutoresizingMaskIntoConstraints = true
+		self.container.frame = self.bounds
+		self.addSubview(container)
 		
 		
 		self.photos = [photo0, photo1, photo2, photo3]
 		self.photos = [photo0, photo1, photo2, photo3]
 		
 		
@@ -70,6 +80,42 @@ Extension of UIView to be formatted as sections.
 	}
 	}
 	
 	
 	
 	
+	/**
+	Open the first photo in the photo viewer.
+	*/
+	func openFirstPhoto(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPhoto(album: self.albumIds[0], photo: self.photoIds[0])
+	}
+	
+	
+	/**
+	Open the second photo in the photo viewer.
+	*/
+	func openSecondPhoto(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPhoto(album: self.albumIds[1], photo: self.photoIds[1])
+	}
+	
+	
+	/**
+	Open the third photo in the photo viewer.
+	*/
+	func openThirdPhoto(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPhoto(album: self.albumIds[2], photo: self.photoIds[2])
+	}
+	
+	
+	/**
+	Open the fourth photo in the photo viewer.
+	*/
+	func openFourthPhoto(_ sender:UITapGestureRecognizer? = nil){
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPhoto(album: self.albumIds[3], photo: self.photoIds[3])
+	}
+	
+	
 	/**
 	/**
 	Default constructor for the interface builder
 	Default constructor for the interface builder
 	*/
 	*/
@@ -91,6 +137,36 @@ Extension of UIView to be formatted as sections.
 		else{
 		else{
 			let path = "img/galeria/thumb/\(filename)"
 			let path = "img/galeria/thumb/\(filename)"
 			photos[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
 			photos[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+			
+			// Set tap recognizer
+			switch idx{
+				case 0:
+					let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowHomeGallery.openFirstPhoto(_:)))
+					tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+					self.photos[idx].isUserInteractionEnabled = true
+					self.photos[idx].addGestureRecognizer(tapRecognizer)
+					break;
+				case 1:
+					let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowHomeGallery.openSecondPhoto(_:)))
+					tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+					self.photos[idx].isUserInteractionEnabled = true
+					self.photos[idx].addGestureRecognizer(tapRecognizer)
+					break;
+				case 2:
+					let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowHomeGallery.openThirdPhoto(_:)))
+					tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+					self.photos[idx].isUserInteractionEnabled = true
+					self.photos[idx].addGestureRecognizer(tapRecognizer)
+					break;
+				case 3:
+					let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowHomeGallery.openFourthPhoto(_:)))
+					tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+					self.photos[idx].isUserInteractionEnabled = true
+					self.photos[idx].addGestureRecognizer(tapRecognizer)
+					break;
+				default:
+					NSLog(":ROWHOMEGALLERY:ERROR: Trying to set tap recognizer for invalid photo index \(idx).")
+			}
 		}
 		}
 	}
 	}
 	
 	

+ 2 - 2
app/RowHomeGallery.xib

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     </dependencies>

+ 0 - 1
app/RowHomePastActivities.swift

@@ -126,7 +126,6 @@ Extension of UIView to be formatted as past activity rows.
 	Opens an activity.
 	Opens an activity.
 	*/
 	*/
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":ROWPASTACTIVITY:DEBUG: Getting delegate and showing past activity \(self.id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showPastActivity(id: self.id)
 		delegate.controller?.showPastActivity(id: self.id)
 	}
 	}

+ 10 - 5
app/RowHomePastActivities.xib

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     </dependencies>
@@ -36,14 +36,19 @@
                                     <color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
                                     <color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
                                     <nil key="highlightedColor"/>
                                     <nil key="highlightedColor"/>
                                 </label>
                                 </label>
-                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
-                                    <rect key="frame" x="10" y="40" width="89" height="64"/>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
+                                    <rect key="frame" x="10" y="40" width="71" height="64"/>
                                     <constraints>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
                                         <constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
                                     </constraints>
                                     </constraints>
+                                    <userDefinedRuntimeAttributes>
+                                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                            <real key="value" value="0.0"/>
+                                        </userDefinedRuntimeAttribute>
+                                    </userDefinedRuntimeAttributes>
                                 </imageView>
                                 </imageView>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
-                                    <rect key="frame" x="98" y="40" width="214" height="64"/>
+                                    <rect key="frame" x="96.5" y="40" width="248.5" height="20.5"/>
                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                     <nil key="textColor"/>
                                     <nil key="textColor"/>
                                     <nil key="highlightedColor"/>
                                     <nil key="highlightedColor"/>

+ 0 - 1
app/RowLablancaOffer.swift

@@ -68,7 +68,6 @@ Extension of UIView to be formatted as sections.
 	:param: i Custom identifier
 	:param: i Custom identifier
 	*/
 	*/
 	init(s: String, i: Int) {
 	init(s: String, i: Int) {
-		NSLog(":ROWLABLANCAOFFER:DEBUG: Init \(s), \(i)")
 		
 		
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
 		loadViewFromNib()
 		loadViewFromNib()

+ 0 - 1
app/RowPastActivity.swift

@@ -124,7 +124,6 @@ Extension of UIView to be formatted as sections.
 	Opens an activity.
 	Opens an activity.
 	*/
 	*/
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
 	func openActivity(_ sender:UITapGestureRecognizer? = nil){
-		NSLog(":ROWPASTACTIVITY:DEBUG: Getting delegate and showing past activity \(self.id).")
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
 		delegate.controller?.showPastActivity(id: self.id)
 		delegate.controller?.showPastActivity(id: self.id)
 	}
 	}

+ 3 - 3
app/RowPastActivity.xib

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     </dependencies>
@@ -35,7 +35,7 @@
                                     <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
                                     <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
                                     <nil key="highlightedColor"/>
                                     <nil key="highlightedColor"/>
                                 </label>
                                 </label>
-                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="dtJ-G2-LyM" userLabel="Image">
+                                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="dtJ-G2-LyM" userLabel="Image">
                                     <rect key="frame" x="10" y="40" width="71" height="64"/>
                                     <rect key="frame" x="10" y="40" width="71" height="64"/>
                                     <constraints>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="64" id="5JB-2b-om6"/>
                                         <constraint firstAttribute="height" constant="64" id="5JB-2b-om6"/>

+ 1 - 7
app/RowSchedule.swift

@@ -70,12 +70,6 @@ Extension of UIView to be formatted as sections.
 		
 		
 		container.frame = self.bounds
 		container.frame = self.bounds
 		self.addSubview(container)
 		self.addSubview(container)
-		
-		// Set tap recognizer
-		/*print("ROW_BLOG:DEBUG: set tap recognizer")
-		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (self.openPost (_:)))
-		tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
-		addGestureRecognizer(tapRecognizer)*/
 	}
 	}
 	
 	
 	
 	
@@ -164,6 +158,6 @@ Extension of UIView to be formatted as sections.
 	*/
 	*/
 	func openEvent(_ sender:UITapGestureRecognizer? = nil){
 	func openEvent(_ sender:UITapGestureRecognizer? = nil){
 		// TODO implement openEvent.
 		// TODO implement openEvent.
-		print("ROW_BLOG:DEBUG: Open Event")
+		NSLog(":ROWSCHEDULE:DEBUG: Open Event")
 	}
 	}
 }
 }

+ 0 - 1
app/ScheduleViewController.swift

@@ -325,7 +325,6 @@ class ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
 	:param: increment Days to advance the schedule. Negative values to back it up.
 	:param: increment Days to advance the schedule. Negative values to back it up.
 	*/
 	*/
 	func changeDay(increment: Int){
 	func changeDay(increment: Int){
-		NSLog(":SCHEDULECONTROLLER:DEBUG: Change day increment: \(increment)")
 		self.selectedDay = self.selectedDay + increment
 		self.selectedDay = self.selectedDay + increment
 		if self.selectedDay <= -1{
 		if self.selectedDay <= -1{
 			self.selectedDay = 0
 			self.selectedDay = 0

+ 128 - 63
app/Sync.swift

@@ -28,6 +28,11 @@ Class to handle server sync.
 class Sync{
 class Sync{
 	
 	
 	var initial: Bool = false
 	var initial: Bool = false
+	var vBlog: Int = 0
+	var vActivities: Int = 0
+	var vGallery: Int = 0
+	var vBlanca: Int = 0
+	var vAll: Int = 0
 	
 	
 	/**
 	/**
 	Starts the sync process.
 	Starts the sync process.
@@ -56,14 +61,34 @@ class Sync{
 	:returns: The URL.
 	:returns: The URL.
 	*/
 	*/
 	func buildUrl() -> URL{
 	func buildUrl() -> URL{
-		let url = URL(string: "https://margolariak.com/API/v1/sync.php?client=com.margolariak.app")
-		//TODO add parameters
+		let defaults = UserDefaults.standard
+		var uId: String = "unknown"
+		if defaults.value(forKey: "versionAll") != nil{
+			self.vAll = defaults.value(forKey: "versionAll") as! Int
+		}
+		if defaults.value(forKey: "versionBlog") != nil{
+			self.vAll = defaults.value(forKey: "versionBlog") as! Int
+		}
+		if defaults.value(forKey: "versionActivities") != nil{
+			self.vActivities = defaults.value(forKey: "versionActivities") as! Int
+		}
+		if defaults.value(forKey: "versionGallery") != nil{
+			self.vGallery = defaults.value(forKey: "versionGallery") as! Int
+		}
+		if defaults.value(forKey: "versionBlanca") != nil{
+			self.vBlanca = defaults.value(forKey: "versionBlanca") as! Int
+		}
+		if defaults.value(forKey: "userId") != nil{
+			uId = defaults.value(forKey: "userId") as! String
+		}
+		let url = URL(string: "https://margolariak.com/API/v1/sync.php?client=com.margolariak.app&user=\(uId)&action=sync&version=\(self.vAll)")
+		
 		return url!
 		return url!
 	}
 	}
 	
 	
 	/**
 	/**
 	Performs an asynchronous sync.
 	Performs an asynchronous sync.
-	It fethes the info from the server and stores as Core Data
+	It fetches the info from the server and stores as Core Data
 	:param: url The url to sync.
 	:param: url The url to sync.
 	*/
 	*/
 	func sync(url: URL){
 	func sync(url: URL){
@@ -82,66 +107,94 @@ class Sync{
 			}
 			}
 			
 			
 			NSLog(":SYNC:LOG: Data received.")
 			NSLog(":SYNC:LOG: Data received.")
+			let defaults = UserDefaults.standard
 			
 			
 			var strData = String(data:data, encoding: String.Encoding.utf8)
 			var strData = String(data:data, encoding: String.Encoding.utf8)
 			
 			
+			var strVersions = ""
+			if strData != nil{
+				strVersions = (strData?.subStr(start : (strData?.indexOf(target : "\"version\":")!)! + 11, end : (strData?.indexOf(target : "}]}")!)! + 1))!
+			}
+			var vrAll: Int = 0
+			var vrBlog: Int = 0
+			var vrActivities: Int = 0
+			var vrGallery: Int = 0
+			var vrBlanca: Int = 0
+			vrAll = Int(strVersions.subStr(start : strVersions.indexOf(target : "\"all\":")! + 7, end : strVersions.indexOf(target : "}")!-2))!
+			strVersions = strVersions.subStr(start : strVersions.indexOf(target : ",")! + 1, end : strVersions.length - 1)
+			vrBlog = Int(strVersions.subStr(start : strVersions.indexOf(target : "\"blog\":")! + 8, end : strVersions.indexOf(target : "}")!-2))!
+			strVersions = strVersions.subStr(start : strVersions.indexOf(target : ",")! + 1, end : strVersions.length - 1)
+			vrActivities = Int(strVersions.subStr(start : strVersions.indexOf(target : "\"activities\":")! + 14, end : strVersions.indexOf(target : "}")!-2))!
+			strVersions = strVersions.subStr(start : strVersions.indexOf(target : ",")! + 1, end : strVersions.length - 1)
+			vrGallery = Int(strVersions.subStr(start : strVersions.indexOf(target : "\"gallery\":")! + 11, end : strVersions.indexOf(target : "}")!-2))!
+			strVersions = strVersions.subStr(start : strVersions.indexOf(target : ",")! + 1, end : strVersions.length - 1)
+			vrBlanca = Int(strVersions.subStr(start : strVersions.indexOf(target : "\"lablanca\":")! + 12, end : strVersions.indexOf(target : "}")!-2))!
+			
 			let dataIdx = strData?.indexOf(target: "{\"data\"")
 			let dataIdx = strData?.indexOf(target: "{\"data\"")
 			strData = strData!.subStr(start: dataIdx!, end: strData!.length - 1)
 			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 dataActivityItinerary : [String] = self.getTable(data: strData!, table: "activity_itinerary")
-			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")
+			//Get tables and save them
+			if vrActivities > self.vActivities || vrBlanca > self.vBlanca{
+				let dataPlace : [String] = self.getTable(data: strData!, table: "place")
+				self.saveTablePlace(entries: dataPlace)
+			}
+			if vrActivities > self.vActivities {
+				let dataActivity : [String] = self.getTable(data: strData!, table: "activity")
+				self.saveTableActivity(entries : dataActivity)
+				let dataActivityComment : [String] = self.getTable(data: strData!, table: "activity_comment")
+				self.saveTableActivityComment(entries : dataActivityComment)
+				let dataActivityImage : [String] = self.getTable(data: strData!, table: "activity_image")
+				self.saveTableActivityImage(entries : dataActivityImage)
+				let dataActivityTag : [String] = self.getTable(data: strData!, table: "activity_tag")
+				self.saveTableActivityTag(entries : dataActivityTag)
+				let dataActivityItinerary : [String] = self.getTable(data: strData!, table: "activity_itinerary")
+				self.saveTableActivityItinerary(entries : dataActivityItinerary)
+				defaults.set(vrActivities, forKey: "versionActivities")
+			}
+			if vrBlanca > self.vBlanca {
+				let dataPeople : [String] = self.getTable(data: strData!, table: "people")
+				self.saveTablePeople(entries: dataPeople)
+				let dataFestival : [String] = self.getTable(data: strData!, table: "festival")
+				self.saveTableFestival(entries: dataFestival)
+				let dataFestivalDay : [String] = self.getTable(data: strData!, table: "festival_day")
+				self.saveTableFestivalDay(entries: dataFestivalDay)
+				let dataFestivalEvent : [String] = self.getTable(data: strData!, table: "festival_event")
+				self.saveTableFestivalEvent(entries: dataFestivalEvent)
+				//let dataFestivalEventImage : [String] = self.getTable(data: strData!, table: "festival_event_image")
+				//
+				let dataFestivalOffer : [String] = self.getTable(data: strData!, table: "festival_offer")
+				self.saveTableFestivalOffer(entries: dataFestivalOffer)
+				defaults.set(vrBlanca, forKey: "versionBlanca")
+			}
+			if vrGallery > self.vGallery {
+				let dataAlbum : [String] = self.getTable(data: strData!, table: "album")
+				self.saveTableAlbum(entries: dataAlbum)
+				let dataPhoto : [String] = self.getTable(data: strData!, table: "photo")
+				self.saveTablePhoto(entries: dataPhoto)
+				let dataPhotoAlbum : [String] = self.getTable(data: strData!, table: "photo_album")
+				self.saveTablePhotoAlbum(entries: dataPhotoAlbum)
+				//let dataPhotoComment : [String] = self.getTable(data: strData!, table: "photo_comment")
+				//
+				defaults.set(vrGallery, forKey: "versionGallery")
+			}
+			if vrBlog > self.vBlog {
+				let dataPost : [String] = self.getTable(data: strData!, table: "post")
+				self.saveTablePost(entries: dataPost)
+				let dataPostComment : [String] = self.getTable(data: strData!, table: "post_comment")
+				self.saveTablePostComment(entries: dataPostComment)
+				let dataPostImage : [String] = self.getTable(data: strData!, table: "post_image")
+				self.saveTablePostImage(entries: dataPostImage)
+				let dataPostTag : [String] = self.getTable(data: strData!, table: "post_tag")
+				self.saveTablePostTag(entries: dataPostTag)
+				defaults.set(vrBlog, forKey: "versionBlog")
+			}
 			let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
 			let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
-			let dataSettings: [String] = self.getTable(data: strData!, table: "settings")
-			
-			//One by one, save the received data
-			self.saveTableActivity(entries : dataActivity)
-			self.saveTableActivityComment(entries : dataActivityComment)
-			self.saveTableActivityImage(entries : dataActivityImage)
-			self.saveTableActivityTag(entries : dataActivityTag)
-			self.saveTableActivityItinerary(entries : dataActivityItinerary)
-			
-			self.saveTablePost(entries: dataPost)
-			self.saveTablePostComment(entries: dataPostComment)
-			self.saveTablePostImage(entries: dataPostImage)
-			self.saveTablePostTag(entries: dataPostTag)
-			
-			self.saveTablePlace(entries: dataPlace)
-			self.saveTablePeople(entries: dataPeople)
-			
-			self.saveTableAlbum(entries: dataAlbum)
-			self.saveTablePhoto(entries: dataPhoto)
-			self.saveTablePhotoAlbum(entries: dataPhotoAlbum)
-			
-			self.saveTableFestival(entries: dataFestival)
-			self.saveTableFestivalDay(entries: dataFestivalDay)
-			self.saveTableFestivalOffer(entries: dataFestivalOffer)
-			self.saveTableFestivalEvent(entries: dataFestivalEvent)
-			
 			self.saveTableSponsor(entries: dataSponsor)
 			self.saveTableSponsor(entries: dataSponsor)
-			
+			let dataSettings: [String] = self.getTable(data: strData!, table: "settings")
 			self.saveSettings(entries: dataSettings)
 			self.saveSettings(entries: dataSettings)
-			
+			defaults.set(vrAll, forKey: "versionAll")
+				
+
 			// If it's the initial sync, hide the segue
 			// If it's the initial sync, hide the segue
 			if self.initial == true{
 			if self.initial == true{
 				NSLog(":SYNC:LOG: Finishing synchronous sync.")
 				NSLog(":SYNC:LOG: Finishing synchronous sync.")
@@ -493,9 +546,9 @@ class Sync{
 			var str = entry
 			var str = entry
 			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
 			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
 			
 			
-			//Get activity
+			//Get post
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let post : String = str.subStr(start : str.indexOf(target : "\"post\":")! + 8, end : str.indexOf(target : ",\"")! - 2)
+			let post : Int = Int(str.subStr(start : str.indexOf(target : "\"post\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
 			
 			
 			//Get text
 			//Get text
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
@@ -503,7 +556,7 @@ class Sync{
 			
 			
 			//Get dtime
 			//Get dtime
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			dateFormatter.dateFormat = "yyyy-MM-dd"
+			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
 			let dtime = dateFormatter.date(from : str.subStr(start : str.indexOf(target : "\"dtime\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
 			let dtime = dateFormatter.date(from : str.subStr(start : str.indexOf(target : "\"dtime\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
 			
 			
 			//Get username
 			//Get username
@@ -1270,17 +1323,23 @@ class Sync{
 			//Get title_es
 			//Get title_es
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let title_es : String = str.subStr(start : str.indexOf(target : "\"title_es\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
 			let title_es : String = str.subStr(start : str.indexOf(target : "\"title_es\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
-			row.setValue(title_es, forKey: "title_es")
+			if (title_es != "ul"){ //From "null"
+				row.setValue(title_es, forKey: "title_es")
+			}
 			
 			
 			//Get title_en
 			//Get title_en
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let title_en : String = str.subStr(start : str.indexOf(target : "\"title_en\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
 			let title_en : String = str.subStr(start : str.indexOf(target : "\"title_en\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
-			row.setValue(title_en, forKey: "title_en")
+			if (title_en != "ul"){ //From "null"
+				row.setValue(title_en, forKey: "title_en")
+			}
 			
 			
 			//Get title_eu
 			//Get title_eu
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let title_eu : String = str.subStr(start : str.indexOf(target : "\"title_eu\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
 			let title_eu : String = str.subStr(start : str.indexOf(target : "\"title_eu\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
-			row.setValue(title_eu, forKey: "title_eu")
+			if (title_eu != "ul"){ //From "null"
+				row.setValue(title_eu, forKey: "title_eu")
+			}
 			
 			
 			//Get description_es
 			//Get description_es
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
@@ -1758,11 +1817,17 @@ class Sync{
 
 
 			// Get day
 			// Get day
 			// Special item, not in the sync content
 			// Special item, not in the sync content
-			dateFormatter.dateFormat = "yyyy-MM-dd"
-			var day = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 11))!
+			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+			dateFormatter.calendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.ISO8601)! as Calendar
+			dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") as Locale!
+			//dateFormatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) as TimeZone!
+			dateFormatter.timeZone = NSTimeZone.local
+			var dayString = "\(str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 11)) 00:00:00"
+			var day = dateFormatter.date(from: dayString)!
 			// If on the first hours of the next day...
 			// If on the first hours of the next day...
 			let calendar = Calendar.current
 			let calendar = Calendar.current
-			let hours = calendar.component(.hour, from: day )
+			let hours = calendar.component(.hour, from: start )
+			
 			// ... the event belongs to the previous day.
 			// ... the event belongs to the previous day.
 			if hours < 6{
 			if hours < 6{
 				day = Calendar.current.date(byAdding: .day, value: -1, to: day)!	
 				day = Calendar.current.date(byAdding: .day, value: -1, to: day)!	

+ 30 - 40
app/ViewController.swift

@@ -45,6 +45,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	
 	
 	// Passed id to perform segues.
 	// Passed id to perform segues.
 	var passId: Int = -1
 	var passId: Int = -1
+	var passAlbum: Int = -1
 	
 	
 	// Location-related variables.
 	// Location-related variables.
 	var locationManager = CLLocationManager()
 	var locationManager = CLLocationManager()
@@ -59,7 +60,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	:param: coder Coder.
 	:param: coder Coder.
 	*/
 	*/
 	required init?(coder aDecoder: NSCoder) {
 	required init?(coder aDecoder: NSCoder) {
-		NSLog(":CONTROLLER:DEBUG: Init!")
 		super.init(coder: aDecoder)
 		super.init(coder: aDecoder)
 		
 		
 	}
 	}
@@ -85,7 +85,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	:param: id The post id.
 	:param: id The post id.
 	*/
 	*/
 	func showPost(id: Int){
 	func showPost(id: Int){
-		NSLog(":CONTROLLER:DEBUG: Showing Post \(id)")
 		self.passId = id
 		self.passId = id
 		performSegue(withIdentifier: "SeguePost", sender: nil)
 		performSegue(withIdentifier: "SeguePost", sender: nil)
 	}
 	}
@@ -96,7 +95,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	:param: id The activity id.
 	:param: id The activity id.
 	*/
 	*/
 	func showPastActivity(id: Int){
 	func showPastActivity(id: Int){
-		NSLog(":CONTROLLER:DEBUG: Showing past activity \(id)")
 		self.passId = id
 		self.passId = id
 		performSegue(withIdentifier: "SeguePastActivity", sender: nil)
 		performSegue(withIdentifier: "SeguePastActivity", sender: nil)
 	}
 	}
@@ -107,7 +105,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	:param: id The activity id.
 	:param: id The activity id.
 	*/
 	*/
 	func showFutureActivity(id: Int){
 	func showFutureActivity(id: Int){
-		NSLog(":CONTROLLER:DEBUG: Showing future activity \(id)")
 		self.passId = id
 		self.passId = id
 		performSegue(withIdentifier: "SegueFutureActivity", sender: nil)
 		performSegue(withIdentifier: "SegueFutureActivity", sender: nil)
 	}
 	}
@@ -118,18 +115,27 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	:param: id The album id.
 	:param: id The album id.
 	*/
 	*/
 	func showAlbum(id: Int){
 	func showAlbum(id: Int){
-		NSLog(":CONTROLLER:DEBUG: Showing album \(id)")
 		self.passId = id
 		self.passId = id
 		performSegue(withIdentifier: "SegueAlbum", sender: nil)
 		performSegue(withIdentifier: "SegueAlbum", sender: nil)
 	}
 	}
 	
 	
 	
 	
+	/**
+	Shows a photo.
+	:param: id The album id.
+	*/
+	func showPhoto(album: Int, photo: Int){
+		self.passAlbum = album
+		self.passId = photo
+		performSegue(withIdentifier: "SeguePhoto", sender: nil)
+	}
+	
+	
 	/**
 	/**
 	Shows a schedule.
 	Shows a schedule.
 	:param: margolari True for the margolari schedule, false for the city one.
 	:param: margolari True for the margolari schedule, false for the city one.
 	*/
 	*/
 	func showSchedule(margolari: Bool){
 	func showSchedule(margolari: Bool){
-		NSLog(":CONTROLLER:DEBUG: Showing schedule. Margolari: \(margolari)")
 		if margolari == true{
 		if margolari == true{
 			self.passId = 1
 			self.passId = 1
 		}
 		}
@@ -140,19 +146,17 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 	
 	
 	
 	
-	/**
+	/** m
 	Handles the initial sync process.
 	Handles the initial sync process.
 	It can start it, showing the sync screen, or finish it, hidding the screen.
 	It can start it, showing the sync screen, or finish it, hidding the screen.
 	:param: showScreen True to start the sync, false to end it.
 	:param: showScreen True to start the sync, false to end it.
 	*/
 	*/
 	func initialSync(showScreen: Bool){
 	func initialSync(showScreen: Bool){
 		if showScreen == true{
 		if showScreen == true{
-			NSLog(":CONTROLLER:DEBUG: Showing initial sync screen.")
 			performSegue(withIdentifier: "SegueSync", sender: nil)
 			performSegue(withIdentifier: "SegueSync", sender: nil)
 			Sync(synchronous: true)
 			Sync(synchronous: true)
 		}
 		}
 		else{
 		else{
-			NSLog(":CONTROLLER:DEBUG: Re-populating views and hidding initial sync screen.")
 			NSLog(":CONTROLLER:DEBUG: Re-populating disabled: Throws error.")
 			NSLog(":CONTROLLER:DEBUG: Re-populating disabled: Throws error.")
 			//self.populate()
 			//self.populate()
 			syncSegue?.destination.dismiss(animated: true, completion: nil)
 			syncSegue?.destination.dismiss(animated: true, completion: nil)
@@ -166,13 +170,16 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	:sender: The calling view.
 	:sender: The calling view.
 	*/
 	*/
 	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
 	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
-		NSLog(":CONTROLLER:DEBUG: preparing for segue '\(String(describing: segue.identifier))' with id \(self.passId)")
 		if segue.identifier == "SeguePost"{
 		if segue.identifier == "SeguePost"{
 			(segue.destination as! PostViewController).id = passId
 			(segue.destination as! PostViewController).id = passId
 		}
 		}
 		if segue.identifier == "SegueAlbum"{
 		if segue.identifier == "SegueAlbum"{
 			(segue.destination as! AlbumViewController).id = passId
 			(segue.destination as! AlbumViewController).id = passId
 		}
 		}
+		if segue.identifier == "SeguePhoto"{
+			(segue.destination as! PhotoViewController).photoId = passId
+			(segue.destination as! PhotoViewController).albumId = passAlbum
+		}
 		if segue.identifier == "SegueSchedule"{
 		if segue.identifier == "SegueSchedule"{
 			if passId == 1{
 			if passId == 1{
 				(segue.destination as! ScheduleViewController).margolari = true
 				(segue.destination as! ScheduleViewController).margolari = true
@@ -193,7 +200,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	}
 	}
 	
 	
 	override func viewWillAppear(_ animated: Bool) {
 	override func viewWillAppear(_ animated: Bool) {
-		NSLog(":CONTROLLER:DEBUG: Forcing a call to populate")
 		self.populate()
 		self.populate()
 		super.viewWillAppear(animated)
 		super.viewWillAppear(animated)
 	}
 	}
@@ -218,14 +224,16 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		fetchLocation()
 		fetchLocation()
 		self.locationTimer = Timer.scheduledTimer(timeInterval: 90, target: self, selector: #selector(fetchLocation), userInfo: nil, repeats: true)
 		self.locationTimer = Timer.scheduledTimer(timeInterval: 90, target: self, selector: #selector(fetchLocation), userInfo: nil, repeats: true)
 				
 				
-		//NSLog(":CONTROLLER:DEBUG: Don't skyp sync")
-		NSLog(":CONTROLLER:DEBUG: Skyp sync")
-		//Sync()
+		NSLog(":CONTROLLER:DEBUG: Don't skyp sync")
+		//NSLog(":CONTROLLER:DEBUG: Skyp sync")
+		Sync()
 
 
 		
 		
 		self.delegate = UIApplication.shared.delegate as? AppDelegate
 		self.delegate = UIApplication.shared.delegate as? AppDelegate
 		self.delegate?.controller = self
 		self.delegate?.controller = self
 		
 		
+		//self.sectionCollection.visibleCells[0].isSelected = true
+		
 		super.viewDidLoad()
 		super.viewDidLoad()
 		
 		
 	}
 	}
@@ -239,6 +247,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	As of now, not working.
 	As of now, not working.
 	*/
 	*/
 	func populate(){
 	func populate(){
+		// TODO Set this up.
 		if (self.containerViewHome != nil){
 		if (self.containerViewHome != nil){
 			//(self.containerViewHome as HomeView).populate()
 			//(self.containerViewHome as HomeView).populate()
 			//let ng = self.containerViewHome.dbgTxt
 			//let ng = self.containerViewHome.dbgTxt
@@ -318,23 +327,19 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	
 	
 	//Make a cell for each section
 	//Make a cell for each section
 	func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 	func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-				
+		
+		var first = true
+		
 		//Get a reference to our storyboard cell
 		//Get a reference to our storyboard cell
 		let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! MenuCollectionViewCell
 		let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! MenuCollectionViewCell
 		
 		
 		//Set text
 		//Set text
 		cell.label.text = self.items[indexPath.item]
 		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)
+		// Mark the first one as selected.
+		if indexPath.item == 0{
+			cell.isSelected = true
+			first = false
 		}
 		}
 		
 		
 		return cell
 		return cell
@@ -354,18 +359,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	@IBAction func showComponent(selected: Int) {
 	@IBAction func showComponent(selected: Int) {
 		//Activate label
 		//Activate label
 		var i = 0
 		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
 		//Show the view
 		if selected == 0 {
 		if selected == 0 {
@@ -428,9 +421,6 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 				self.containerViewGallery.alpha = 1
 				self.containerViewGallery.alpha = 1
 			})
 			})
 		}
 		}
-		
 	}
 	}
-
-
 }
 }