|
@@ -21,55 +21,45 @@
|
|
|
import Foundation
|
|
import Foundation
|
|
|
import CoreData
|
|
import CoreData
|
|
|
import UIKit
|
|
import UIKit
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
-Class to handle the home view.
|
|
|
|
|
-*/
|
|
|
|
|
|
|
+ Class to handle the home view.
|
|
|
|
|
+ */
|
|
|
class HomeView: UIView {
|
|
class HomeView: UIView {
|
|
|
|
|
|
|
|
- // Outlets
|
|
|
|
|
- @IBOutlet var scrollView: UIScrollView!
|
|
|
|
|
- @IBOutlet var container: UIView!
|
|
|
|
|
- @IBOutlet var locationSection: Section!
|
|
|
|
|
- @IBOutlet var lablancaSection: Section!
|
|
|
|
|
- @IBOutlet var futureActivitiesSection: Section!
|
|
|
|
|
- @IBOutlet var blogSection: Section!
|
|
|
|
|
- @IBOutlet var gallerySection: Section!
|
|
|
|
|
- @IBOutlet var pastActivitiesSection: Section!
|
|
|
|
|
- @IBOutlet var socialSection: Section!
|
|
|
|
|
-
|
|
|
|
|
- var lang: String? = nil
|
|
|
|
|
- var moc: NSManagedObjectContext? = nil
|
|
|
|
|
- var appDelegate: AppDelegate? = nil
|
|
|
|
|
|
|
+ //The main scroll view.
|
|
|
|
|
+ @IBOutlet weak var scrollView: UIScrollView!
|
|
|
|
|
|
|
|
- let dbgTxt = "IVV"
|
|
|
|
|
|
|
+ //The container of the view.
|
|
|
|
|
+ @IBOutlet weak var container: UIView!
|
|
|
|
|
|
|
|
|
|
+ //Each of the sections of the view.
|
|
|
|
|
+ @IBOutlet weak var locationSection: Section!
|
|
|
|
|
+ @IBOutlet weak var lablancaSection: Section!
|
|
|
|
|
+ @IBOutlet weak var futureActivitiesSection: Section!
|
|
|
|
|
+ @IBOutlet weak var blogSection: Section!
|
|
|
|
|
+ @IBOutlet weak var gallerySection: Section!
|
|
|
|
|
+ @IBOutlet weak var pastActivitiesSection: Section!
|
|
|
|
|
+ @IBOutlet weak var socialSection: Section!
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- Run when the view is started.
|
|
|
|
|
- :param: frame Frame for the view.
|
|
|
|
|
- */
|
|
|
|
|
override init(frame: CGRect){
|
|
override init(frame: CGRect){
|
|
|
super.init(frame: frame)
|
|
super.init(frame: frame)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
- Run when the view is started.
|
|
|
|
|
- :param: coder Application decoder.
|
|
|
|
|
|
|
+ Run when the view is started.
|
|
|
*/
|
|
*/
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
|
|
|
|
super.init(coder: aDecoder)
|
|
super.init(coder: aDecoder)
|
|
|
|
|
|
|
|
- // Load the contents of the HomeView.xib file.
|
|
|
|
|
|
|
+ //Load the contents of the HomeView.xib file.
|
|
|
Bundle.main.loadNibNamed("HomeView", owner: self, options: nil)
|
|
Bundle.main.loadNibNamed("HomeView", owner: self, options: nil)
|
|
|
self.addSubview(container)
|
|
self.addSubview(container)
|
|
|
- self.container.frame = self.bounds
|
|
|
|
|
|
|
+ container.frame = self.bounds
|
|
|
|
|
|
|
|
|
|
|
|
|
- // Set titles for each section
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //Set titles for each section
|
|
|
locationSection.setTitle(text: "Encuentranos")
|
|
locationSection.setTitle(text: "Encuentranos")
|
|
|
lablancaSection.setTitle(text: "La Blanca")
|
|
lablancaSection.setTitle(text: "La Blanca")
|
|
|
futureActivitiesSection.setTitle(text: "Proximas actividades")
|
|
futureActivitiesSection.setTitle(text: "Proximas actividades")
|
|
@@ -78,53 +68,35 @@ class HomeView: UIView {
|
|
|
pastActivitiesSection.setTitle(text: "Ultimas actividades")
|
|
pastActivitiesSection.setTitle(text: "Ultimas actividades")
|
|
|
socialSection.setTitle(text: "Siguenos")
|
|
socialSection.setTitle(text: "Siguenos")
|
|
|
|
|
|
|
|
- // Get info to populate sections
|
|
|
|
|
- self.moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
|
|
|
|
|
- self.appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
|
|
- self.moc?.persistentStoreCoordinator = appDelegate?.persistentStoreCoordinator
|
|
|
|
|
- self.lang = getLanguage()
|
|
|
|
|
|
|
+ //Get info to populate sections
|
|
|
|
|
+ let moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
|
|
|
|
|
|
|
|
- // Populate sections
|
|
|
|
|
- self.populate()
|
|
|
|
|
|
|
+ let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
|
|
+ moc.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
|
|
|
|
|
+ let lang : String = 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())
|
|
|
|
|
|
|
|
- //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)")
|
|
|
|
|
- //}
|
|
|
|
|
- // TODO: Calculate at the end
|
|
|
|
|
- //self.scrollView.contentSize.height = 1300// CGFloat(h);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- func populate2(){
|
|
|
|
|
- NSLog(":HOME:DEBUG: Dummy Populating home view.")
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- Triggers a reloading (or initial loading) of all sections.
|
|
|
|
|
- */
|
|
|
|
|
- open func populate(){
|
|
|
|
|
|
|
|
|
|
- NSLog(":HOME:DEBUG: Populating home view.")
|
|
|
|
|
|
|
+ pastActivitiesSection.expandSection()
|
|
|
|
|
|
|
|
- //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()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //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)")
|
|
|
|
|
+ }
|
|
|
|
|
+ // TODO: Calculate at the end
|
|
|
|
|
+ self.scrollView.contentSize.height = 1300// CGFloat(h);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- Retrieves the device language. The only available ones are Spanish, English and Basque.
|
|
|
|
|
- :return: Two letter language code (en, eu, es). If other, spanish will be selected.
|
|
|
|
|
- */
|
|
|
|
|
func getLanguage() -> String{
|
|
func getLanguage() -> String{
|
|
|
let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
|
|
let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
|
|
|
if(pre == "es" || pre == "en" || pre == "eu"){
|
|
if(pre == "es" || pre == "en" || pre == "eu"){
|
|
@@ -135,17 +107,9 @@ class HomeView: UIView {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- Sets the future activities section.
|
|
|
|
|
- Loads up to two future activities.
|
|
|
|
|
- :param: context Aplication context.
|
|
|
|
|
- :param: delegate Application delegate.
|
|
|
|
|
- :param: lang Device language. Two letter code. Accepts 'es', 'en' and 'eu'.
|
|
|
|
|
- :param: parent View where the rows will be loaded.
|
|
|
|
|
- */
|
|
|
|
|
func setUpFutureActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
|
|
func setUpFutureActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
|
|
|
|
|
|
|
|
|
|
+ //context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
|
|
|
let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
|
|
let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
|
|
|
let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
|
|
let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
|
|
|
let sortDescriptors = [sortDescriptor]
|
|
let sortDescriptors = [sortDescriptor]
|
|
@@ -154,8 +118,11 @@ class HomeView: UIView {
|
|
|
fetchRequest.fetchLimit = 2
|
|
fetchRequest.fetchLimit = 2
|
|
|
|
|
|
|
|
do {
|
|
do {
|
|
|
|
|
+ //go get the results
|
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
|
- NSLog(":HOME:DEBUG: Future activity count: \(searchResults.count)")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //I like to check the size of the returned results!
|
|
|
|
|
+ print ("Activities: \(searchResults.count)")
|
|
|
|
|
|
|
|
var row : RowHomePastActivities
|
|
var row : RowHomePastActivities
|
|
|
var count = 0
|
|
var count = 0
|
|
@@ -164,14 +131,19 @@ class HomeView: UIView {
|
|
|
var text: String
|
|
var text: String
|
|
|
var image: String
|
|
var image: String
|
|
|
|
|
|
|
|
|
|
+ //You need to convert to NSManagedObject to use 'for' loops
|
|
|
for r in searchResults as [NSManagedObject] {
|
|
for r in searchResults as [NSManagedObject] {
|
|
|
count = count + 1
|
|
count = count + 1
|
|
|
|
|
+ //get the Key Value pairs (although there may be a better way to do that...
|
|
|
|
|
+ print("Perm: \(r.value(forKey: "permalink"))")
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//Create a new row
|
|
//Create a new row
|
|
|
row = RowHomePastActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
|
|
row = RowHomePastActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
|
|
|
id = r.value(forKey: "id")! as! Int
|
|
id = r.value(forKey: "id")! as! Int
|
|
|
title = r.value(forKey: "title_\(lang)")! as! String
|
|
title = r.value(forKey: "title_\(lang)")! as! String
|
|
|
text = r.value(forKey: "text_\(lang)")! as! String
|
|
text = r.value(forKey: "text_\(lang)")! as! String
|
|
|
|
|
+ print(title)
|
|
|
row.setTitle(text: title)
|
|
row.setTitle(text: title)
|
|
|
row.setText(text: text)
|
|
row.setText(text: text)
|
|
|
|
|
|
|
@@ -187,30 +159,26 @@ class HomeView: UIView {
|
|
|
let imgSearchResults = try context.fetch(imgFetchRequest)
|
|
let imgSearchResults = try context.fetch(imgFetchRequest)
|
|
|
for imgR in imgSearchResults as [NSManagedObject]{
|
|
for imgR in imgSearchResults as [NSManagedObject]{
|
|
|
image = imgR.value(forKey: "image")! as! String
|
|
image = imgR.value(forKey: "image")! as! String
|
|
|
|
|
+ print ("IMAGE: \(image)")
|
|
|
row.setImage(filename: image)
|
|
row.setImage(filename: image)
|
|
|
}
|
|
}
|
|
|
} catch {
|
|
} catch {
|
|
|
- NSLog(":HOME:ERROR: Error getting image for futureactivity \(id): \(error)")
|
|
|
|
|
|
|
+ print("Error getting image for activity \(id): \(error)")
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ print("Row height: \(row.frame.height)")
|
|
|
|
|
+
|
|
|
parent.addArrangedSubview(row)
|
|
parent.addArrangedSubview(row)
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
} catch {
|
|
} catch {
|
|
|
- NSLog(":HOME:ERROR: Error setting the future activities section up: \(error)")
|
|
|
|
|
|
|
+ print("Error with request: \(error)")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- Sets the blog section.
|
|
|
|
|
- Loads up to two posts.
|
|
|
|
|
- :param: context Aplication context.
|
|
|
|
|
- :param: delegate Application delegate.
|
|
|
|
|
- :param: lang Device language. Two letter code. Accepts 'es', 'en' and 'eu'.
|
|
|
|
|
- :param: parent View where the rows will be loaded.
|
|
|
|
|
- */
|
|
|
|
|
func setUpBlog(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
|
|
func setUpBlog(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
|
|
|
|
|
|
|
|
|
|
+ //context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
|
|
|
let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
|
|
let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
|
|
|
let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
|
|
let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
|
|
|
let sortDescriptors = [sortDescriptor]
|
|
let sortDescriptors = [sortDescriptor]
|
|
@@ -218,8 +186,11 @@ class HomeView: UIView {
|
|
|
fetchRequest.fetchLimit = 2
|
|
fetchRequest.fetchLimit = 2
|
|
|
|
|
|
|
|
do {
|
|
do {
|
|
|
|
|
+ //go get the results
|
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
|
- NSLog(":HOME:DEBUG: Post count: \(searchResults.count)")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //I like to check the size of the returned results!
|
|
|
|
|
+ print ("Post: \(searchResults.count)")
|
|
|
|
|
|
|
|
var row : RowHomeBlog
|
|
var row : RowHomeBlog
|
|
|
var count = 0
|
|
var count = 0
|
|
@@ -228,8 +199,12 @@ class HomeView: UIView {
|
|
|
var text: String
|
|
var text: String
|
|
|
var image: String
|
|
var image: String
|
|
|
|
|
|
|
|
|
|
+ //You need to convert to NSManagedObject to use 'for' loops
|
|
|
for r in searchResults as [NSManagedObject] {
|
|
for r in searchResults as [NSManagedObject] {
|
|
|
count = count + 1
|
|
count = count + 1
|
|
|
|
|
+ //get the Key Value pairs (although there may be a better way to do that...
|
|
|
|
|
+ print("Perm: \(r.value(forKey: "permalink"))")
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//Create a new row
|
|
//Create a new row
|
|
|
row = RowHomeBlog.init(s: "rowHomeBlog\(count)", i: count)
|
|
row = RowHomeBlog.init(s: "rowHomeBlog\(count)", i: count)
|
|
@@ -253,12 +228,15 @@ class HomeView: UIView {
|
|
|
let imgSearchResults = try context.fetch(imgFetchRequest)
|
|
let imgSearchResults = try context.fetch(imgFetchRequest)
|
|
|
for imgR in imgSearchResults as [NSManagedObject]{
|
|
for imgR in imgSearchResults as [NSManagedObject]{
|
|
|
image = imgR.value(forKey: "image")! as! String
|
|
image = imgR.value(forKey: "image")! as! String
|
|
|
|
|
+ print ("IMAGE: \(image)")
|
|
|
row.setImage(filename: image)
|
|
row.setImage(filename: image)
|
|
|
}
|
|
}
|
|
|
} catch {
|
|
} catch {
|
|
|
- NSLog(":HOME:ERROR: Error getting image for post \(id): \(error)")
|
|
|
|
|
|
|
+ print("Error getting image for post \(id): \(error)")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ print("Row height: \(row.frame.height)")
|
|
|
|
|
+
|
|
|
parent.addArrangedSubview(row)
|
|
parent.addArrangedSubview(row)
|
|
|
|
|
|
|
|
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
|
|
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
|
|
@@ -267,21 +245,13 @@ class HomeView: UIView {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
} catch {
|
|
} catch {
|
|
|
- NSLog(":HOME:ERROR: Error setting the blog section up: \(error)")
|
|
|
|
|
|
|
+ print("Error with request: \(error)")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- Sets the past activities section.
|
|
|
|
|
- Loads up to two past activities.
|
|
|
|
|
- :param: context Aplication context.
|
|
|
|
|
- :param: delegate Application delegate.
|
|
|
|
|
- :param: lang Device language. Two letter code. Accepts 'es', 'en' and 'eu'.
|
|
|
|
|
- :param: parent View where the rows will be loaded.
|
|
|
|
|
- */
|
|
|
|
|
func setUpPastActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
|
|
func setUpPastActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
|
|
|
|
|
|
|
|
|
|
+ //context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
|
|
|
let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
|
|
let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
|
|
|
let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
|
|
let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
|
|
|
let sortDescriptors = [sortDescriptor]
|
|
let sortDescriptors = [sortDescriptor]
|
|
@@ -290,8 +260,11 @@ class HomeView: UIView {
|
|
|
fetchRequest.fetchLimit = 2
|
|
fetchRequest.fetchLimit = 2
|
|
|
|
|
|
|
|
do {
|
|
do {
|
|
|
|
|
+ //go get the results
|
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
|
- NSLog(":HOME:LOG: Setting past activities up. Count: \(searchResults.count)")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //I like to check the size of the returned results!
|
|
|
|
|
+ print ("Activities: \(searchResults.count)")
|
|
|
|
|
|
|
|
var row : RowHomePastActivities
|
|
var row : RowHomePastActivities
|
|
|
var count = 0
|
|
var count = 0
|
|
@@ -300,8 +273,12 @@ class HomeView: UIView {
|
|
|
var text: String
|
|
var text: String
|
|
|
var image: String
|
|
var image: String
|
|
|
|
|
|
|
|
|
|
+ //You need to convert to NSManagedObject to use 'for' loops
|
|
|
for r in searchResults as [NSManagedObject] {
|
|
for r in searchResults as [NSManagedObject] {
|
|
|
count = count + 1
|
|
count = count + 1
|
|
|
|
|
+ //get the Key Value pairs (although there may be a better way to do that...
|
|
|
|
|
+ print("Perm: \(r.value(forKey: "permalink"))")
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//Create a new row
|
|
//Create a new row
|
|
|
row = RowHomePastActivities.init(s: "rowHomePastActivities\(count)", i: count)
|
|
row = RowHomePastActivities.init(s: "rowHomePastActivities\(count)", i: count)
|
|
@@ -325,35 +302,32 @@ class HomeView: UIView {
|
|
|
let imgSearchResults = try context.fetch(imgFetchRequest)
|
|
let imgSearchResults = try context.fetch(imgFetchRequest)
|
|
|
for imgR in imgSearchResults as [NSManagedObject]{
|
|
for imgR in imgSearchResults as [NSManagedObject]{
|
|
|
image = imgR.value(forKey: "image")! as! String
|
|
image = imgR.value(forKey: "image")! as! String
|
|
|
|
|
+ print ("IMAGE: \(image)")
|
|
|
row.setImage(filename: image)
|
|
row.setImage(filename: image)
|
|
|
}
|
|
}
|
|
|
} catch {
|
|
} catch {
|
|
|
- NSLog(":HOME:ERROR: Error getting image for past activity \(id): \(error)")
|
|
|
|
|
|
|
+ print("Error getting image for activity \(id): \(error)")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ print("Row height: \(row.frame.height)")
|
|
|
|
|
+
|
|
|
parent.addArrangedSubview(row)
|
|
parent.addArrangedSubview(row)
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
} catch {
|
|
} catch {
|
|
|
- NSLog(":HOME:ERROR: Error setting the past activities section up: \(error)")
|
|
|
|
|
|
|
+ print("Error with request: \(error)")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- Sets the fgallery section.
|
|
|
|
|
- Loads up to four photos.
|
|
|
|
|
- :param: context Aplication context.
|
|
|
|
|
- :param: delegate Application delegate.
|
|
|
|
|
- :param: parent View where the rows will be loaded.
|
|
|
|
|
- */
|
|
|
|
|
func setUpGallery(context : NSManagedObjectContext, delegate: AppDelegate,parent: UIStackView){
|
|
func setUpGallery(context : NSManagedObjectContext, delegate: AppDelegate,parent: UIStackView){
|
|
|
- NSLog(":HOME:LOG: Setting gallery section up.")
|
|
|
|
|
|
|
+ print("HOME:LOG: Setting up gallery.")
|
|
|
|
|
|
|
|
// Create the row
|
|
// Create the row
|
|
|
var row: RowHomeGallery
|
|
var row: RowHomeGallery
|
|
|
row = RowHomeGallery.init(s: "rowHomeGallery", i: 0)
|
|
row = RowHomeGallery.init(s: "rowHomeGallery", i: 0)
|
|
|
parent.addArrangedSubview(row)
|
|
parent.addArrangedSubview(row)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Set images
|
|
// Set images
|
|
|
let fetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
|
|
let fetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
|
|
|
let sortDescriptor = NSSortDescriptor(key: "uploaded", ascending: false)
|
|
let sortDescriptor = NSSortDescriptor(key: "uploaded", ascending: false)
|
|
@@ -362,7 +336,10 @@ class HomeView: UIView {
|
|
|
fetchRequest.fetchLimit = 4
|
|
fetchRequest.fetchLimit = 4
|
|
|
|
|
|
|
|
do {
|
|
do {
|
|
|
|
|
+ //go get the results
|
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
let searchResults = try context.fetch(fetchRequest)
|
|
|
|
|
+
|
|
|
|
|
+ var id: Int
|
|
|
var image: String
|
|
var image: String
|
|
|
|
|
|
|
|
// Loop images
|
|
// Loop images
|
|
@@ -379,31 +356,24 @@ class HomeView: UIView {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
catch{
|
|
catch{
|
|
|
- NSLog(":HOME:ERROR: Error setting gallery up: \(error)")
|
|
|
|
|
|
|
+ print("HOME:ERROR: Error setting gallery up: \(error)")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- Sets the social section.
|
|
|
|
|
- :param: parent View where the rows will be loaded.
|
|
|
|
|
- */
|
|
|
|
|
func setUpSocial(parent : UIStackView){
|
|
func setUpSocial(parent : UIStackView){
|
|
|
- NSLog(":HOME:LOG: Setting soceial section up.")
|
|
|
|
|
|
|
+ print("SETING UP SOCIAL")
|
|
|
//Create a new row
|
|
//Create a new row
|
|
|
var row : RowHomeSocial
|
|
var row : RowHomeSocial
|
|
|
row = RowHomeSocial.init(s: "rowHomeSocial", i: 0)
|
|
row = RowHomeSocial.init(s: "rowHomeSocial", i: 0)
|
|
|
|
|
+ print("ROW CREATED")
|
|
|
parent.addArrangedSubview(row)
|
|
parent.addArrangedSubview(row)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- opens the blog section, showing a post.
|
|
|
|
|
- :param: sender: View calling the function.
|
|
|
|
|
- */
|
|
|
|
|
func openPost(_ sender:UITapGestureRecognizer? = nil){
|
|
func openPost(_ sender:UITapGestureRecognizer? = nil){
|
|
|
- NSLog(":HOME:DEBUG: Getting delegate and showing post.")
|
|
|
|
|
|
|
+ print("HOME:DEBUG: getting delegate and showing post.")
|
|
|
let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
|
|
delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
|
|
|
- NSLog(":HOME:DEBUG: Post should be shown.")
|
|
|
|
|
|
|
+ print("HOME:DEBUG: Post should be shown.")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|