Просмотр исходного кода

Merge branch 'BaseProject' into Activities

Iñigo Valentin 9 лет назад
Родитель
Сommit
5fe233db90
28 измененных файлов с 1335 добавлено и 87 удалено
  1. 21 0
      app.xcodeproj/project.pbxproj
  2. 6 0
      app/Assets.xcassets/Misc/Contents.json
  3. 23 0
      app/Assets.xcassets/Misc/Pinpoint.imageset/Contents.json
  4. BIN
      app/Assets.xcassets/Misc/Pinpoint.imageset/pinpoint-1.png
  5. BIN
      app/Assets.xcassets/Misc/Pinpoint.imageset/pinpoint-2.png
  6. BIN
      app/Assets.xcassets/Misc/Pinpoint.imageset/pinpoint.png
  7. 23 0
      app/Assets.xcassets/Misc/PinpointGM.imageset/Contents.json
  8. BIN
      app/Assets.xcassets/Misc/PinpointGM.imageset/pinpoint_gm-1.png
  9. BIN
      app/Assets.xcassets/Misc/PinpointGM.imageset/pinpoint_gm-2.png
  10. BIN
      app/Assets.xcassets/Misc/PinpointGM.imageset/pinpoint_gm.png
  11. 23 0
      app/Assets.xcassets/Misc/ScheduleBullet.imageset/Contents.json
  12. BIN
      app/Assets.xcassets/Misc/ScheduleBullet.imageset/schedule_point-1.png
  13. BIN
      app/Assets.xcassets/Misc/ScheduleBullet.imageset/schedule_point-2.png
  14. BIN
      app/Assets.xcassets/Misc/ScheduleBullet.imageset/schedule_point.png
  15. 23 0
      app/Assets.xcassets/Misc/ScheduleLine.imageset/Contents.json
  16. BIN
      app/Assets.xcassets/Misc/ScheduleLine.imageset/schedule_timeline-1.png
  17. BIN
      app/Assets.xcassets/Misc/ScheduleLine.imageset/schedule_timeline-2.png
  18. BIN
      app/Assets.xcassets/Misc/ScheduleLine.imageset/schedule_timeline.png
  19. 271 7
      app/Base.lproj/Main.storyboard
  20. 30 21
      app/HomeView.swift
  21. 13 0
      app/LablancaView.swift
  22. 1 1
      app/LablancaView.xib
  23. 141 0
      app/RowSchedule.swift
  24. 143 0
      app/RowSchedule.xib
  25. 185 0
      app/ScheduleViewController.swift
  26. 401 55
      app/Sync.swift
  27. 29 1
      app/ViewController.swift
  28. 2 2
      app/app.xcdatamodeld/app.xcdatamodel/contents

+ 21 - 0
app.xcodeproj/project.pbxproj

@@ -53,6 +53,7 @@
 		93D9EA6C1DE3498500089002 /* HomeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93D9EA6B1DE3498500089002 /* HomeView.xib */; };
 		93D9EA711DE37C7900089002 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 93D9EA701DE37C7900089002 /* libsqlite3.tbd */; };
 		93D9EA761DE3ACBB00089002 /* Sync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D9EA751DE3ACBB00089002 /* Sync.swift */; };
+<<<<<<< HEAD
 		93E0C5E21EB7E7F000905811 /* ActivitiesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5E11EB7E7F000905811 /* ActivitiesView.xib */; };
 		93E0C5E41EB7E94300905811 /* ActivitiesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5E31EB7E94300905811 /* ActivitiesView.swift */; };
 		93E0C5E61EBDEF2B00905811 /* RowFutureActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5E51EBDEF2B00905811 /* RowFutureActivity.swift */; };
@@ -61,6 +62,11 @@
 		93E0C5EC1EBE001000905811 /* RowPastActivity.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5EB1EBE000F00905811 /* RowPastActivity.xib */; };
 		93E0C5EE1EBE25BD00905811 /* RowLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5ED1EBE25BC00905811 /* RowLabel.swift */; };
 		93E0C5F21EBE264F00905811 /* RowLabel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5F11EBE264F00905811 /* RowLabel.xib */; };
+=======
+		93E0C5F41EBE306900905811 /* ScheduleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5F31EBE306900905811 /* ScheduleViewController.swift */; };
+		93EB2F0C1EBF5AEB00F64186 /* RowSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */; };
+		93EB2F0E1EBF5BF500F64186 /* RowSchedule.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */; };
+>>>>>>> BaseProject
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -112,6 +118,7 @@
 		93D9EA6B1DE3498500089002 /* HomeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HomeView.xib; sourceTree = "<group>"; };
 		93D9EA701DE37C7900089002 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
 		93D9EA751DE3ACBB00089002 /* Sync.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Sync.swift; sourceTree = "<group>"; };
+<<<<<<< HEAD
 		93E0C5E11EB7E7F000905811 /* ActivitiesView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ActivitiesView.xib; sourceTree = "<group>"; };
 		93E0C5E31EB7E94300905811 /* ActivitiesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivitiesView.swift; sourceTree = "<group>"; };
 		93E0C5E51EBDEF2B00905811 /* RowFutureActivity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFutureActivity.swift; sourceTree = "<group>"; };
@@ -120,6 +127,11 @@
 		93E0C5EB1EBE000F00905811 /* RowPastActivity.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowPastActivity.xib; 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>"; };
+=======
+		93E0C5F31EBE306900905811 /* ScheduleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduleViewController.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>"; };
+>>>>>>> BaseProject
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -200,6 +212,7 @@
 				938D211E1EA2306300C47EC3 /* LablancaView.swift */,
 				9326C4F31EA51C39007DF2A4 /* RowLablancaDay.xib */,
 				9326C4F51EA5279D007DF2A4 /* RowLablancaDay.swift */,
+<<<<<<< HEAD
 				93E0C5E11EB7E7F000905811 /* ActivitiesView.xib */,
 				93E0C5E31EB7E94300905811 /* ActivitiesView.swift */,
 				93E0C5E51EBDEF2B00905811 /* RowFutureActivity.swift */,
@@ -208,6 +221,11 @@
 				93E0C5EB1EBE000F00905811 /* RowPastActivity.xib */,
 				93E0C5ED1EBE25BC00905811 /* RowLabel.swift */,
 				93E0C5F11EBE264F00905811 /* RowLabel.xib */,
+=======
+				93E0C5F31EBE306900905811 /* ScheduleViewController.swift */,
+				93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */,
+				93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */,
+>>>>>>> BaseProject
 			);
 			path = app;
 			sourceTree = "<group>";
@@ -297,6 +315,7 @@
 				93075C6A1E59CAB000396389 /* BlogView.xib in Resources */,
 				93B84BA41D9C31AB006C0F67 /* Assets.xcassets in Resources */,
 				935D6E2D1E8678B700CED3A1 /* GalleryView.xib in Resources */,
+				93EB2F0E1EBF5BF500F64186 /* RowSchedule.xib in Resources */,
 				93BAD2EE1E585578009DF853 /* RowHomeBlog.xib in Resources */,
 				9326C4F41EA51C39007DF2A4 /* RowLablancaDay.xib in Resources */,
 				935D6E311E867C5E00CED3A1 /* RowGallery.xib in Resources */,
