|
|
@@ -40,6 +40,10 @@ class HomeView: UIView {
|
|
|
@IBOutlet weak var gallerySection: Section!
|
|
|
@IBOutlet weak var pastActivitiesSection: Section!
|
|
|
@IBOutlet weak var socialSection: Section!
|
|
|
+
|
|
|
+ let lang: String
|
|
|
+ let moc: NSManagedObjectContext
|
|
|
+ let appDelegate: AppDelegate
|
|
|
|
|
|
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{
|