Browse Source

XIB files for the album view.

Iñigo Valentin 9 years ago
parent
commit
826b6c2d3c
5 changed files with 539 additions and 0 deletions
  1. 12 0
      app.xcodeproj/project.pbxproj
  2. 164 0
      app/AlbumViewController.swift
  3. 179 0
      app/Base.lproj/Main.storyboard
  4. 115 0
      app/RowAlbum.swift
  5. 69 0
      app/RowAlbum.xib

+ 12 - 0
app.xcodeproj/project.pbxproj

@@ -22,6 +22,9 @@
 		935D6E2F1E86792000CED3A1 /* GalleryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935D6E2E1E86792000CED3A1 /* GalleryView.swift */; };
 		935D6E311E867C5E00CED3A1 /* RowGallery.xib in Resources */ = {isa = PBXBuildFile; fileRef = 935D6E301E867C5E00CED3A1 /* RowGallery.xib */; };
 		935D6E331E867C7E00CED3A1 /* RowGallery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935D6E321E867C7E00CED3A1 /* RowGallery.swift */; };
+		936966ED1E98445200A11055 /* AlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 936966EC1E98445200A11055 /* AlbumViewController.swift */; };
+		936966EF1E9848D600A11055 /* RowAlbum.xib in Resources */ = {isa = PBXBuildFile; fileRef = 936966EE1E9848D600A11055 /* RowAlbum.xib */; };
+		936966F11E984B5000A11055 /* RowAlbum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 936966F01E984B5000A11055 /* RowAlbum.swift */; };
 		937EA02D1E5B8B5300D0893A /* UIApplcation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 937EA02C1E5B8B5300D0893A /* UIApplcation.swift */; };
 		93B408031D9ED44C000FBC99 /* MenuCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93B408021D9ED44C000FBC99 /* MenuCollectionViewCell.swift */; };
 		93B5C01A1E872B4B0069BFF8 /* RowHomeGallery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93B5C0191E872B4B0069BFF8 /* RowHomeGallery.swift */; };
@@ -64,6 +67,9 @@
 		935D6E2E1E86792000CED3A1 /* GalleryView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GalleryView.swift; sourceTree = "<group>"; };
 		935D6E301E867C5E00CED3A1 /* RowGallery.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowGallery.xib; sourceTree = "<group>"; };
 		935D6E321E867C7E00CED3A1 /* RowGallery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowGallery.swift; sourceTree = "<group>"; };
+		936966EC1E98445200A11055 /* AlbumViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlbumViewController.swift; sourceTree = "<group>"; };
+		936966EE1E9848D600A11055 /* RowAlbum.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowAlbum.xib; sourceTree = "<group>"; };
+		936966F01E984B5000A11055 /* RowAlbum.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowAlbum.swift; sourceTree = "<group>"; };
 		937EA02C1E5B8B5300D0893A /* UIApplcation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIApplcation.swift; sourceTree = "<group>"; };
 		93B408021D9ED44C000FBC99 /* MenuCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MenuCollectionViewCell.swift; path = ../MenuCollectionViewCell.swift; sourceTree = "<group>"; };
 		93B5C0191E872B4B0069BFF8 /* RowHomeGallery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomeGallery.swift; sourceTree = "<group>"; };
@@ -163,6 +169,9 @@
 				935D6E321E867C7E00CED3A1 /* RowGallery.swift */,
 				93B5C0191E872B4B0069BFF8 /* RowHomeGallery.swift */,
 				93B5C01B1E872B600069BFF8 /* RowHomeGallery.xib */,
+				936966EC1E98445200A11055 /* AlbumViewController.swift */,
+				936966EE1E9848D600A11055 /* RowAlbum.xib */,
+				936966F01E984B5000A11055 /* RowAlbum.swift */,
 			);
 			path = app;
 			sourceTree = "<group>";
@@ -242,6 +251,7 @@
 				93BAD2F61E586310009DF853 /* RowHomeSocial.xib in Resources */,
 				93BAD2F21E585E88009DF853 /* RowHomeFutureActivities.xib in Resources */,
 				931AA5B01E219006003A2290 /* RowHomePastActivities.xib in Resources */,
