diff --git a/AvH Plan.xcodeproj/project.pbxproj b/AvH Plan.xcodeproj/project.pbxproj index 513c105..dc9eadb 100644 --- a/AvH Plan.xcodeproj/project.pbxproj +++ b/AvH Plan.xcodeproj/project.pbxproj @@ -13,17 +13,20 @@ A957A75222DDC15500E0A2ED /* MenuViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A957A75022DDC15500E0A2ED /* MenuViewCell.xib */; }; A96133802299867400B541D4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A961337F2299867400B541D4 /* AppDelegate.swift */; }; A96133822299867400B541D4 /* PlanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133812299867400B541D4 /* PlanViewController.swift */; }; - A96133842299867400B541D4 /* PersonalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133832299867400B541D4 /* PersonalViewController.swift */; }; A96133872299867400B541D4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A96133852299867400B541D4 /* Main.storyboard */; }; A96133892299867A00B541D4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A96133882299867A00B541D4 /* Assets.xcassets */; }; A961338C2299867A00B541D4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A961338A2299867A00B541D4 /* LaunchScreen.storyboard */; }; A96133972299867A00B541D4 /* AvH_PlanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133962299867A00B541D4 /* AvH_PlanTests.swift */; }; A96133A22299867A00B541D4 /* AvH_PlanUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133A12299867A00B541D4 /* AvH_PlanUITests.swift */; }; A96133B0229986DF00B541D4 /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133AF229986DF00B541D4 /* CollectionViewCell.swift */; }; + A96D4CC822DDE01A006BAB34 /* GeneralPlanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96D4CC722DDE01A006BAB34 /* GeneralPlanViewController.swift */; }; + A96D4CCA22DDE184006BAB34 /* PersonalPlanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96D4CC922DDE184006BAB34 /* PersonalPlanViewController.swift */; }; A9A3496C22D4859200F35AE0 /* SubstModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A3496B22D4859200F35AE0 /* SubstModel.swift */; }; A9C1D2FE22D656A400139043 /* InfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C1D2FD22D656A400139043 /* InfoViewController.swift */; }; A9C1D30022D656DD00139043 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C1D2FF22D656DD00139043 /* MenuViewController.swift */; }; A9C1D30222D7237200139043 /* DataFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C1D30122D7237200139043 /* DataFetcher.swift */; }; + A9D830A722DE258C00D7EA05 /* PlanViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D830A522DE258C00D7EA05 /* PlanViewCell.swift */; }; + A9D830A822DE258C00D7EA05 /* PlanViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9D830A622DE258C00D7EA05 /* PlanViewCell.xib */; }; C736A19A44C64423F3A695B7 /* Pods_AvH_PlanUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74EDE3D8134812AB76BEB988 /* Pods_AvH_PlanUITests.framework */; }; /* End PBXBuildFile section */ @@ -53,7 +56,6 @@ A961337C2299867400B541D4 /* AvH Plan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AvH Plan.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A961337F2299867400B541D4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; A96133812299867400B541D4 /* PlanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanViewController.swift; sourceTree = ""; }; - A96133832299867400B541D4 /* PersonalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonalViewController.swift; sourceTree = ""; }; A96133862299867400B541D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; A96133882299867A00B541D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; A961338B2299867A00B541D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -65,10 +67,14 @@ A96133A12299867A00B541D4 /* AvH_PlanUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvH_PlanUITests.swift; sourceTree = ""; }; A96133A32299867A00B541D4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A96133AF229986DF00B541D4 /* CollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = ""; }; + A96D4CC722DDE01A006BAB34 /* GeneralPlanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralPlanViewController.swift; sourceTree = ""; }; + A96D4CC922DDE184006BAB34 /* PersonalPlanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonalPlanViewController.swift; sourceTree = ""; }; A9A3496B22D4859200F35AE0 /* SubstModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubstModel.swift; sourceTree = ""; }; A9C1D2FD22D656A400139043 /* InfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoViewController.swift; sourceTree = ""; }; A9C1D2FF22D656DD00139043 /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = ""; }; A9C1D30122D7237200139043 /* DataFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataFetcher.swift; sourceTree = ""; }; + A9D830A522DE258C00D7EA05 /* PlanViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanViewCell.swift; sourceTree = ""; }; + A9D830A622DE258C00D7EA05 /* PlanViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PlanViewCell.xib; sourceTree = ""; }; C6EC6ACE7893F2BB0A157817 /* Pods-AvH Plan.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvH Plan.release.xcconfig"; path = "Target Support Files/Pods-AvH Plan/Pods-AvH Plan.release.xcconfig"; sourceTree = ""; }; D9D6269E96544A9242A29611 /* Pods_AvH_PlanTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AvH_PlanTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E596AED9E99670CBF1B6F49E /* Pods-AvH Plan.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvH Plan.debug.xcconfig"; path = "Target Support Files/Pods-AvH Plan/Pods-AvH Plan.debug.xcconfig"; sourceTree = ""; }; @@ -155,7 +161,6 @@ children = ( A961337F2299867400B541D4 /* AppDelegate.swift */, A96133812299867400B541D4 /* PlanViewController.swift */, - A96133832299867400B541D4 /* PersonalViewController.swift */, A9C1D2FD22D656A400139043 /* InfoViewController.swift */, A9C1D2FF22D656DD00139043 /* MenuViewController.swift */, A96133852299867400B541D4 /* Main.storyboard */, @@ -167,6 +172,10 @@ A9C1D30122D7237200139043 /* DataFetcher.swift */, A957A74F22DDC15500E0A2ED /* MenuViewCell.swift */, A957A75022DDC15500E0A2ED /* MenuViewCell.xib */, + A9D830A522DE258C00D7EA05 /* PlanViewCell.swift */, + A9D830A622DE258C00D7EA05 /* PlanViewCell.xib */, + A96D4CC722DDE01A006BAB34 /* GeneralPlanViewController.swift */, + A96D4CC922DDE184006BAB34 /* PersonalPlanViewController.swift */, ); path = "AvH Plan"; sourceTree = ""; @@ -301,6 +310,7 @@ A957A75222DDC15500E0A2ED /* MenuViewCell.xib in Resources */, A96133892299867A00B541D4 /* Assets.xcassets in Resources */, A96133872299867400B541D4 /* Main.storyboard in Resources */, + A9D830A822DE258C00D7EA05 /* PlanViewCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -424,15 +434,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - A96133842299867400B541D4 /* PersonalViewController.swift in Sources */, A96133802299867400B541D4 /* AppDelegate.swift in Sources */, A9A3496C22D4859200F35AE0 /* SubstModel.swift in Sources */, A9C1D30022D656DD00139043 /* MenuViewController.swift in Sources */, A96133B0229986DF00B541D4 /* CollectionViewCell.swift in Sources */, A957A75122DDC15500E0A2ED /* MenuViewCell.swift in Sources */, A9C1D2FE22D656A400139043 /* InfoViewController.swift in Sources */, + A9D830A722DE258C00D7EA05 /* PlanViewCell.swift in Sources */, + A96D4CC822DDE01A006BAB34 /* GeneralPlanViewController.swift in Sources */, A96133822299867400B541D4 /* PlanViewController.swift in Sources */, A9C1D30222D7237200139043 /* DataFetcher.swift in Sources */, + A96D4CCA22DDE184006BAB34 /* PersonalPlanViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/AvH Plan/Base.lproj/Main.storyboard b/AvH Plan/Base.lproj/Main.storyboard index 65186dc..aa12b04 100644 --- a/AvH Plan/Base.lproj/Main.storyboard +++ b/AvH Plan/Base.lproj/Main.storyboard @@ -7,128 +7,17 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -141,17 +30,13 @@ - - - - - + @@ -161,121 +46,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -286,11 +61,7 @@ - - - - @@ -298,7 +69,7 @@ - + diff --git a/AvH Plan/GeneralPlanViewController.swift b/AvH Plan/GeneralPlanViewController.swift new file mode 100644 index 0000000..b4a153d --- /dev/null +++ b/AvH Plan/GeneralPlanViewController.swift @@ -0,0 +1,45 @@ +// +// GeneralViewController.swift +// AvH Plan +// +// Created by Deniz Duezgoeren on 16.07.19. +// Copyright © 2019 Deniz Duezgoeren. All rights reserved. +// + +import UIKit + +class GeneralViewController: PlanViewController { + + @IBOutlet weak var toolbar: UINavigationBar! + + override func viewDidLoad() { + super.viewDidLoad() + } + + override func getViewType() -> String { + return "plan" + } + + override func getRefreshViewString() -> String { + return "Fetching the plan..." + } + + override func getFromDatabase() -> [SubstModel] { + return df.getFromDatabase() + } + + override func getToolbarBottomAnchor() -> NSLayoutYAxisAnchor { + return toolbar.bottomAnchor + } + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/AvH Plan/PersonalPlanViewController.swift b/AvH Plan/PersonalPlanViewController.swift new file mode 100644 index 0000000..da1404a --- /dev/null +++ b/AvH Plan/PersonalPlanViewController.swift @@ -0,0 +1,47 @@ +// +// PersonalPlanViewController.swift +// AvH Plan +// +// Created by Deniz Duezgoeren on 16.07.19. +// Copyright © 2019 Deniz Duezgoeren. All rights reserved. +// + +import UIKit + +class PersonalPlanViewController: PlanViewController { + + @IBOutlet weak var toolbar: UINavigationBar! + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func getViewType() -> String { + return "personal" + } + + override func getRefreshViewString() -> String { + return "Fetching your plan..." + } + + override func getFromDatabase() -> [SubstModel] { + return df.getPersonalFromDatabase() + } + + override func getToolbarBottomAnchor() -> NSLayoutYAxisAnchor { + return toolbar.bottomAnchor + } + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/AvH Plan/PersonalViewController.swift b/AvH Plan/PersonalViewController.swift deleted file mode 100644 index 2cecefc..0000000 --- a/AvH Plan/PersonalViewController.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// PersonalViewController.swift -// AvH Plan -// -// Created by Deniz Duezgoeren on 11.07.19. -// Copyright © 2019 Deniz Duezgoeren. All rights reserved. -// - -import UIKit - -class PersonalViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { - - let reuseIdentifier = "cell" - @IBOutlet weak var collectionView: UICollectionView! - var substs = Array() - private let refreshControl = UIRefreshControl() - let df = DataFetcher() - - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - if #available(iOS 10.0, *) { - collectionView.refreshControl = refreshControl - } else { - collectionView.addSubview(refreshControl) - } - refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged) - refreshControl.tintColor = UIColor(red: 0.39, green: 0.71, blue: 0.96, alpha: 1.0) - refreshControl.attributedTitle = NSAttributedString(string: "Fetching your plan...") - } - - @objc private func objDoAsync(_ sender: Any) { - df.doAsync(do: "personal") { substitutions in - self.substs = substitutions as! [SubstModel] - self.collectionView.reloadData() - self.refreshControl.endRefreshing() - } - } - - override func viewDidLoad() { - super.viewDidLoad() - collectionView.backgroundColor = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0) - - self.substs = self.df.getPersonalFromDatabase() - self.collectionView.reloadData() - } - - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return self.substs.count - } - - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! CollectionViewCell - if self.substs.count != 0 { - cell.group.text = self.substs[indexPath.item].group - cell.additional.text = self.substs[indexPath.item].additional - cell.date.text = self.substs[indexPath.item].date - cell.time.text = self.substs[indexPath.item].time - cell.room.text = self.substs[indexPath.item].room - - let course = self.substs[indexPath.item].course - let image = df.getImage(from: course) - - if image != nil { - let attachment: NSTextAttachment = NSTextAttachment() - attachment.bounds = CGRect(x: 0, y: 0, width: cell.course.frame.height - 6, height: cell.course.frame.height - 6) - attachment.image = image - - let courseImage = NSMutableAttributedString(attachment: attachment) - let courseString = NSAttributedString(string: " " + course) - courseImage.append(courseString) - - cell.course.attributedText = courseImage - } else { - cell.course.text = course - } - } - - cell.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0) - cell.tintView.backgroundColor = cell.backgroundColor - return cell - } - - // func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - // print("You selected cell#\(indexPath.item)!") - // } - - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: view.frame.size.width, height: 108) - } -} - diff --git a/AvH Plan/PlanViewCell.swift b/AvH Plan/PlanViewCell.swift new file mode 100644 index 0000000..34bedd3 --- /dev/null +++ b/AvH Plan/PlanViewCell.swift @@ -0,0 +1,27 @@ +// +// PlanViewCell.swift +// AvH Plan +// +// Created by Deniz Duezgoeren on 16.07.19. +// Copyright © 2019 Deniz Duezgoeren. All rights reserved. +// + +import UIKit +import MagazineLayout + +class PlanViewCell: MagazineLayoutCollectionViewCell { + + @IBOutlet weak var group: UILabel! + @IBOutlet weak var date: UILabel! + @IBOutlet weak var course: UILabel! + @IBOutlet weak var time: UILabel! + @IBOutlet weak var additional: UILabel! + @IBOutlet weak var room: UILabel! + @IBOutlet weak var tintView: UIView! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + +} diff --git a/AvH Plan/PlanViewCell.xib b/AvH Plan/PlanViewCell.xib new file mode 100644 index 0000000..3c53d9e --- /dev/null +++ b/AvH Plan/PlanViewCell.xib @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AvH Plan/PlanViewController.swift b/AvH Plan/PlanViewController.swift index d578dbb..715fa3f 100644 --- a/AvH Plan/PlanViewController.swift +++ b/AvH Plan/PlanViewController.swift @@ -7,17 +7,41 @@ // import UIKit +import MagazineLayout -class PlanViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { +class PlanViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateMagazineLayout { - let reuseIdentifier = "cell" - @IBOutlet weak var collectionView: UICollectionView! - var substs = Array() + let identifier = "plan_cell" + var substs = [SubstModel]() private let refreshControl = UIRefreshControl() let df = DataFetcher() + let layout = MagazineLayout() + var collectionView: UICollectionView + + required init?(coder decoder: NSCoder) { + collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + super.init(coder: decoder) + } + + func getToolbarBottomAnchor() -> NSLayoutYAxisAnchor { + return view.topAnchor + } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + + view.addSubview(collectionView) + collectionView.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), + collectionView.topAnchor.constraint(equalTo: getToolbarBottomAnchor()), + collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + ]) + collectionView.register(UINib(nibName: "PlanViewCell", bundle: nil), forCellWithReuseIdentifier: identifier) + collectionView.dataSource = self + collectionView.delegate = self + if #available(iOS 10.0, *) { collectionView.refreshControl = refreshControl } else { @@ -25,11 +49,23 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle } refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged) refreshControl.tintColor = UIColor(red: 0.39, green: 0.71, blue: 0.96, alpha: 1.0) - refreshControl.attributedTitle = NSAttributedString(string: "Fetching the plan...") + refreshControl.attributedTitle = NSAttributedString(string: getRefreshViewString()) + } + + func getViewType() -> String { + return "plan" + } + + func getFromDatabase() -> [SubstModel] { + return self.df.getFromDatabase() + } + + func getRefreshViewString() -> String { + return "Fetching the plan..." } @objc private func objDoAsync(_ sender: Any) { - df.doAsync(do: "plan") { substitutions in + df.doAsync(do: getViewType()) { substitutions in self.substs = substitutions as! [SubstModel] self.collectionView.reloadData() self.refreshControl.endRefreshing() @@ -40,7 +76,7 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle super.viewDidLoad() collectionView.backgroundColor = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0) - self.substs = self.df.getFromDatabase() + self.substs = getFromDatabase() self.collectionView.reloadData() } @@ -49,7 +85,7 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! CollectionViewCell + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! PlanViewCell if self.substs.count != 0 { cell.group.text = self.substs[indexPath.item].group cell.additional.text = self.substs[indexPath.item].additional @@ -62,11 +98,11 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle if image != nil { let attachment: NSTextAttachment = NSTextAttachment() - attachment.bounds = CGRect(x: 0, y: 0, width: cell.course.frame.height - 6, height: cell.course.frame.height - 6) + attachment.bounds = CGRect(x: 0, y: 0, width: 16, height: 16) attachment.image = image let courseImage = NSMutableAttributedString(attachment: attachment) - let courseString = NSAttributedString(string: " " + course) + let courseString = NSAttributedString(string: " \(course)") courseImage.append(courseString) cell.course.attributedText = courseImage @@ -80,12 +116,40 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle return cell } -// func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { -// print("You selected cell#\(indexPath.item)!") -// } + // stubs - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - return CGSize(width: view.frame.size.width, height: 108) + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode { + let widthMode = MagazineLayoutItemWidthMode.fullWidth(respectsHorizontalInsets: true) + let heightMode = MagazineLayoutItemHeightMode.dynamic + return MagazineLayoutItemSizeMode(widthMode: widthMode, heightMode: heightMode) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, visibilityModeForHeaderInSectionAtIndex index: Int) -> MagazineLayoutHeaderVisibilityMode { + return .hidden + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, visibilityModeForFooterInSectionAtIndex index: Int) -> MagazineLayoutFooterVisibilityMode { + return .hidden + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, visibilityModeForBackgroundInSectionAtIndex index: Int) -> MagazineLayoutBackgroundVisibilityMode { + return .hidden + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, horizontalSpacingForItemsInSectionAtIndex index: Int) -> CGFloat { + return 0 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, verticalSpacingForElementsInSectionAtIndex index: Int) -> CGFloat { + return 1 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetsForSectionAtIndex index: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetsForItemsInSectionAtIndex index: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } }