Преглед изворни кода

Separate controller for the post view.

Iñigo Valentin пре 9 година
родитељ
комит
aa25e2b3e4

+ 4 - 0
app.xcodeproj/project.pbxproj

@@ -34,6 +34,7 @@
 		93BAD2F41E585EE6009DF853 /* RowHomeFutureActivities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BAD2F31E585EE6009DF853 /* RowHomeFutureActivities.swift */; };
 		93BAD2F61E586310009DF853 /* RowHomeSocial.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93BAD2F51E586310009DF853 /* RowHomeSocial.xib */; };
 		93BAD2F81E586741009DF853 /* RowHomeSocial.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BAD2F71E586741009DF853 /* RowHomeSocial.swift */; };
+		93BEB6D21E7E878300C68DE5 /* PostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BEB6D11E7E878300C68DE5 /* PostViewController.swift */; };
 		93D9EA601DE271E700089002 /* Section.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93D9EA5F1DE271E700089002 /* Section.xib */; };
 		93D9EA641DE273FD00089002 /* Section.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D9EA631DE273FD00089002 /* Section.swift */; };
 		93D9EA681DE342AC00089002 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D9EA671DE342AC00089002 /* UIView.swift */; };
@@ -73,6 +74,7 @@
 		93BAD2F31E585EE6009DF853 /* RowHomeFutureActivities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomeFutureActivities.swift; sourceTree = "<group>"; };
 		93BAD2F51E586310009DF853 /* RowHomeSocial.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowHomeSocial.xib; sourceTree = "<group>"; };
 		93BAD2F71E586741009DF853 /* RowHomeSocial.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomeSocial.swift; sourceTree = "<group>"; };
+		93BEB6D11E7E878300C68DE5 /* PostViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostViewController.swift; sourceTree = "<group>"; };
 		93D9EA5F1DE271E700089002 /* Section.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = Section.xib; path = ../Section.xib; sourceTree = "<group>"; };
 		93D9EA631DE273FD00089002 /* Section.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Section.swift; sourceTree = "<group>"; };
 		93D9EA671DE342AC00089002 /* UIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
@@ -145,6 +147,7 @@
 				93BAD2F31E585EE6009DF853 /* RowHomeFutureActivities.swift */,
 				93BAD2F51E586310009DF853 /* RowHomeSocial.xib */,
 				93BAD2F71E586741009DF853 /* RowHomeSocial.swift */,
+				93BEB6D11E7E878300C68DE5 /* PostViewController.swift */,
 				937EA0281E5A267C00D0893A /* PostView.swift */,
 				937EA02A1E5A271F00D0893A /* PostView.xib */,
 				937EA02C1E5B8B5300D0893A /* UIApplcation.swift */,
@@ -248,6 +251,7 @@
 				937EA02D1E5B8B5300D0893A /* UIApplcation.swift in Sources */,
 				93D9EA641DE273FD00089002 /* Section.swift in Sources */,
 				93D9EA6A1DE3491100089002 /* HomeView.swift in Sources */,
+				93BEB6D21E7E878300C68DE5 /* PostViewController.swift in Sources */,
 				93BAD2F81E586741009DF853 /* RowHomeSocial.swift in Sources */,
 				93BAD2F01E585662009DF853 /* RowHomeBlog.swift in Sources */,
 				93294FFA1E337D0D00FDAF50 /* RowHomePastActivities.swift in Sources */,

+ 1 - 1
app/Base.lproj/Main.storyboard

@@ -302,7 +302,7 @@
         <!--Post-->
         <scene sceneID="zgg-Cx-j75">
             <objects>
-                <viewController title="Post" id="UkS-wI-Yhx" sceneMemberID="viewController">
+                <viewController title="Post" id="UkS-wI-Yhx" customClass="PostViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="yy6-d2-MRo"/>
                         <viewControllerLayoutGuide type="bottom" id="IxZ-up-5UO"/>

+ 1 - 0
app/PostView.swift

@@ -47,6 +47,7 @@ class PostView: UIView {
 
 	@IBOutlet weak var commentContent: UITextView!
 	
+	var id: Int = -1
 	
 	override init(frame: CGRect){
 		print("POST:DEBUG: Init cgrect")

+ 43 - 22
app/PostView.xib

@@ -29,14 +29,30 @@
             <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
+                <navigationBar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PAV-4K-mGS">
+                    <rect key="frame" x="0.0" y="0.0" width="320" height="65"/>
+                    <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="65" id="Fmg-jt-mY1"/>
+                    </constraints>
+                    <color key="barTintColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    <textAttributes key="titleTextAttributes">
+                        <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    </textAttributes>
+                    <items>
+                        <navigationItem title="Gasteizko Margolariak" id="rxh-zx-B6G">
+                            <barButtonItem key="backBarButtonItem" title="Back" id="lPX-Uf-eO6"/>
+                        </navigationItem>
+                    </items>
+                </navigationBar>
                 <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8gP-MM-Wzw">
-                    <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+                    <rect key="frame" x="0.0" y="65" width="320" height="415"/>
                     <subviews>
                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EAf-cL-nxv" userLabel="Section">
-                            <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+                            <rect key="frame" x="10" y="10" width="300" height="395"/>
                             <subviews>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="Title" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4ub-YM-i5l" userLabel="Title">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="24"/>
+                                    <rect key="frame" x="0.0" y="0.0" width="300" height="24"/>
                                     <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="24" id="ziT-xG-miV"/>
@@ -46,41 +62,41 @@
                                     <nil key="highlightedColor"/>
                                 </label>
                                 <stackView opaque="NO" contentMode="scaleAspectFit" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="4Ew-hE-42z" userLabel="Content">
-                                    <rect key="frame" x="0.0" y="24" width="320" height="456"/>
+                                    <rect key="frame" x="0.0" y="24" width="300" height="371"/>
                                     <subviews>
                                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bdx-mT-bf3" userLabel="Post">
-                                            <rect key="frame" x="8" y="8" width="304" height="282"/>
+                                            <rect key="frame" x="8" y="8" width="284" height="282"/>
                                             <subviews>
                                                 <stackView contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="Rjp-Jo-7ns">
-                                                    <rect key="frame" x="0.0" y="0.0" width="304" height="290.5"/>
+                                                    <rect key="frame" x="0.0" y="0.0" width="284" height="290.5"/>
                                                     <subviews>
                                                         <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="vwR-EU-h1T" userLabel="Image">
-                                                            <rect key="frame" x="8" y="8" width="288" height="128"/>
+                                                            <rect key="frame" x="8" y="8" width="268" height="128"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="128" id="rXJ-QA-Rv2"/>
                                                             </constraints>
                                                         </imageView>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NoQ-Kc-oS7" userLabel="Text">
-                                                            <rect key="frame" x="8" y="142" width="288" height="20.5"/>
+                                                            <rect key="frame" x="8" y="142" width="268" height="20.5"/>
                                                             <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                             <nil key="textColor"/>
                                                             <nil key="highlightedColor"/>
                                                         </label>
                                                         <stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L5f-5R-97B" userLabel="Image Extra">
-                                                            <rect key="frame" x="8" y="168.5" width="288" height="80"/>
+                                                            <rect key="frame" x="8" y="168.5" width="268" height="80"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="80" id="5I2-Lb-wuc"/>
                                                             </constraints>
                                                         </stackView>
                                                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="apC-ZW-0Hz" userLabel="Separator">
-                                                            <rect key="frame" x="8" y="254.5" width="288" height="1"/>
+                                                            <rect key="frame" x="8" y="254.5" width="268" height="1"/>
                                                             <color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="1" id="q7T-rB-2wq"/>
                                                             </constraints>
                                                         </view>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="254" text="Date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lBQ-aX-qhL" userLabel="Date">
-                                                            <rect key="frame" x="8" y="261.5" width="288" height="21"/>
+                                                            <rect key="frame" x="8" y="261.5" width="268" height="21"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="21" id="dIO-lU-cxb"/>
                                                             </constraints>
@@ -117,31 +133,31 @@
                                             </userDefinedRuntimeAttributes>
                                         </view>
                                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Gq3-pT-mgO" userLabel="Comments">
-                                            <rect key="frame" x="8" y="300" width="304" height="148"/>
+                                            <rect key="frame" x="8" y="300" width="284" height="63"/>
                                             <subviews>
                                                 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="GfC-zi-ouX">
-                                                    <rect key="frame" x="0.0" y="0.0" width="304" height="379"/>
+                                                    <rect key="frame" x="0.0" y="0.0" width="284" height="294"/>
                                                     <subviews>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="# comments" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w3V-dl-ijf" userLabel="Comment Count">
-                                                            <rect key="frame" x="0.0" y="0.0" width="304" height="20.5"/>
+                                                            <rect key="frame" x="0.0" y="0.0" width="284" height="0.0"/>
                                                             <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                             <nil key="textColor"/>
                                                             <nil key="highlightedColor"/>
                                                         </label>
                                                         <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="For-Ru-u5Y" userLabel="Comment List">
-                                                            <rect key="frame" x="0.0" y="20.5" width="304" height="200"/>
+                                                            <rect key="frame" x="0.0" y="0.0" width="284" height="200"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="200" id="5tA-ix-yCI"/>
                                                             </constraints>
                                                         </stackView>
                                                         <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="4Rd-hH-5iP" userLabel="Comment user">
-                                                            <rect key="frame" x="0.0" y="220.5" width="304" height="30.5"/>
+                                                            <rect key="frame" x="0.0" y="200" width="284" height="0.0"/>
                                                             <nil key="textColor"/>
                                                             <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                                             <textInputTraits key="textInputTraits"/>
                                                         </textField>
                                                         <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="kba-hh-hSu" userLabel="Comment content">
-                                                            <rect key="frame" x="0.0" y="251" width="304" height="128"/>
+                                                            <rect key="frame" x="0.0" y="200" width="284" height="94"/>
                                                             <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                                             <string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
                                                             <fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -191,6 +207,7 @@
                                 <constraint firstAttribute="bottom" secondItem="4Ew-hE-42z" secondAttribute="bottom" id="uhz-3p-MMC"/>
                                 <constraint firstItem="4ub-YM-i5l" firstAttribute="width" secondItem="EAf-cL-nxv" secondAttribute="width" id="x3t-Ce-Pdb"/>
                             </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"/>
@@ -205,20 +222,24 @@
                         </view>
                     </subviews>
                     <constraints>
-                        <constraint firstAttribute="bottom" secondItem="EAf-cL-nxv" secondAttribute="bottom" id="Ag8-hb-pRe"/>
-                        <constraint firstItem="EAf-cL-nxv" firstAttribute="leading" secondItem="8gP-MM-Wzw" secondAttribute="leading" id="Xi7-pP-tP3"/>
-                        <constraint firstAttribute="trailing" secondItem="EAf-cL-nxv" secondAttribute="trailing" id="beN-Kp-AUz"/>
+                        <constraint firstAttribute="bottom" secondItem="EAf-cL-nxv" secondAttribute="bottom" constant="10" id="Ag8-hb-pRe"/>
+                        <constraint firstItem="EAf-cL-nxv" firstAttribute="leading" secondItem="8gP-MM-Wzw" secondAttribute="leading" constant="10" id="Xi7-pP-tP3"/>
+                        <constraint firstAttribute="trailing" secondItem="EAf-cL-nxv" secondAttribute="trailing" constant="10" id="beN-Kp-AUz"/>
                         <constraint firstItem="EAf-cL-nxv" firstAttribute="centerX" secondItem="8gP-MM-Wzw" secondAttribute="centerX" id="pNj-KU-Urt"/>
-                        <constraint firstItem="EAf-cL-nxv" firstAttribute="top" secondItem="8gP-MM-Wzw" secondAttribute="top" id="s9c-Vv-GUn"/>
+                        <constraint firstItem="EAf-cL-nxv" firstAttribute="top" secondItem="8gP-MM-Wzw" secondAttribute="top" constant="10" id="s9c-Vv-GUn"/>
                         <constraint firstItem="EAf-cL-nxv" firstAttribute="centerY" secondItem="8gP-MM-Wzw" secondAttribute="centerY" id="uKL-gy-4eG"/>
                     </constraints>
                 </scrollView>
             </subviews>
+            <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
             <constraints>
                 <constraint firstAttribute="bottom" secondItem="8gP-MM-Wzw" secondAttribute="bottom" id="4ip-yx-sWQ"/>
-                <constraint firstItem="8gP-MM-Wzw" firstAttribute="top" secondItem="Zrz-uS-eQa" secondAttribute="top" id="BJ1-cB-ult"/>
+                <constraint firstItem="PAV-4K-mGS" firstAttribute="centerX" secondItem="Zrz-uS-eQa" secondAttribute="centerX" id="Bo7-lN-lbx"/>
+                <constraint firstItem="PAV-4K-mGS" firstAttribute="top" secondItem="Zrz-uS-eQa" secondAttribute="top" id="IxE-tm-HzB"/>
                 <constraint firstItem="8gP-MM-Wzw" firstAttribute="leading" secondItem="Zrz-uS-eQa" secondAttribute="leading" id="SCr-Jl-orE"/>
                 <constraint firstAttribute="trailing" secondItem="8gP-MM-Wzw" secondAttribute="trailing" id="f4k-Vc-8xy"/>
+                <constraint firstItem="8gP-MM-Wzw" firstAttribute="top" secondItem="PAV-4K-mGS" secondAttribute="bottom" id="pgP-gq-5cj"/>
+                <constraint firstItem="PAV-4K-mGS" firstAttribute="width" secondItem="Zrz-uS-eQa" secondAttribute="width" id="q1z-aA-rYD"/>
             </constraints>
             <userDefinedRuntimeAttributes>
                 <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">

+ 65 - 0
app/PostViewController.swift

@@ -0,0 +1,65 @@
+// 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 PostViewController: UIViewController, UIGestureRecognizerDelegate {
+	
+	var id: Int = -1
+	var delegate: AppDelegate?
+	
+	//Each of the sections of the app.
+	
+	var passId: Int = -1
+	
+	func getContext () -> NSManagedObjectContext {
+		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		//return appDelegate.persistentContainer.viewContext
+		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
+	}
+	
+	func showPost(id: Int){
+		print("POSTCONTROLLER:DEBUG: showPost \(id)")
+	}
+	
+	/**
+	Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		print("POSTCONTROLLER:LOG: viewDidLoad()")
+		
+		super.viewDidLoad()
+		
+	}
+	
+	/**
+	Dispose of any resources that can be recreated.
+	*/
+	override func didReceiveMemoryWarning() {
+		super.didReceiveMemoryWarning()
+	}
+	
+}
+

+ 10 - 0
app/ViewController.swift

@@ -39,6 +39,8 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	@IBOutlet weak var containerViewLocation: UIView!
 	@IBOutlet weak var containerViewHome: HomeView!
 	
+	var passId: Int = -1
+	
 	func getContext () -> NSManagedObjectContext {
 		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		//return appDelegate.persistentContainer.viewContext
@@ -47,9 +49,17 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	
 	func showPost(id: Int){
 		print("CONTROLLER:DEBUG: showPost \(id)")
+		self.passId = id
 		performSegue(withIdentifier: "SeguePost", sender: nil)
 	}
 	
+	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+		print("CONTROLLER:DEBUG: preparing for segue \(segue.identifier) with id \(self.passId)")
+		if segue.identifier == "SeguePost"{
+			(segue.destination as! PostViewController).id = passId
+		}
+	}
+	
 	/**
 	 Run when the app loads.
 	*/