+				936966EF1E9848D600A11055 /* RowAlbum.xib in Resources */,
 				93D9EA601DE271E700089002 /* Section.xib in Resources */,
 				93075C6A1E59CAB000396389 /* BlogView.xib in Resources */,
 				93B84BA41D9C31AB006C0F67 /* Assets.xcassets in Resources */,
@@ -263,6 +273,7 @@
 			files = (
 				93294FF81E336FA000FDAF50 /* Entry.swift in Sources */,
 				937EA02D1E5B8B5300D0893A /* UIApplcation.swift in Sources */,
+				936966F11E984B5000A11055 /* RowAlbum.swift in Sources */,
 				93D9EA641DE273FD00089002 /* Section.swift in Sources */,
 				93D9EA6A1DE3491100089002 /* HomeView.swift in Sources */,
 				93BEB6D21E7E878300C68DE5 /* PostViewController.swift in Sources */,
@@ -279,6 +290,7 @@
 				93B84B9A1D9C31AB006C0F67 /* AppDelegate.swift in Sources */,
 				93B84BA21D9C31AB006C0F67 /* app.xcdatamodeld in Sources */,
 				935D6E331E867C7E00CED3A1 /* RowGallery.swift in Sources */,
+				936966ED1E98445200A11055 /* AlbumViewController.swift in Sources */,
 				93D9EA681DE342AC00089002 /* UIView.swift in Sources */,
 				93075C701E59D04A00396389 /* RowBlog.swift in Sources */,
 				93B408031D9ED44C000FBC99 /* MenuCollectionViewCell.swift in Sources */,

+ 164 - 0
app/AlbumViewController.swift

@@ -0,0 +1,164 @@
+// 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 AlbumViewController: UIViewController, UIGestureRecognizerDelegate {
+	
+	@IBOutlet weak var barButton: UIButton!
+	@IBOutlet weak var barTitle: UILabel!
+	@IBOutlet weak var albumTitle: UILabel!
+	@IBOutlet weak var albumContainer: UIStackView!
+
+	// Album ID
+	var id: Int = -1
+	
+	// App delegate
+	var delegate: AppDelegate?
+	
+	// Id received from segue.
+	var passId: Int = -1
+	
+	func getContext () -> NSManagedObjectContext {
+		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
+	}
+	
+	/**
+	Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		NSLog(":GALLERYCONTROLLER:LOG: Init album.")
+		
+		super.viewDidLoad()
+		self.loadGallery(id: id)
+		
+		// Set button action
+		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+	}
+	
+	/**
+	Returns to the main view controller.
+	*/
+	func back() {
+		NSLog(":GALLERYCONTROLLER:DEBUG: Back")
+		self.dismiss(animated: true, completion: nil)
+	}
+	
+	
+	/**
+	Dispose of any resources that can be recreated.
+	*/
+	override func didReceiveMemoryWarning() {
+		super.didReceiveMemoryWarning()
+	}
+	
+	/**
+	Loads the photos of the album
+	*/
+	public func loadAlbum(id: Int){
+		
+		NSLog(":GALLERYCONTROLLER:DEBUG: Loading post \(id)")
+		
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		/*let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
+		
+		do {
+			//go get the results
+			let searchResults = try context.fetch(fetchRequest)
+			
+			var count = 0
+			var sTitle: String
+			var sText: String
+			var image: String
+			
+			//You need to convert to NSManagedObject to use 'for' loops
+			for r in searchResults as [NSManagedObject] {
+				count = count + 1
+				
+				sTitle = r.value(forKey: "title_\(lang)")! as! String
+				sText = r.value(forKey: "text_\(lang)")! as! String
+				postTitle.text = "  \(sTitle)"
+				postText.text = sText.stripHtml()
+				
+				// Get main image
+				image = ""
+				let imgFetchRequest: NSFetchRequest<Post_image> = Post_image.fetchRequest()
+				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
+				let imgSortDescriptors = [imgSortDescriptor]
+				imgFetchRequest.sortDescriptors = imgSortDescriptors
+				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
+				imgFetchRequest.fetchLimit = 1
+				//TODO get more images
+				do{
+					let imgSearchResults = try context.fetch(imgFetchRequest)
+					for imgR in imgSearchResults as [NSManagedObject]{
+						image = imgR.value(forKey: "image")! as! String
+						print ("POST:LOG: Image: \(image)")
+						//TODO set image
+						//row.setImage(filename: image)
+					}
+				} catch {
+					print("POST:ERROR: Error getting image for post \(id): \(error)")
+				}
+				
+			}
+		} catch {
+			print("POST:ERROR: Error with request: \(error)")
+		}
+		*/
+		
+		//Always at the end: update scrollview
+		// TODOs
+		//var h: Int = 0
+		//for view in scrollView.subviews {
+		//contentRect = contentRect.union(view.frame);
+		//	h = h + Int(view.frame.height) + 30 //Why 30?
+		//}
+		//print("POST:DEBUG: Height: \(h)")
+		// TODO: Calculate at the end
+		//self.scrollView.contentSize.height = 4500//CGFloat(h);
+		
+	}
+	
+	/**
+	Gets the device language.
+	:return: Two letter language code of the device.
+	*/
+	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"
+		}
+	}
+	
+}
+