@@ -315,6 +334,7 @@
 			files = (
 				93294FF81E336FA000FDAF50 /* Entry.swift in Sources */,
 				937EA02D1E5B8B5300D0893A /* UIApplcation.swift in Sources */,
+				93E0C5F41EBE306900905811 /* ScheduleViewController.swift in Sources */,
 				936966F11E984B5000A11055 /* RowAlbum.swift in Sources */,
 				93D9EA641DE273FD00089002 /* Section.swift in Sources */,
 				93D9EA6A1DE3491100089002 /* HomeView.swift in Sources */,
@@ -335,6 +355,7 @@
 				93B84B9A1D9C31AB006C0F67 /* AppDelegate.swift in Sources */,
 				93B84BA21D9C31AB006C0F67 /* app.xcdatamodeld in Sources */,
 				935D6E331E867C7E00CED3A1 /* RowGallery.swift in Sources */,
+				93EB2F0C1EBF5AEB00F64186 /* RowSchedule.swift in Sources */,
 				936966ED1E98445200A11055 /* AlbumViewController.swift in Sources */,
 				93D9EA681DE342AC00089002 /* UIView.swift in Sources */,
 				938D211F1EA2306300C47EC3 /* LablancaView.swift in Sources */,

+ 6 - 0
app/Assets.xcassets/Misc/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 23 - 0
app/Assets.xcassets/Misc/Pinpoint.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "pinpoint.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "pinpoint-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "pinpoint-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Misc/Pinpoint.imageset/pinpoint-1.png


BIN
app/Assets.xcassets/Misc/Pinpoint.imageset/pinpoint-2.png


BIN
app/Assets.xcassets/Misc/Pinpoint.imageset/pinpoint.png


+ 23 - 0
app/Assets.xcassets/Misc/PinpointGM.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "pinpoint_gm.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "pinpoint_gm-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "pinpoint_gm-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Misc/PinpointGM.imageset/pinpoint_gm-1.png


BIN
app/Assets.xcassets/Misc/PinpointGM.imageset/pinpoint_gm-2.png


BIN
app/Assets.xcassets/Misc/PinpointGM.imageset/pinpoint_gm.png


+ 23 - 0
app/Assets.xcassets/Misc/ScheduleBullet.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "schedule_point.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "schedule_point-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "schedule_point-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Misc/ScheduleBullet.imageset/schedule_point-1.png


BIN
app/Assets.xcassets/Misc/ScheduleBullet.imageset/schedule_point-2.png


BIN
app/Assets.xcassets/Misc/ScheduleBullet.imageset/schedule_point.png


+ 23 - 0
app/Assets.xcassets/Misc/ScheduleLine.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "schedule_timeline.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "schedule_timeline-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "schedule_timeline-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Misc/ScheduleLine.imageset/schedule_timeline-1.png


BIN
app/Assets.xcassets/Misc/ScheduleLine.imageset/schedule_timeline-2.png


BIN
app/Assets.xcassets/Misc/ScheduleLine.imageset/schedule_timeline.png


+ 271 - 7
app/Base.lproj/Main.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
     <device id="retina4_0" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -187,6 +187,7 @@
                         <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"/>
+                        <segue destination="zJF-Mh-CNb" kind="show" identifier="SegueSchedule" id="A70-jo-yAP"/>
                         <segue destination="3o1-ab-AT4" kind="show" identifier="SegueSync" id="E96-mK-gE9"/>
                     </connections>
                 </viewController>
@@ -485,7 +486,7 @@
                                 </userDefinedRuntimeAttributes>
                             </view>
                         </subviews>
-                        <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <constraints>
                             <constraint firstItem="jx5-wy-ab4" firstAttribute="centerX" secondItem="mCJ-K1-jG1" secondAttribute="centerX" id="5lE-sn-JIj"/>
                             <constraint firstItem="arX-Be-0iS" firstAttribute="top" secondItem="yy6-d2-MRo" secondAttribute="bottom" id="SYd-o2-Nm3"/>
@@ -560,7 +561,7 @@
                                     <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" 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" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sej-1q-hlq" userLabel="Section">
+                                            <view contentMode="scaleToFill" ambiguous="YES" 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">
@@ -573,13 +574,13 @@
                                                         <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                                         <nil key="highlightedColor"/>
                                                     </label>
-                                                    <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="NlX-b5-vyb" userLabel="Content">
+                                                    <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" 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" ambiguous="YES" 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" ambiguous="YES" misplaced="YES" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="WRD-IZ-JpU">
+                                                                    <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="WRD-IZ-JpU">
                                                                         <rect key="frame" x="0.0" y="0.0" width="284" height="1000"/>
                                                                     </stackView>
                                                                 </subviews>
@@ -662,7 +663,7 @@
                                 </userDefinedRuntimeAttributes>
                             </view>
                         </subviews>
-                        <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" 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"/>
@@ -690,6 +691,269 @@
             </objects>
             <point key="canvasLocation" x="-1978" y="1477"/>
         </scene>
+        <!--Schedule-->
+        <scene sceneID="0Lj-Be-Hu6">
+            <objects>
+                <viewController title="Album" id="zJF-Mh-CNb" userLabel="Schedule" customClass="ScheduleViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="dOJ-i5-gIk"/>
+                        <viewControllerLayoutGuide type="bottom" id="Kp9-sV-JUZ"/>
+                    </layoutGuides>
+                    <view key="view" autoresizesSubviews="NO" contentMode="scaleToFill" id="8YN-gM-ymv" 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="P0f-Qc-GSS" 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="cV9-gT-2OC">
+                                        <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="RJE-Hu-oDM">
+                                        <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="RJE-Hu-oDM" firstAttribute="centerX" secondItem="P0f-Qc-GSS" secondAttribute="centerX" id="T6g-du-prz"/>
+                                    <constraint firstItem="cV9-gT-2OC" firstAttribute="leading" secondItem="P0f-Qc-GSS" secondAttribute="leading" id="VGf-cr-zKT"/>
+                                    <constraint firstItem="cV9-gT-2OC" firstAttribute="width" secondItem="P0f-Qc-GSS" secondAttribute="width" multiplier="0.15" id="WCJ-A0-CgT"/>
+                                    <constraint firstItem="RJE-Hu-oDM" firstAttribute="height" secondItem="P0f-Qc-GSS" secondAttribute="height" id="YlB-So-f8f"/>
+                                    <constraint firstItem="RJE-Hu-oDM" firstAttribute="centerY" secondItem="P0f-Qc-GSS" secondAttribute="centerY" id="aES-4b-n3l"/>
+                                    <constraint firstItem="RJE-Hu-oDM" firstAttribute="width" secondItem="P0f-Qc-GSS" secondAttribute="width" multiplier="0.7" id="fKA-UR-a5d"/>
+                                    <constraint firstItem="cV9-gT-2OC" firstAttribute="centerY" secondItem="P0f-Qc-GSS" secondAttribute="centerY" id="j0s-Q2-z7i"/>
+                                    <constraint firstItem="cV9-gT-2OC" firstAttribute="height" secondItem="P0f-Qc-GSS" secondAttribute="height" id="rCF-Un-LBK"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rRo-dr-1GN">
+                                <rect key="frame" x="0.0" y="50" width="320" height="518"/>
+                                <subviews>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nIg-ez-N2J" userLabel="Section">
+                                        <rect key="frame" x="10" y="10" width="300" height="498"/>
+                                        <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="663-n7-Jwn" 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="zTh-A8-uDI"/>
+                                                </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="rYw-pJ-uyq" userLabel="Content">
+                                                <rect key="frame" x="2" y="30" width="296" height="468.5"/>
+                                                <subviews>
+                                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="odg-U1-6cp" userLabel="Calendar">
+                                                        <rect key="frame" x="8" y="8" width="280" height="60"/>
+                                                        <subviews>
+                                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ean-uL-e8X">
+                                                                <rect key="frame" x="10" y="7" width="45" height="45"/>
+                                                                <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
+                                                                <constraints>
+                                                                    <constraint firstAttribute="height" constant="45" id="FCK-N3-WdV"/>
+                                                                    <constraint firstAttribute="width" constant="45" id="czB-hK-gr2"/>
+                                                                </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>
+                                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="25" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EUB-BM-L7c" userLabel="Number">
+                                                                <rect key="frame" x="65" y="7.5" width="45" height="45"/>
+                                                                <constraints>
+                                                                    <constraint firstAttribute="width" constant="45" id="0J5-54-fFO"/>
+                                                                    <constraint firstAttribute="height" constant="45" id="bRL-x7-mQS"/>
+                                                                </constraints>
+                                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="35"/>
+                                                                <nil key="textColor"/>
+                                                                <nil key="highlightedColor"/>
+                                                            </label>
+                                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Agosto" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="g7M-sJ-teh" userLabel="Month">
+                                                                <rect key="frame" x="110" y="32" width="105" height="20.5"/>
+                                                                <fontDescription key="fontDescription" type="italicSystem" pointSize="17"/>
+                                                                <nil key="textColor"/>
+                                                                <nil key="highlightedColor"/>
+                                                            </label>
+                                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Margoeguna" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TH3-vv-4wy">
+                                                                <rect key="frame" x="110" y="7.5" width="115" height="20.5"/>
+                                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
+                                                                <nil key="textColor"/>
+                                                                <nil key="highlightedColor"/>
+                                                            </label>
+                                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gEL-Ik-UfU">
+                                                                <rect key="frame" x="225" y="7" width="45" height="45"/>
+                                                                <color key="backgroundColor" red="0.070588235289999995" green="0.27058823529999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/>
+                                                                <constraints>
+                                                                    <constraint firstAttribute="width" constant="45" id="0Dv-S2-hPr"/>
+                                                                    <constraint firstAttribute="height" constant="45" id="GXZ-mi-hcs"/>
+                                                                </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="ean-uL-e8X" firstAttribute="leading" secondItem="odg-U1-6cp" secondAttribute="leading" constant="10" id="2tn-Yg-glj"/>
+                                                            <constraint firstItem="EUB-BM-L7c" firstAttribute="leading" secondItem="ean-uL-e8X" secondAttribute="trailing" constant="10" id="7wi-ei-pIo"/>
+                                                            <constraint firstItem="gEL-Ik-UfU" firstAttribute="centerY" secondItem="odg-U1-6cp" secondAttribute="centerY" id="Drw-jI-c92"/>
+                                                            <constraint firstItem="ean-uL-e8X" firstAttribute="centerY" secondItem="odg-U1-6cp" secondAttribute="centerY" id="FbR-7B-mF9"/>
+                                                            <constraint firstItem="TH3-vv-4wy" firstAttribute="trailing" secondItem="gEL-Ik-UfU" secondAttribute="leading" id="Fwr-5c-qZk"/>
+                                                            <constraint firstItem="g7M-sJ-teh" firstAttribute="leading" secondItem="EUB-BM-L7c" secondAttribute="trailing" id="SDa-kN-y0V"/>
+                                                            <constraint firstItem="g7M-sJ-teh" firstAttribute="bottom" secondItem="EUB-BM-L7c" secondAttribute="bottom" id="ewO-z9-CnW"/>
+                                                            <constraint firstItem="TH3-vv-4wy" firstAttribute="leading" secondItem="EUB-BM-L7c" secondAttribute="trailing" id="exx-HG-g1H"/>
+                                                            <constraint firstItem="TH3-vv-4wy" firstAttribute="top" secondItem="EUB-BM-L7c" secondAttribute="top" id="fjd-hL-ilJ"/>
+                                                            <constraint firstAttribute="trailing" secondItem="gEL-Ik-UfU" secondAttribute="trailing" constant="10" id="lUb-Gk-coy"/>
+                                                            <constraint firstItem="g7M-sJ-teh" firstAttribute="trailing" secondItem="gEL-Ik-UfU" secondAttribute="leading" constant="-10" id="nvO-MM-b9b"/>
+                                                            <constraint firstItem="EUB-BM-L7c" firstAttribute="centerY" secondItem="odg-U1-6cp" secondAttribute="centerY" id="yZR-5M-Qdr"/>
+                                                            <constraint firstAttribute="height" constant="60" id="yfY-8b-HUb"/>
+                                                        </constraints>
+                                                    </view>
+                                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Sqf-Nt-Prc" userLabel="Schedule">
+                                                        <rect key="frame" x="8" y="78" width="280" height="382.5"/>
+                                                        <subviews>
+                                                            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="48Q-LP-YCz">
+                                                                <rect key="frame" x="0.0" y="0.0" width="280" height="382.5"/>
+                                                                <subviews>
+                                                                    <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="bHp-Km-KNL">
+                                                                        <rect key="frame" x="0.0" y="0.0" width="280" height="382.5"/>
+                                                                    </stackView>
+                                                                </subviews>
+                                                                <constraints>
+                                                                    <constraint firstItem="bHp-Km-KNL" firstAttribute="centerY" secondItem="48Q-LP-YCz" secondAttribute="centerY" id="HB5-Fp-quo"/>
+                                                                    <constraint firstItem="bHp-Km-KNL" firstAttribute="centerX" secondItem="48Q-LP-YCz" secondAttribute="centerX" id="VAI-Nn-IAt"/>
+                                                                    <constraint firstItem="bHp-Km-KNL" firstAttribute="width" secondItem="48Q-LP-YCz" secondAttribute="width" id="aBI-FI-uS0"/>
+                                                                    <constraint firstItem="bHp-Km-KNL" firstAttribute="height" secondItem="48Q-LP-YCz" secondAttribute="height" id="pD4-YH-rJ5"/>
+                                                                </constraints>
+                                                            </scrollView>
+                                                        </subviews>
+                                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                        <constraints>
+                                                            <constraint firstItem="48Q-LP-YCz" firstAttribute="centerX" secondItem="Sqf-Nt-Prc" secondAttribute="centerX" id="D5K-ml-TlX"/>
+                                                            <constraint firstItem="48Q-LP-YCz" firstAttribute="height" secondItem="Sqf-Nt-Prc" secondAttribute="height" id="hRA-1N-OZH"/>
+                                                            <constraint firstItem="48Q-LP-YCz" firstAttribute="centerY" secondItem="Sqf-Nt-Prc" secondAttribute="centerY" id="tz4-U7-hYk"/>
+                                                            <constraint firstItem="48Q-LP-YCz" firstAttribute="width" secondItem="Sqf-Nt-Prc" secondAttribute="width" id="zUk-4F-sbH"/>
+                                                        </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"/>
+                                                <constraints>
+                                                    <constraint firstItem="Sqf-Nt-Prc" firstAttribute="top" secondItem="odg-U1-6cp" secondAttribute="bottom" constant="10" id="aOG-X0-VZl"/>
+                                                </constraints>
+                                                <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="rYw-pJ-uyq" firstAttribute="top" secondItem="663-n7-Jwn" secondAttribute="bottom" id="9Gs-ds-1Kn"/>
+                                            <constraint firstItem="663-n7-Jwn" firstAttribute="width" secondItem="nIg-ez-N2J" secondAttribute="width" id="P66-wF-f9s"/>
+                                            <constraint firstItem="663-n7-Jwn" firstAttribute="centerX" secondItem="nIg-ez-N2J" secondAttribute="centerX" id="WQ9-5d-Emo"/>
+                                            <constraint firstItem="Sqf-Nt-Prc" firstAttribute="width" secondItem="nIg-ez-N2J" secondAttribute="width" constant="-20" id="Z9f-tb-ejn"/>
+                                            <constraint firstItem="663-n7-Jwn" firstAttribute="top" secondItem="nIg-ez-N2J" secondAttribute="top" id="add-lE-oaz"/>
+                                            <constraint firstItem="Sqf-Nt-Prc" firstAttribute="centerX" secondItem="nIg-ez-N2J" secondAttribute="centerX" id="ccQ-Bg-VP2"/>
+                                            <constraint firstItem="rYw-pJ-uyq" firstAttribute="centerX" secondItem="nIg-ez-N2J" secondAttribute="centerX" id="fep-5d-H6q"/>
+                                            <constraint firstAttribute="bottom" secondItem="rYw-pJ-uyq" secondAttribute="bottom" id="uMf-AM-09X"/>
+                                        </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="nIg-ez-N2J" firstAttribute="height" secondItem="rRo-dr-1GN" secondAttribute="height" constant="-20" id="2cx-Wp-1D3"/>
+                                    <constraint firstItem="nIg-ez-N2J" firstAttribute="centerY" secondItem="rRo-dr-1GN" secondAttribute="centerY" id="Aow-J2-EtX"/>
+                                    <constraint firstItem="nIg-ez-N2J" firstAttribute="centerX" secondItem="rRo-dr-1GN" secondAttribute="centerX" id="DSh-bL-FaZ"/>
+                                    <constraint firstItem="nIg-ez-N2J" firstAttribute="width" secondItem="rRo-dr-1GN" secondAttribute="width" constant="-20" id="civ-Ll-a7e"/>
+                                </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.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <constraints>
+                            <constraint firstItem="P0f-Qc-GSS" firstAttribute="width" secondItem="8YN-gM-ymv" secondAttribute="width" id="15Q-4t-71E"/>
+                            <constraint firstItem="rRo-dr-1GN" firstAttribute="top" secondItem="P0f-Qc-GSS" secondAttribute="bottom" id="40K-Ts-eE7"/>
+                            <constraint firstItem="rRo-dr-1GN" firstAttribute="width" secondItem="8YN-gM-ymv" secondAttribute="width" id="Jhr-rW-slc"/>
+                            <constraint firstItem="P0f-Qc-GSS" firstAttribute="top" secondItem="dOJ-i5-gIk" secondAttribute="bottom" id="WaW-Zq-Uf9"/>
+                            <constraint firstItem="P0f-Qc-GSS" firstAttribute="centerX" secondItem="8YN-gM-ymv" secondAttribute="centerX" id="gQv-36-Fxt"/>
+                            <constraint firstAttribute="bottom" secondItem="rRo-dr-1GN" secondAttribute="bottom" id="gzY-Cd-jBQ"/>
+                            <constraint firstItem="rRo-dr-1GN" firstAttribute="centerX" secondItem="8YN-gM-ymv" secondAttribute="centerX" id="yze-m6-yFy"/>
+                        </constraints>
+                        <userDefinedRuntimeAttributes>
+                            <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                <real key="value" value="0.0"/>
+                            </userDefinedRuntimeAttribute>
+                        </userDefinedRuntimeAttributes>
+                    </view>
+                    <connections>
+                        <outlet property="btNext" destination="gEL-Ik-UfU" id="yfe-ny-2eZ"/>
+                        <outlet property="btPrev" destination="ean-uL-e8X" id="8ah-gF-AV8"/>
+                        <outlet property="lbDayMonth" destination="g7M-sJ-teh" id="Wwr-mS-Y3D"/>
+                        <outlet property="lbDayName" destination="TH3-vv-4wy" id="hbO-Yb-NUo"/>
+                        <outlet property="lbDayNumber" destination="EUB-BM-L7c" id="UjL-xN-CcE"/>
+                        <outlet property="svScheduleList" destination="bHp-Km-KNL" id="aSi-lC-w6H"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="rq0-MV-vyl" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-2839" y="1801"/>
+        </scene>
         <!--Sync-->
         <scene sceneID="cqg-BI-2xm">
             <objects>

+ 30 - 21
app/HomeView.swift

@@ -40,6 +40,10 @@ class HomeView: UIView {
 	@IBOutlet weak var gallerySection: Section!
 	@IBOutlet weak var pastActivitiesSection: Section!
 	@IBOutlet weak var socialSection: Section!
+
+	var lang: String? = nil
+	var moc: NSManagedObjectContext? = nil
+	var appDelegate: AppDelegate? = nil
 	
 	override init(frame: CGRect){
 		super.init(frame: frame)
@@ -58,7 +62,6 @@ class HomeView: UIView {
 		container.frame = self.bounds
 		
 
-		
 		//Set titles for each section
 		locationSection.setTitle(text: "Encuentranos")
 		lablancaSection.setTitle(text: "La Blanca")
@@ -69,32 +72,38 @@ class HomeView: UIView {
 		socialSection.setTitle(text: "Siguenos")
 		
 		//Get info to populate sections
-		let moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
-		
-		let appDelegate = UIApplication.shared.delegate as! AppDelegate
-		moc.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
-		let lang : String = getLanguage()
+		self.moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		self.appDelegate = UIApplication.shared.delegate as! AppDelegate
+		self.moc?.persistentStoreCoordinator = appDelegate?.persistentStoreCoordinator
+		self.lang = getLanguage()
 		
 		//Populate sections
-		setUpPastActivities(context: moc, delegate: appDelegate, lang: lang, parent: pastActivitiesSection.getContentStack())
-		setUpBlog(context: moc, delegate: appDelegate, lang: lang, parent: blogSection.getContentStack())
-		setUpFutureActivities(context: moc, delegate: appDelegate, lang: lang, parent: futureActivitiesSection.getContentStack())
-		setUpSocial(parent: socialSection.getContentStack())
-		setUpGallery(context: moc, delegate: appDelegate, parent: gallerySection.getContentStack())
-		
-		
-		pastActivitiesSection.expandSection()
+		self.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?
-			print("curh: \(h)")
-		}
+		//var h: Int = 0
+		//for view in scrollView.subviews {
+		//	//contentRect = contentRect.union(view.frame);
+		//	h = h + Int(view.frame.height) + 30 //Why 30?
+		//	print("curh: \(h)")
+		//}
 		// TODO: Calculate at the end
-		self.scrollView.contentSize.height = 1300// CGFloat(h);
+		//self.scrollView.contentSize.height = 1300// CGFloat(h);
+	}
+
+	/**
+	 Triggers a reloading (or initial loading) of all sections.
+	*/
+	func populate(){
+		
+		//Populate sections
+		self.setUpPastActivities(context: self.moc!, delegate: appDelegate!, lang: self.lang!, parent: self.pastActivitiesSection.getContentStack())
+		self.setUpBlog(context: self.moc!, delegate: self.appDelegate!, lang: self.lang!, parent: self.blogSection.getContentStack())
+		self.setUpFutureActivities(context: self.moc!, delegate: self.appDelegate!, lang: self.lang!, parent: self.futureActivitiesSection.getContentStack())
+		self.setUpSocial(parent: self.socialSection.getContentStack())
+		self.setUpGallery(context: self.moc!, delegate: self.appDelegate!, parent: self.gallerySection.getContentStack())
+		self.pastActivitiesSection.expandSection()
 	}
 	
 	func getLanguage() -> String{

+ 13 - 0
app/LablancaView.swift

@@ -113,6 +113,12 @@ class LablancaView: UIView {
 			NSLog(":LABLANCA:ERROR: Error getting festivals info: \(error)")
 		}
 		
+		// Set up schedule buttons
+		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openSchedule(_:)))
+		fBtSchedule.isUserInteractionEnabled = true
+		fBtSchedule.addGestureRecognizer(tapRecognizer)
+		
+		
 		// Get info about the day prices.
 		let dateFormatter = DateFormatter()
 		dateFormatter.dateFormat = "yyyy-MM-dd"
@@ -185,6 +191,13 @@ class LablancaView: UIView {
 		// Nothing else to be done.
 	}
 	
+	func openSchedule(_ sender:UITapGestureRecognizer? = nil){
+		NSLog(":LABLANCA:DEBUG: Getting delegate and showing schedule.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showSchedule(margolari: false)
+		NSLog(":LABLANCA:DEBUG: Schedule should be shown.")
+	}
+	
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){

+ 1 - 1
app/LablancaView.xib

@@ -1,5 +1,5 @@
 <?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="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>

+ 141 - 0
app/RowSchedule.swift

@@ -0,0 +1,141 @@
+// 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 RowSchedule: UIView {
+
+	
+	// Outlets
+	@IBOutlet weak var container: UIView!
+	@IBOutlet weak var lbTime: UILabel!
+	@IBOutlet weak var lbTitle: UILabel!
+	@IBOutlet weak var lbText: UILabel!
+	@IBOutlet weak var lbLocation: UILabel!
+	
+	/**
+	Default constructor
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+	}
+	
+	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) {
+		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
+		loadViewFromNib()
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = self.bounds
+		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)*/
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+	/**
+	Sets the time of the event.
+	:param: str String with the time to set.
+	*/
+	func setTime(str: String){
+		self.lbTime.text = str
+	}
+	
+	/**
+	Sets the time of the event.
+	:param: hours Hour of the event start.
+	:param: minutes Minutes of the event start.
+	*/
+	func setTime(hours: Int, minutes: Int){
+		self.lbTime.text = "\(hours):\(minutes)"
+	}
+	
+	/**
+	Sets the time of the event.
+	:param: dtime Datetime of the event start.
+	*/
+	func setTime(dtime: NSDate){
+		let dateformatter = DateFormatter()
+		let calendar = Calendar.current
+		let hours = calendar.component(.hour, from: dtime as Date)
+		let minutes = calendar.component(.minute, from: dtime as Date)
+		self.lbTime.text = "\(hours):\(minutes)"
+	}
+	
+	/**
+	Sets the title of the event.
+	:param: text The title of the event.
+	*/
+	func setTitle(text: String){
+		self.lbTitle.text = text
+	}
+	
+	/**
+	Sets the location of the event.
+	:param: text The location of the event.
+	*/
+	func setLocation(text: String){
+		self.lbLocation.text = text
+	}
+	
+	/**
+	Sets the description of the event. Decodes HTML.
+	:param: text The new text.
+	*/
+	func setText(text: String){
+		self.lbText.text = text.stripHtml()
+	}
+	
+	/**
+	Opens an event dialog.
+	*/
+	func openEvent(_ sender:UITapGestureRecognizer? = nil){
+		print("ROW_BLOG:DEBUG: openpost")
+	}
+}

+ 143 - 0
app/RowSchedule.xib

@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowSchedule" customModule="app">
+            <connections>
+                <outlet property="container" destination="HZR-5W-2l9" id="Pbz-zj-AcP"/>
+                <outlet property="lbLocation" destination="Edl-Ib-zzS" id="P41-6d-DGV"/>
+                <outlet property="lbText" destination="pCF-JC-n5h" id="yAA-gU-Dt5"/>
+                <outlet property="lbTime" destination="VVW-yL-wmh" id="PLK-PD-yaj"/>
+                <outlet property="lbTitle" destination="vSV-nw-MRt" id="LoG-Yq-S3M"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <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="HZR-5W-2l9" userLabel="Container">
+                    <rect key="frame" x="0.0" y="273.5" width="375" height="120"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ko7-ge-5ca" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="120"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VVW-yL-wmh" userLabel="Time">
+                                    <rect key="frame" x="10" y="10" width="55" height="22"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="55" id="qJV-iR-yg8"/>
+                                    </constraints>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+                                    <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView userInteractionEnabled="NO" alpha="0.75" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ScheduleLine" translatesAutoresizingMaskIntoConstraints="NO" id="q6x-38-7dL" userLabel="Line">
+                                    <rect key="frame" x="79" y="-0.5" width="2" height="120"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="2" id="Qy1-BX-GQH"/>
+                                    </constraints>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ScheduleBullet" translatesAutoresizingMaskIntoConstraints="NO" id="pxM-Zk-Eo7" userLabel="Bullet">
+                                    <rect key="frame" x="70" y="11" width="20" height="20"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="20" id="WHH-b4-kKt"/>
+                                        <constraint firstAttribute="height" constant="20" id="Ye0-5j-v5U"/>
+                                    </constraints>
+                                </imageView>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vSV-nw-MRt" userLabel="Title">
+                                    <rect key="frame" x="100" y="10" width="255" height="22"/>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+                                    <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pCF-JC-n5h" userLabel="Text">
+                                    <rect key="frame" x="110" y="37" width="235" height="21"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <nil key="textColor"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Pinpoint" translatesAutoresizingMaskIntoConstraints="NO" id="BmB-4o-ng5" userLabel="Pinpoint">
+                                    <rect key="frame" x="115" y="68" width="19" height="26"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="19" id="Biy-y3-MT7"/>
+                                        <constraint firstAttribute="height" constant="26" id="OQG-JA-m2Q"/>
+                                    </constraints>
+                                </imageView>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Location" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Edl-Ib-zzS">
+                                    <rect key="frame" x="139" y="72.5" width="206" height="18"/>
+                                    <fontDescription key="fontDescription" type="italicSystem" pointSize="15"/>
+                                    <color key="textColor" red="0.32931472081218272" green="0.32931472081218272" blue="0.32931472081218272" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                            </subviews>
+                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                            <constraints>
+                                <constraint firstItem="Edl-Ib-zzS" firstAttribute="trailing" secondItem="pCF-JC-n5h" secondAttribute="trailing" id="1VK-ft-zMD"/>
+                                <constraint firstItem="VVW-yL-wmh" firstAttribute="leading" secondItem="ko7-ge-5ca" secondAttribute="leading" constant="10" id="2bv-NZ-02c"/>
+                                <constraint firstItem="vSV-nw-MRt" firstAttribute="centerY" secondItem="VVW-yL-wmh" secondAttribute="centerY" id="4zW-mq-1iT"/>
+                                <constraint firstItem="vSV-nw-MRt" firstAttribute="leading" secondItem="pxM-Zk-Eo7" secondAttribute="trailing" constant="10" id="7KL-GL-vCQ"/>
+                                <constraint firstItem="Edl-Ib-zzS" firstAttribute="leading" secondItem="BmB-4o-ng5" secondAttribute="trailing" constant="5" id="7k0-y1-elz"/>
+                                <constraint firstItem="BmB-4o-ng5" firstAttribute="leading" secondItem="pCF-JC-n5h" secondAttribute="leading" constant="5" id="EbO-2o-ewf"/>
+                                <constraint firstItem="q6x-38-7dL" firstAttribute="centerX" secondItem="pxM-Zk-Eo7" secondAttribute="centerX" id="FOh-uA-HYL"/>
+                                <constraint firstItem="VVW-yL-wmh" firstAttribute="top" secondItem="ko7-ge-5ca" secondAttribute="top" constant="10" id="MGt-lg-S7C"/>
+                                <constraint firstItem="BmB-4o-ng5" firstAttribute="top" secondItem="pCF-JC-n5h" secondAttribute="bottom" constant="10" id="MOh-Ga-NOQ"/>
+                                <constraint firstItem="pxM-Zk-Eo7" firstAttribute="centerY" secondItem="VVW-yL-wmh" secondAttribute="centerY" id="ORZ-Cx-D0o"/>
+                                <constraint firstItem="pCF-JC-n5h" firstAttribute="width" secondItem="vSV-nw-MRt" secondAttribute="width" constant="-20" id="ZWn-od-vpP"/>
+                                <constraint firstItem="pxM-Zk-Eo7" firstAttribute="leading" secondItem="VVW-yL-wmh" secondAttribute="trailing" constant="5" id="g87-LH-Iby"/>
+                                <constraint firstItem="pCF-JC-n5h" firstAttribute="top" secondItem="vSV-nw-MRt" secondAttribute="bottom" constant="5" id="h98-Dl-4cw"/>
+                                <constraint firstAttribute="trailing" secondItem="vSV-nw-MRt" secondAttribute="trailing" id="jLW-at-0mc"/>
+                                <constraint firstItem="q6x-38-7dL" firstAttribute="top" secondItem="ko7-ge-5ca" secondAttribute="top" id="mdq-SM-9G4"/>
+                                <constraint firstItem="pCF-JC-n5h" firstAttribute="centerX" secondItem="vSV-nw-MRt" secondAttribute="centerX" id="nM3-9e-iDR"/>
+                                <constraint firstItem="Edl-Ib-zzS" firstAttribute="centerY" secondItem="BmB-4o-ng5" secondAttribute="centerY" id="olt-3s-reR"/>
+                            </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>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="120" id="5eZ-Gg-zIC"/>
+                        <constraint firstAttribute="trailing" secondItem="ko7-ge-5ca" secondAttribute="trailing" constant="10" id="H98-ZX-xoZ"/>
+                        <constraint firstItem="ko7-ge-5ca" firstAttribute="bottom" secondItem="HZR-5W-2l9" secondAttribute="bottom" constant="10" id="O6V-Wc-nvy"/>
+                        <constraint firstItem="ko7-ge-5ca" firstAttribute="leading" secondItem="HZR-5W-2l9" secondAttribute="leading" constant="10" id="giZ-PP-oZq"/>
+                        <constraint firstItem="q6x-38-7dL" firstAttribute="height" secondItem="HZR-5W-2l9" secondAttribute="height" id="nyx-DR-DHI"/>
+                        <constraint firstAttribute="top" secondItem="ko7-ge-5ca" secondAttribute="top" constant="-10" id="odh-eT-v0E"/>
+                    </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>
+            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <constraints>
+                <constraint firstItem="HZR-5W-2l9" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Lp5-k0-ysc"/>
+                <constraint firstItem="HZR-5W-2l9" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="QJ3-of-4nA"/>
+                <constraint firstItem="HZR-5W-2l9" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="lFR-Ff-arx"/>
+            </constraints>
+        </view>
+    </objects>
+    <resources>
+        <image name="Pinpoint" width="10" height="13"/>
+        <image name="ScheduleBullet" width="12" height="12"/>
+        <image name="ScheduleLine" width="1" height="2"/>
+    </resources>
+</document>

+ 185 - 0
app/ScheduleViewController.swift

@@ -0,0 +1,185 @@
+// 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 ScheduleViewController: UIViewController, UIGestureRecognizerDelegate {
+
+	// Outlets
+	@IBOutlet weak var btPrev: UIButton!
+	@IBOutlet weak var btNext: UIButton!
+	@IBOutlet weak var lbDayNumber: UILabel!
+	@IBOutlet weak var lbDayMonth: UILabel!
+	@IBOutlet weak var lbDayName: UILabel!
+	@IBOutlet weak var svScheduleList: UIStackView!
+	
+	// Margolari schedule indicator
+	var margolari: Bool = false
+	
+	// App delegate
+	var delegate: AppDelegate?
+	
+	func getContext () -> NSManagedObjectContext {
+		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
+	}
+	
+	/**
+	Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		NSLog(":SCHEDULECONTROLLER:LOG: Init schedule.")
+		
+		super.viewDidLoad()
+		self.loadSchedule(margolari: margolari)
+		
+		//TODO Title
+		
+		// TODO Set button action
+		//barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+	}
+	
+	/**
+	Returns to the main view controller.
+	*/
+	func back() {
+		NSLog(":SCHEDULECONTROLLER:DEBUG: Back")
+		self.dismiss(animated: true, completion: nil)
+	}
+	
+	
+	/**
+	Dispose of any resources that can be recreated.
+	*/
+	override func didReceiveMemoryWarning() {
+		super.didReceiveMemoryWarning()
+	}
+	
+	/**
+	Loads the schedule.
+	*/
+	public func loadSchedule(margolari: Bool){
+		
+		NSLog(":SCHEDULECONTROLLER:DEBUG: Loading schedule: Margolariak \(margolari)")
+		
+		var rowcount = 0
+		var row: RowSchedule
+		var start: NSDate
+		var title: String
+		var text: String
+		var locationId: Int
+		var location: String
+		
+		NSLog(":SCHEDULECONTROLLER:DEBUG: 1")
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		NSLog(":SCHEDULECONTROLLER:DEBUG: 2")
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Festival_event> = Festival_event.fetchRequest()
+		let sortDescriptor = NSSortDescriptor(key: "start", ascending: false)
+		let sortDescriptors = [sortDescriptor]
+		NSLog(":SCHEDULECONTROLLER:DEBUG: 3")
+		fetchRequest.sortDescriptors = sortDescriptors
+		
+		if margolari == true{
+			fetchRequest.predicate = NSPredicate(format: "gm = %i", 1)
+		}
+		else{
+			fetchRequest.predicate = NSPredicate(format: "gm = %i", 0)
+		}
+		
+		// TODO: filter by date, not by number
+		fetchRequest.fetchLimit = 20
+		
+		NSLog(":SCHEDULECONTROLLER:DEBUG: 4")
+		
+		do {
+			
+			// Get the result
+			let searchResults = try context.fetch(fetchRequest)
+			NSLog(":SCHEDULECONTROLLER:DEBUG: 5")
+			
+			NSLog(":SCHEDULECONTROLLER:DEBUG: Total events: \(searchResults.count)")
+			
+			for r in searchResults as [NSManagedObject] {
+				
+				title = r.value(forKey: "title_\(lang)") as! String
+				if let tx = r.value(forKey: "description_\(lang)"){
+					text = r.value(forKey: "description_\(lang)") as! String
+				}
+				else{
+					text = ""
+				}
+				start = r.value(forKey: "start")! as! NSDate
+				locationId = r.value(forKey: "place")! as! Int
+				row = RowSchedule.init(s: "rowSchedule\(rowcount)", i: rowcount)
+				
+				row.setTitle(text: title)
+				row.setText(text: text)
+				row.setTime(dtime: start)
+				
+				// Get location info from Place entity
+				let locationFetchRequest: NSFetchRequest<Place> = Place.fetchRequest()
+				locationFetchRequest.predicate = NSPredicate(format: "id == %i", locationId)
+				locationFetchRequest.fetchLimit = 1
+				do{
+					var locationSearchResults = try context.fetch(locationFetchRequest)
+					var locationR = locationSearchResults[0]
+					location = locationR.value(forKey: "name_\(lang)")! as! String
+					
+					row.setLocation(text: location)
+				} catch {
+					NSLog(":SCHEDULECONTROLLER:ERROR: Error getting location: \(error)")
+				}
+				
+				NSLog(":SCHEDULECONTROLLER:DEBUG: Adding row: height: \(row.frame.height)")
+				svScheduleList.addArrangedSubview(row)
+				row.setNeedsLayout()
+				row.layoutIfNeeded()
+				
+				rowcount = rowcount + 1
+			}
+		} catch {
+			NSLog(":SCHEDULECONTROLLER:ERROR: Error with request: \(error)")
+		}
+
+	}
+	
+	/**
+	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"
+		}
+	}
+	
+}
+

+ 401 - 55
app/Sync.swift

@@ -99,10 +99,10 @@ class Sync{
 			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 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 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")
@@ -111,7 +111,7 @@ class Sync{
 			let dataPostComment : [String] = self.getTable(data: strData!, table: "post_comment")
 			let dataPostImage : [String] = self.getTable(data: strData!, table: "post_image")
 			let dataPostTag : [String] = self.getTable(data: strData!, table: "post_tag")
-			//let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
+			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
@@ -127,6 +127,7 @@ class Sync{
 			self.saveTablePostTag(entries: dataPostTag)
 			
 			self.saveTablePlace(entries: dataPlace)
+			self.saveTablePeople(entries: dataPeople)
 			
 			self.saveTableAlbum(entries: dataAlbum)
 			self.saveTablePhoto(entries: dataPhoto)
@@ -134,6 +135,10 @@ class Sync{
 			
 			self.saveTableFestival(entries: dataFestival)
 			self.saveTableFestivalDay(entries: dataFestivalDay)
+			self.saveTableFestivalOffer(entries: dataFestivalOffer)
+			self.saveTableFestivalEvent(entries: dataFestivalEvent)
+			
+			self.saveTableSponsor(entries: dataSponsor)
 			
 			self.saveSettings(entries: dataSettings)
 			
@@ -206,28 +211,28 @@ class Sync{
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	*/
-	func saveTablePeople(entries : [String]){
+	func saveTablePlace(entries : [String]){
 		
-		NSLog(":SYNC:LOG: Saving table People.")
+		NSLog(":SYNC:LOG: Saving table Place.")
 		
 		//Set up context
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
 		
-		let entity =  NSEntityDescription.entity(forEntityName: "People", in: context)
+		let entity =  NSEntityDescription.entity(forEntityName: "Place", in: context)
 		
 		var row: NSManagedObject
 		
 		//Delete all previous entries
-		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "People")
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Place")
 		let request = NSBatchDeleteRequest(fetchRequest: fetch)
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			NSLog(":SYNC:ERROR: Could not clean up People entity: \(error), \(error.userInfo).")
+			NSLog(":SYNC:ERROR: Could not clean up Places entity: \(error), \(error.userInfo).")
 		} catch {
-			NSLog(":SYNC:ERROR: Could not clean up People entity")
+			NSLog(":SYNC:ERROR: Could not clean up Places entity.")
 		}
 		
 		//Loop new entries
@@ -299,85 +304,61 @@ class Sync{
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	*/
-	func saveTablePlace(entries : [String]){
+	func saveTablePeople(entries : [String]){
 		
-		NSLog(":SYNC:LOG: Saving table Place.")
+		NSLog(":SYNC:LOG: Saving table People.")
 		
 		//Set up context
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
 		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
 		
-		let entity =  NSEntityDescription.entity(forEntityName: "Place", in: context)
+		let entity =  NSEntityDescription.entity(forEntityName: "People", in: context)
 		
 		var row: NSManagedObject
 		
 		//Delete all previous entries
-		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Place")
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "People")
 		let request = NSBatchDeleteRequest(fetchRequest: fetch)
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			NSLog(":SYNC:ERROR: Could not clean up Places entity: \(error), \(error.userInfo).")
+			NSLog(":SYNC:ERROR: Could not clean up People entity: \(error), \(error.userInfo).")
 		} catch {
-			NSLog(":SYNC:ERROR: Could not clean up Places entity.")
+			NSLog(":SYNC:ERROR: Could not clean up People entity.")
 		}
 		
 		//Loop new entries
 		for entry in entries{
 			
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			
 			//Get id
 			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))!
+			row.setValue(id, forKey: "id")
 			
 			//Get name_es
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let name_es : String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			let name_es: String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_es, forKey: "name_es")
 			
 			//Get name_en
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let name_en : String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			let name_en: String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_en, forKey: "name_en")
 			
 			//Get name_eu
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let name_eu : String = str.subStr(start : str.indexOf(target : "\"name_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_eu, forKey: "name_eu")
 			
-			//Get address_es
-			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let address_es : String = str.subStr(start : str.indexOf(target : "\"address_es\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
-			
-			//Get address_en
-			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let address_en : String = str.subStr(start : str.indexOf(target : "\"address_en\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
-			
-			//Get address_eu
-			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let address_eu : String = str.subStr(start : str.indexOf(target : "\"address_eu\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
-			
-			//Get cp
-			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let cp : String = str.subStr(start : str.indexOf(target : "\"cp\":")! + 6, end : str.indexOf(target : ",\"")! - 2)
-			
-			//Get lat
-			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let lat : Float = Float(str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2))!
-			
-			//Get lon
+			//Get link
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
-			let lon : Float = Float(str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2))!
+			let link : String = str.subStr(start : str.indexOf(target : "\"link\":")! + 8, end : str.length - 2)
+			row.setValue(link, forKey: "link")
 			
 			//Save CoreData
-			row = NSManagedObject(entity: entity!, insertInto: context)
-			row.setValue(id, forKey: "id")
-			row.setValue(name_es, forKey: "name_es")
-			row.setValue(name_en, forKey: "name_en")
-			row.setValue(name_eu, forKey: "name_eu")
-			row.setValue(address_es, forKey: "address_es")
-			row.setValue(address_en, forKey: "address_en")
-			row.setValue(address_eu, forKey: "address_eu")
-			row.setValue(cp, forKey: "cp")
-			row.setValue(lat, forKey: "lat")
-			row.setValue(lon, forKey: "lon")
 			do {
 				try context.save()
 			} catch let error as NSError  {
@@ -1125,7 +1106,7 @@ class Sync{
 			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
 			let start = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
 			row.setValue(start, forKey: "start")
-			
+
 			//Get end
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
 			let end = str.subStr(start : str.indexOf(target : "\"end\":")! + 7, end : str.indexOf(target : ",\"")! - 2)
@@ -1526,9 +1507,9 @@ class Sync{
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			NSLog(":SYNC:ERROR: Could not clean up Festival: \(error), \(error.userInfo).")
+			NSLog(":SYNC:ERROR: Could not clean up Festival_day: \(error), \(error.userInfo).")
 		} catch {
-			NSLog(":SYNC:ERROR: Could not clean up Festival entity.")
+			NSLog(":SYNC:ERROR: Could not clean up Festival_day entity.")
 		}
 		
 		//Loop new entries
@@ -1578,6 +1559,371 @@ class Sync{
 		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTableFestivalOffer(entries : [String]){
+		
+		NSLog(":SYNC:LOG: Saving table FestivalOffer.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Festival_offer", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Festival_offer")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			NSLog(":SYNC:ERROR: Could not clean up Festival_offer: \(error), \(error.userInfo).")
+		} catch {
+			NSLog(":SYNC:ERROR: Could not clean up Festival_offer entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			
+			// Get id
+			var str = entry
+			let id: Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(id, forKey: "id")
+			
+			// Get year
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let year: Int = Int(str.subStr(start : str.indexOf(target : "\"year\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(year, forKey: "year")
+			
+			// Get name_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_es: String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_es, forKey: "name_es")
+			
+			// Get name_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_en: String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_en, forKey: "name_en")
+			
+			// Get name_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_eu: String = str.subStr(start : str.indexOf(target : "\"name_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_eu, forKey: "name_eu")
+			
+			// Get description_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_es : String = str.subStr(start : str.indexOf(target : "\"description_es\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_es != "ul"){ //From "null"
+				row.setValue(description_es, forKey: "description_es")
+			}
+			
+			// Get description_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_en : String = str.subStr(start : str.indexOf(target : "\"description_en\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_en != "ul"){ //From "null"
+				row.setValue(description_en, forKey: "description_en")
+			}
+			
+			// Get description_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_eu : String = str.subStr(start : str.indexOf(target : "\"description_eu\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_eu != "ul"){ //From "null"
+				row.setValue(description_eu, forKey: "description_eu")
+			}
+			
+			// Get days
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let days: Int = Int(str.subStr(start : str.indexOf(target : "\"days\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(days, forKey: "days")
+			
+			//Get price
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let price: Int = Int(str.subStr(start : str.indexOf(target : "\"price\":")! + 9, end : str.length - 2))!
+			row.setValue(price, forKey: "price")
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				NSLog(":SYNC:ERROR: Could not store Festival_offer entry \(error.userInfo).")
+			} catch {
+				NSLog(":SYNC:ERROR: Could not store Festival_offer entry.")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTableFestivalEvent(entries : [String]){
+		
+		NSLog(":SYNC:LOG: Saving table FestivalEvent.")
+		
+		let dateFormatter = DateFormatter()
+		dateFormatter.timeZone = TimeZone.ReferenceType.local
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Festival_event", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Festival_event")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			NSLog(":SYNC:ERROR: Could not clean up Festival_event: \(error), \(error.userInfo).")
+		} catch {
+			NSLog(":SYNC:ERROR: Could not clean up Festival_event entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			
+			//Get id
+			var str = entry
+			let id: Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(id, forKey: "id")
+			
+			//Get gm
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let gm: Int = Int(str.subStr(start : str.indexOf(target : "\"gm\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(gm, forKey: "gm")
+			
+			//Get title_es
+			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)
+			row.setValue(title_es, forKey: "title_es")
+			
+			//Get title_en
+			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)
+			row.setValue(title_en, forKey: "title_en")
+			
+			//Get title_eu
+			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)
+			row.setValue(title_eu, forKey: "title_eu")
+			
+			//Get description_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_es : String = str.subStr(start : str.indexOf(target : "\"description_es\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_es != "ul"){ //From "null"
+				row.setValue(description_es, forKey: "description_es")
+			}
+			
+			//Get description_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_en : String = str.subStr(start : str.indexOf(target : "\"description_en\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_en != "ul"){ //From "null"
+				row.setValue(description_en, forKey: "description_en")
+			}
+			
+			//Get description_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_eu : String = str.subStr(start : str.indexOf(target : "\"description_eu\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_eu != "ul"){ //From "null"
+				row.setValue(description_eu, forKey: "description_eu")
+			}
+			
+			//Get host
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let strHost: String = str.subStr(start : str.indexOf(target : "\"host\":")! + 8, end : str.indexOf(target : ",\"")! - 2)
+			if (strHost != "ul"){ //From "null"
+				let host: Int = Int(strHost)!
+				row.setValue(host, forKey: "host")
+			}
+			
+			//Get place
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let place: Int = Int(str.subStr(start : str.indexOf(target : "\"place\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(place, forKey: "place")
+			
+			//Get start
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+			let start = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(start, forKey: "start")
+
+			// Get day
+			// 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 : ",\"")! - 2))!
+			// If on the first hours of the next day...
+			let calendar = Calendar.current
+			let hours = calendar.component(.hour, from: day as! Date)
+			// ... the event belongs to the previous day.
+			if hours < 6{
+				day = Calendar.current.date(byAdding: .day, value: -1, to: day)!	
+			}
+			row.setValue(day, forKey: "day")
+
+			
+			//Get end
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+			let strEnd: String =  str.subStr(start : str.indexOf(target : "\"end\":")! + 7, end : str.length - 2)
+			if (strEnd != "ul"){ //From "null"
+				let end = dateFormatter.date(from: strEnd)!
+				row.setValue(end, forKey: "end")
+			}
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				NSLog(":SYNC:ERROR: Could not store Festival_event entry \(error.userInfo).")
+			} catch {
+				NSLog(":SYNC:ERROR: Could not store Festival_event entry.")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTableSponsor(entries : [String]){
+		
+		NSLog(":SYNC:LOG: Saving table Sponsor.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Sponsor", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Sponsor")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			NSLog(":SYNC:ERROR: Could not clean up Sponsor: \(error), \(error.userInfo).")
+		} catch {
+			NSLog(":SYNC:ERROR: Could not clean up Sponsor entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			
+			//Get id
+			var str = entry
+			let id: Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(id, forKey: "id")
+			
+			// Get name_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_es: String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_es, forKey: "name_es")
+			
+			// Get name_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_en: String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_en, forKey: "name_en")
+			
+			// Get name_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_eu: String = str.subStr(start : str.indexOf(target : "\"name_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_eu, forKey: "name_eu")
+			
+			// Get text_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text_es: String = str.subStr(start : str.indexOf(target : "\"text_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(text_es, forKey: "text_es")
+			
+			// Get text_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text_en: String = str.subStr(start : str.indexOf(target : "\"text_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(text_en, forKey: "text_en")
+			
+			// Get text_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text_eu: String = str.subStr(start : str.indexOf(target : "\"text_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(text_eu, forKey: "text_eu")
+			
+			// Get image
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let image: String = str.subStr(start : str.indexOf(target : "\"image\":")! + 9, end : str.indexOf(target : ",\"")! - 2)
+			if (image != "ul"){ //From "null"
+				row.setValue(image, forKey: "image")
+			}
+			
+			// Get address_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_es: String = str.subStr(start : str.indexOf(target : "\"address_es\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			if (address_es != "ul"){ //From "null"
+				row.setValue(address_es, forKey: "address_es")
+			}
+			
+			// Get address_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_en: String = str.subStr(start : str.indexOf(target : "\"address_en\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			if (address_en != "ul"){ //From "null"
+				row.setValue(address_en, forKey: "address_en")
+			}
+			
+			// Get address_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_eu: String = str.subStr(start : str.indexOf(target : "\"address_eu\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			if (address_eu != "ul"){ //From "null"
+				row.setValue(address_eu, forKey: "address_eu")
+			}
+			
+			//Get link
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let link: String = str.subStr(start : str.indexOf(target : "\"link\":")! + 8, end : str.indexOf(target : ",\"")! - 2)
+			if (link != "ul"){ //From "null"
+				row.setValue(link, forKey: "link")
+			}
+			
+			//Get lat
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let strLat: String = str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2)
+			if (strLat != "ul"){ //From "null"
+				let lat: Float = Float(str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2))!
+				row.setValue(lat, forKey: "lat")
+			}
+			
+			//Get lon
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let strLon: String = str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2)
+			if (strLon != "ul"){ //From "null"
+				let lon: Float = Float(str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2))!
+				row.setValue(lon, forKey: "lon")
+			}
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				NSLog(":SYNC:ERROR: Could not store Sponsor entry \(error.userInfo).")
+			} catch {
+				NSLog(":SYNC:ERROR: Could not store Sponsor entry.")
+			}
+		}
+	}
+	
 	/**
 	Saves the received settings.
 	:param: entries Array of strings containing the rows of the table, in JSON format.

+ 29 - 1
app/ViewController.swift

@@ -81,6 +81,18 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		performSegue(withIdentifier: "SegueAlbum", sender: nil)
 	}
 	
+	func showSchedule(margolari: Bool){
+		NSLog(":CONTROLLER:DEBUG: Showing schedule. Margolari: \(margolari)")
+		if margolari == true{
+			self.passId = 1
+		}
+		else{
+			self.passId = 0
+		}
+		// TODO: Uncomment when ready
+		performSegue(withIdentifier: "SegueSchedule", sender: nil)
+	}
+	
 	/**
 	 Handles the initial sync process.
 	 It can start it, showing the sync screen, or finish it, hidding the screen.
@@ -112,6 +124,14 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		if segue.identifier == "SegueAlbum"{
 			(segue.destination as! AlbumViewController).id = passId
 		}
+		if segue.identifier == "SegueSchedule"{
+			if passId == 1{
+				(segue.destination as! ScheduleViewController).margolari = true
+			}
+			else{
+				(segue.destination as! ScheduleViewController).margolari = false
+			}
+		}
 		if segue.identifier == "SegueSync"{
 			self.syncSegue = segue
 		}
@@ -140,7 +160,15 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		delegate = UIApplication.shared.delegate as! AppDelegate
 		delegate?.controller = self
 		
-		
+	}
+
+	func populate(){
+		self.containerViewHome.populate()
+		//self.containerLocation.populate()
+		//self.containerLablanca.populate()
+		//self.containerActivities.populate()
+		//self.containerBlog.populate()
+		//self.containerGallery.populate()
 	}
 	
 	/**

+ 2 - 2
app/app.xcdatamodeld/app.xcdatamodel/contents

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11759" systemVersion="16D32" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
+<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="12141" systemVersion="16E195" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
     <entity name="Activity" representedClassName=".Activity" syncable="YES" codeGenerationType="class">
         <attribute name="after_en" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="after_es" optional="YES" attributeType="String" syncable="YES"/>
@@ -88,7 +88,7 @@
         <attribute name="description_es" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="description_eu" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="end" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
-        <attribute name="gm" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
+        <attribute name="gm" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
         <attribute name="host" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
         <attribute name="id" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
         <attribute name="place" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>