+ 179 - 0
app/Base.lproj/Main.storyboard

@@ -186,6 +186,7 @@
                         <outlet property="containerViewLablanca" destination="nhy-Gy-cgq" id="bBa-2W-hjf"/>
                         <outlet property="containerViewLocation" destination="T4H-Rn-I4y" id="EFa-Km-WuR"/>
                         <segue destination="UkS-wI-Yhx" kind="show" identifier="SeguePost" id="gs2-jd-cPW"/>
+                        <segue destination="k0M-Sk-DZM" kind="show" identifier="SegueAlbum" id="Puc-tv-vaD"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
@@ -511,6 +512,184 @@
             </objects>
             <point key="canvasLocation" x="-728" y="1744"/>
         </scene>
+        <!--Album-->
+        <scene sceneID="R7a-5x-3QL">
+            <objects>
+                <viewController title="Album" id="k0M-Sk-DZM" customClass="AlbumViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="ONc-DJ-6Kh"/>
+                        <viewControllerLayoutGuide type="bottom" id="Jfy-ak-hpJ"/>
+                    </layoutGuides>
+                    <view key="view" autoresizesSubviews="NO" contentMode="scaleToFill" id="iBY-d9-Ye4" userLabel="Container">
+                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kLX-yW-lMr" userLabel="Toolbar">
+                                <rect key="frame" x="0.0" y="20" width="320" height="30"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Thj-0t-rxK">
+                                        <rect key="frame" x="0.0" y="0.0" width="48" height="30"/>
+                                        <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                                        <state key="normal" title="&lt;">
+                                            <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                        </state>
+                                    </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="LLe-aQ-Sbj">
+                                        <rect key="frame" x="48" y="0.0" width="224" height="30"/>
+                                        <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
+                                        <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                </subviews>
+                                <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <constraints>
+                                    <constraint firstItem="LLe-aQ-Sbj" firstAttribute="width" secondItem="kLX-yW-lMr" secondAttribute="width" multiplier="0.7" id="3sD-ex-RH9"/>
+                                    <constraint firstItem="LLe-aQ-Sbj" firstAttribute="centerY" secondItem="kLX-yW-lMr" secondAttribute="centerY" id="7Jj-rc-BTU"/>
+                                    <constraint firstItem="Thj-0t-rxK" firstAttribute="leading" secondItem="kLX-yW-lMr" secondAttribute="leading" id="Jcs-G1-TKC"/>
+                                    <constraint firstItem="Thj-0t-rxK" firstAttribute="centerY" secondItem="kLX-yW-lMr" secondAttribute="centerY" id="VWD-2l-QIQ"/>
+                                    <constraint firstItem="Thj-0t-rxK" firstAttribute="height" secondItem="kLX-yW-lMr" secondAttribute="height" id="XCm-uK-ZdM"/>
+                                    <constraint firstItem="LLe-aQ-Sbj" firstAttribute="height" secondItem="kLX-yW-lMr" secondAttribute="height" id="m2u-z2-gQX"/>
+                                    <constraint firstItem="LLe-aQ-Sbj" firstAttribute="centerX" secondItem="kLX-yW-lMr" secondAttribute="centerX" id="uyE-xa-dZu"/>
+                                    <constraint firstItem="Thj-0t-rxK" firstAttribute="width" secondItem="kLX-yW-lMr" secondAttribute="width" multiplier="0.15" id="uzO-gY-Kxq"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WEW-3s-kOI">
+                                <rect key="frame" x="0.0" y="50" width="320" height="518"/>
+                                <subviews>
+                                    <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kmd-tW-XIB">
+                                        <rect key="frame" x="0.0" y="0.0" width="320" height="518"/>
+                                        <subviews>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sej-1q-hlq" userLabel="Section">
+                                                <rect key="frame" x="10" y="10" width="300" height="1046"/>
+                                                <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="YsV-il-CeR" userLabel="Title">
+                                                        <rect key="frame" x="0.0" y="0.0" width="300" 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="1pw-9x-fqs"/>
+                                                        </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="NlX-b5-vyb" userLabel="Content">
+                                                        <rect key="frame" x="0.0" y="30" width="300" height="1016"/>
+                                                        <subviews>
+                                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YEF-04-q7Y" userLabel="Album">
+                                                                <rect key="frame" x="8" y="8" width="284" height="1000"/>
+                                                                <subviews>
+                                                                    <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="WRD-IZ-JpU">
+                                                                        <rect key="frame" x="0.0" y="0.0" width="284" height="1000"/>
+                                                                    </stackView>
+                                                                </subviews>
+                                                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                                <constraints>
+                                                                    <constraint firstItem="WRD-IZ-JpU" firstAttribute="centerY" secondItem="YEF-04-q7Y" secondAttribute="centerY" id="HMS-4q-ns8"/>
+                                                                    <constraint firstItem="WRD-IZ-JpU" firstAttribute="width" secondItem="YEF-04-q7Y" secondAttribute="width" id="Im5-F6-vGb"/>
+                                                                    <constraint firstAttribute="height" constant="1000" id="Ix6-5u-agq"/>
+                                                                    <constraint firstItem="WRD-IZ-JpU" firstAttribute="height" secondItem="YEF-04-q7Y" secondAttribute="height" id="U7o-HF-khX"/>
+                                                                    <constraint firstItem="WRD-IZ-JpU" firstAttribute="centerX" secondItem="YEF-04-q7Y" secondAttribute="centerX" id="jKg-n6-Kko"/>
+                                                                </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 firstItem="NlX-b5-vyb" firstAttribute="centerX" secondItem="sej-1q-hlq" secondAttribute="centerX" id="11D-qS-lDY"/>
+                                                    <constraint firstItem="YsV-il-CeR" firstAttribute="centerX" secondItem="sej-1q-hlq" secondAttribute="centerX" id="Oym-KM-sqY"/>
+                                                    <constraint firstItem="NlX-b5-vyb" firstAttribute="top" secondItem="YsV-il-CeR" secondAttribute="bottom" id="kG4-rx-MOP"/>
+                                                    <constraint firstItem="NlX-b5-vyb" firstAttribute="width" secondItem="sej-1q-hlq" secondAttribute="width" id="mxX-S0-Jhg"/>
+                                                    <constraint firstItem="YsV-il-CeR" firstAttribute="width" secondItem="sej-1q-hlq" secondAttribute="width" id="ql7-1w-gZt"/>
+                                                    <constraint firstItem="YsV-il-CeR" firstAttribute="top" secondItem="sej-1q-hlq" secondAttribute="top" id="tWs-7c-cHP"/>
+                                                    <constraint firstAttribute="bottom" secondItem="NlX-b5-vyb" secondAttribute="bottom" id="tfG-n0-ydH"/>
+                                                </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="sej-1q-hlq" firstAttribute="trailing" secondItem="Kmd-tW-XIB" secondAttribute="trailing" constant="10" id="Axn-3D-Qni"/>
+                                            <constraint firstItem="sej-1q-hlq" firstAttribute="top" secondItem="Kmd-tW-XIB" secondAttribute="top" constant="10" id="W3n-lX-oj8"/>
+                                            <constraint firstItem="sej-1q-hlq" firstAttribute="leading" secondItem="Kmd-tW-XIB" secondAttribute="leading" constant="10" id="k9J-Pf-W1C"/>
+                                            <constraint firstItem="sej-1q-hlq" firstAttribute="centerX" secondItem="Kmd-tW-XIB" secondAttribute="centerX" id="sn2-ir-MIe"/>
+                                            <constraint firstAttribute="bottom" secondItem="sej-1q-hlq" secondAttribute="bottom" constant="10" id="uH3-zh-3sM"/>
+                                        </constraints>
+                                        <edgeInsets key="layoutMargins" top="10" left="10" bottom="10" right="10"/>
+                                        <userDefinedRuntimeAttributes>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                <real key="value" value="0.0"/>
+                                            </userDefinedRuntimeAttribute>
+                                        </userDefinedRuntimeAttributes>
+                                    </scrollView>
+                                </subviews>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstAttribute="bottom" secondItem="Kmd-tW-XIB" secondAttribute="bottom" id="0Uz-ek-vBj"/>
+                                    <constraint firstItem="Kmd-tW-XIB" firstAttribute="width" secondItem="WEW-3s-kOI" secondAttribute="width" id="Bi9-mv-NSg"/>
+                                    <constraint firstItem="Kmd-tW-XIB" firstAttribute="top" secondItem="WEW-3s-kOI" secondAttribute="top" id="S3J-3p-RrM"/>
+                                    <constraint firstItem="Kmd-tW-XIB" firstAttribute="centerX" secondItem="WEW-3s-kOI" secondAttribute="centerX" id="aXw-Ot-IDF"/>
+                                </constraints>
+                                <userDefinedRuntimeAttributes>
+                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                        <color key="value" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    </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="kLX-yW-lMr" firstAttribute="top" secondItem="ONc-DJ-6Kh" secondAttribute="bottom" id="1cs-f7-eXV"/>
+                            <constraint firstItem="WEW-3s-kOI" firstAttribute="centerX" secondItem="iBY-d9-Ye4" secondAttribute="centerX" id="7rG-90-CBm"/>
+                            <constraint firstItem="WEW-3s-kOI" firstAttribute="width" secondItem="iBY-d9-Ye4" secondAttribute="width" id="L71-wc-a42"/>
+                            <constraint firstItem="WEW-3s-kOI" firstAttribute="top" secondItem="kLX-yW-lMr" secondAttribute="bottom" id="NlL-cF-RyX"/>
+                            <constraint firstItem="kLX-yW-lMr" firstAttribute="centerX" secondItem="iBY-d9-Ye4" secondAttribute="centerX" id="XK7-sC-KU0"/>
+                            <constraint firstAttribute="bottom" secondItem="WEW-3s-kOI" secondAttribute="bottom" id="h2X-Gs-sB2"/>
+                            <constraint firstItem="kLX-yW-lMr" firstAttribute="width" secondItem="iBY-d9-Ye4" secondAttribute="width" id="nmM-Cs-aC6"/>
+                        </constraints>
+                        <userDefinedRuntimeAttributes>
+                            <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                <real key="value" value="0.0"/>
+                            </userDefinedRuntimeAttribute>
+                        </userDefinedRuntimeAttributes>
+                    </view>
+                    <connections>
+                        <outlet property="albumContainer" destination="WRD-IZ-JpU" id="tSP-7c-APp"/>
+                        <outlet property="albumTitle" destination="YsV-il-CeR" id="t9S-NX-eaE"/>
+                        <outlet property="barButton" destination="Thj-0t-rxK" id="6bX-xo-abt"/>
+                        <outlet property="barTitle" destination="LLe-aQ-Sbj" id="bFR-jT-Xmq"/>
+                        <outlet property="postTitle" destination="YsV-il-CeR" id="Lg2-ea-EeY"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="GLj-OZ-Cqc" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-1978" y="1477"/>
+        </scene>
     </scenes>
     <resources>
         <image name="PhotoPlaceholder" width="170" height="108"/>

+ 115 - 0
app/RowAlbum.swift

@@ -0,0 +1,115 @@
+// 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 Foundation
+import UIKit
+
+/**
+Extension of UIView to be formatted as sections.
+*/
+@IBDesignable class RowAlbum: UIView {
+	
+	// Outlets
+	
+	@IBOutlet weak var photo0: UIImageView!
+	@IBOutlet weak var photo1: UIImageView!
+	
+	
+	// This view
+	var v: UIView!
+	
+	// Array with the imageviews
+	var preview: [UIImageView] = []
+
+	/**
+	Default constructor
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+	}
+	
+	/**
+	Loads the view from the xib with the same name as the class.
+	*/
+	private func loadViewFromNib() {
+		let bundle = Bundle(for: type(of: self))
+		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
+	}
+	
+	/**
+	Default constructor.
+	:param: s Custom identifier
+	:param: i Custom identifier
+	*/
+	init(s: String, i: Int) {
+		NSLog(":ROWALBUM:DEBUG: Init \(s), \(i)")
+		
+		super.init(frame: CGRect(x: 0, y: 0, width: 1000, height: 1000))
+		loadViewFromNib()
+		v = self
+		self.frame = bself.ounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		
+		//Populate review array
+		preview = [photo0, photo1]
+		
+		// Set tap recognizers
+		// TODO
+		//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (RowAlbum.openPhoto(_:)))
+		//tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+		//self.addGestureRecognizer(tapRecognizer)
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		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)
+	}
+	
+	/**
+	Changes the preview image of the photos.
+	If null or empty, the igage is hidden.
+	:param: idx Id of the image in the row. 0 for left, 1 for right.
+	:param: filename Filename of the image.
+	*/
+	func setImage(idx: Int, filename: String){
+		if (filename == ""){
+			NSLog(":ROWALBUM:DEBUG: No image for album \(self.id) at index \(idx).")
+			preview[idx].isHidden = true
+			//TODO hide the imageview
+		}
+		else{
+			NSLog(":ROWALBUM:DEBUG: Set image \(filename) for at index \(idx).")
+			let path = "img/galeria/thumb/\(filename)"
+			preview[idx].setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+		}
+	}
+	
+}

+ 69 - 0
app/RowAlbum.xib

@@ -0,0 +1,69 @@
+<?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">
+    <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="RowAlbum" customModule="app" customModuleProvider="target">
+            <connections>
+                <outlet property="image0" destination="STJ-Gn-fSb" id="jMa-Hj-9ea"/>
+                <outlet property="image1" destination="BRb-br-Rb9" id="mNJ-gK-1D1"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowAlbum">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="STJ-Gn-fSb" userLabel="PhotoL">
+                    <rect key="frame" x="10" y="10" width="172.5" height="108"/>
+                    <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="108" id="adJ-vY-QZ4"/>
+                    </constraints>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                            <color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        </userDefinedRuntimeAttribute>
+                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                            <real key="value" value="1"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </imageView>
+                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="BRb-br-Rb9" userLabel="PhotoR">
+                    <rect key="frame" x="197.5" y="10" width="172.5" height="108"/>
+                    <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="108" id="LVi-0V-kFe"/>
+                    </constraints>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                            <color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        </userDefinedRuntimeAttribute>
+                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                            <real key="value" value="1"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </imageView>
+            </subviews>
+            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <constraints>
+                <constraint firstItem="BRb-br-Rb9" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" multiplier="0.5" constant="-15" id="Nsh-ju-JXC"/>
+                <constraint firstItem="BRb-br-Rb9" firstAttribute="trailing" secondItem="iN0-l3-epB" secondAttribute="trailing" constant="-5" id="Phu-9W-VdZ"/>
+                <constraint firstItem="STJ-Gn-fSb" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="jbT-nH-OfC"/>
+                <constraint firstItem="STJ-Gn-fSb" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" multiplier="0.5" constant="-15" id="nGe-Uj-Yhh"/>
+                <constraint firstItem="STJ-Gn-fSb" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="10" id="uhv-Ju-fhw"/>
+                <constraint firstItem="BRb-br-Rb9" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="vo9-a0-KTz"/>
+            </constraints>
+        </view>
+    </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
+</document>