diff --git a/Shopping List.xcodeproj/project.pbxproj b/Shopping List.xcodeproj/project.pbxproj index 9970ba97..bf8057e9 100644 --- a/Shopping List.xcodeproj/project.pbxproj +++ b/Shopping List.xcodeproj/project.pbxproj @@ -8,20 +8,28 @@ /* Begin PBXBuildFile section */ 4613E91221143BFC00E7FF73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4613E91121143BFC00E7FF73 /* AppDelegate.swift */; }; - 4613E91421143BFC00E7FF73 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4613E91321143BFC00E7FF73 /* ViewController.swift */; }; 4613E91721143BFC00E7FF73 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91521143BFC00E7FF73 /* Main.storyboard */; }; 4613E91921143BFD00E7FF73 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91821143BFD00E7FF73 /* Assets.xcassets */; }; 4613E91C21143BFD00E7FF73 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91A21143BFD00E7FF73 /* LaunchScreen.storyboard */; }; + 4BBA772224782E7E007F96A9 /* ShoppingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBA772124782E7E007F96A9 /* ShoppingItem.swift */; }; + 4BBA772424783313007F96A9 /* ShoppingListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBA772324783313007F96A9 /* ShoppingListController.swift */; }; + 4BBA772624783803007F96A9 /* ShoppingListCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBA772524783803007F96A9 /* ShoppingListCollectionViewController.swift */; }; + 4BBA772824783845007F96A9 /* GroceryItemCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBA772724783845007F96A9 /* GroceryItemCollectionViewCell.swift */; }; + 4BBA772A24783873007F96A9 /* GroceryItemDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBA772924783873007F96A9 /* GroceryItemDetailViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 4613E90E21143BFC00E7FF73 /* Shopping List.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Shopping List.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4613E91121143BFC00E7FF73 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 4613E91321143BFC00E7FF73 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 4613E91621143BFC00E7FF73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 4613E91821143BFD00E7FF73 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4613E91B21143BFD00E7FF73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 4613E91D21143BFD00E7FF73 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4BBA772124782E7E007F96A9 /* ShoppingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingItem.swift; sourceTree = ""; }; + 4BBA772324783313007F96A9 /* ShoppingListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingListController.swift; sourceTree = ""; }; + 4BBA772524783803007F96A9 /* ShoppingListCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingListCollectionViewController.swift; sourceTree = ""; }; + 4BBA772724783845007F96A9 /* GroceryItemCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroceryItemCollectionViewCell.swift; sourceTree = ""; }; + 4BBA772924783873007F96A9 /* GroceryItemDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroceryItemDetailViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,16 +62,68 @@ 4613E91021143BFC00E7FF73 /* Shopping List */ = { isa = PBXGroup; children = ( - 4613E91121143BFC00E7FF73 /* AppDelegate.swift */, - 4613E91321143BFC00E7FF73 /* ViewController.swift */, - 4613E91521143BFC00E7FF73 /* Main.storyboard */, - 4613E91821143BFD00E7FF73 /* Assets.xcassets */, - 4613E91A21143BFD00E7FF73 /* LaunchScreen.storyboard */, + 4BBA773024783D5F007F96A9 /* Resources */, + 4BBA772F24783D55007F96A9 /* Stroyboards */, + 4BBA772B24783CBB007F96A9 /* View Controllers */, + 4BBA772C24783CEA007F96A9 /* Views */, + 4BBA772D24783D1D007F96A9 /* Models */, + 4BBA772E24783D26007F96A9 /* Model Controllers */, 4613E91D21143BFD00E7FF73 /* Info.plist */, ); path = "Shopping List"; sourceTree = ""; }; + 4BBA772B24783CBB007F96A9 /* View Controllers */ = { + isa = PBXGroup; + children = ( + 4BBA772924783873007F96A9 /* GroceryItemDetailViewController.swift */, + 4BBA772524783803007F96A9 /* ShoppingListCollectionViewController.swift */, + ); + path = "View Controllers"; + sourceTree = ""; + }; + 4BBA772C24783CEA007F96A9 /* Views */ = { + isa = PBXGroup; + children = ( + 4BBA772724783845007F96A9 /* GroceryItemCollectionViewCell.swift */, + ); + path = Views; + sourceTree = ""; + }; + 4BBA772D24783D1D007F96A9 /* Models */ = { + isa = PBXGroup; + children = ( + 4BBA772124782E7E007F96A9 /* ShoppingItem.swift */, + ); + path = Models; + sourceTree = ""; + }; + 4BBA772E24783D26007F96A9 /* Model Controllers */ = { + isa = PBXGroup; + children = ( + 4BBA772324783313007F96A9 /* ShoppingListController.swift */, + ); + path = "Model Controllers"; + sourceTree = ""; + }; + 4BBA772F24783D55007F96A9 /* Stroyboards */ = { + isa = PBXGroup; + children = ( + 4613E91521143BFC00E7FF73 /* Main.storyboard */, + 4613E91A21143BFD00E7FF73 /* LaunchScreen.storyboard */, + ); + path = Stroyboards; + sourceTree = ""; + }; + 4BBA773024783D5F007F96A9 /* Resources */ = { + isa = PBXGroup; + children = ( + 4613E91121143BFC00E7FF73 /* AppDelegate.swift */, + 4613E91821143BFD00E7FF73 /* Assets.xcassets */, + ); + path = Resources; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -135,7 +195,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4613E91421143BFC00E7FF73 /* ViewController.swift in Sources */, + 4BBA772624783803007F96A9 /* ShoppingListCollectionViewController.swift in Sources */, + 4BBA772224782E7E007F96A9 /* ShoppingItem.swift in Sources */, + 4BBA772A24783873007F96A9 /* GroceryItemDetailViewController.swift in Sources */, + 4BBA772424783313007F96A9 /* ShoppingListController.swift in Sources */, + 4BBA772824783845007F96A9 /* GroceryItemCollectionViewCell.swift in Sources */, 4613E91221143BFC00E7FF73 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Shopping List/Base.lproj/Main.storyboard b/Shopping List/Base.lproj/Main.storyboard deleted file mode 100644 index 03c13c22..00000000 --- a/Shopping List/Base.lproj/Main.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Shopping List/Model Controllers/ShoppingListController.swift b/Shopping List/Model Controllers/ShoppingListController.swift new file mode 100644 index 00000000..5776d7b0 --- /dev/null +++ b/Shopping List/Model Controllers/ShoppingListController.swift @@ -0,0 +1,26 @@ +// +// ShoppingListController.swift +// Shopping List +// +// Created by Ian Becker on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +class ShoppingListController { + + var groceryItems: [ShoppingItem] { + + let itemNames = [ShoppingItem(groceryItem: "Apple"), + ShoppingItem(groceryItem: "Grapes"), + ShoppingItem(groceryItem: "Milk"), + ShoppingItem(groceryItem: "Muffin"), + ShoppingItem(groceryItem: "Popcorn"), + ShoppingItem(groceryItem: "Soda"), + ShoppingItem(groceryItem:"Strawberries")] + + return itemNames + + } +} diff --git a/Shopping List/Models/ShoppingItem.swift b/Shopping List/Models/ShoppingItem.swift new file mode 100644 index 00000000..56bd4318 --- /dev/null +++ b/Shopping List/Models/ShoppingItem.swift @@ -0,0 +1,18 @@ +// +// ShoppingItem.swift +// Shopping List +// +// Created by Ian Becker on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +struct ShoppingItem { + var groceryItem: String + var hasBeenAdded: Bool = false + + var image: UIImage { + return UIImage(named: groceryItem)! + } +} diff --git a/Shopping List/AppDelegate.swift b/Shopping List/Resources/AppDelegate.swift similarity index 100% rename from Shopping List/AppDelegate.swift rename to Shopping List/Resources/AppDelegate.swift diff --git a/Shopping List/Assets.xcassets/AppIcon.appiconset/Contents.json b/Shopping List/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Shopping List/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Shopping List/Assets.xcassets/Apple.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Apple.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Apple.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Apple.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Apple.imageset/apple.png b/Shopping List/Resources/Assets.xcassets/Apple.imageset/apple.png similarity index 100% rename from Shopping List/Assets.xcassets/Apple.imageset/apple.png rename to Shopping List/Resources/Assets.xcassets/Apple.imageset/apple.png diff --git a/Shopping List/Assets.xcassets/Contents.json b/Shopping List/Resources/Assets.xcassets/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Contents.json rename to Shopping List/Resources/Assets.xcassets/Contents.json diff --git a/Shopping List/Assets.xcassets/Grapes.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Grapes.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Grapes.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Grapes.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Grapes.imageset/grapes.png b/Shopping List/Resources/Assets.xcassets/Grapes.imageset/grapes.png similarity index 100% rename from Shopping List/Assets.xcassets/Grapes.imageset/grapes.png rename to Shopping List/Resources/Assets.xcassets/Grapes.imageset/grapes.png diff --git a/Shopping List/Assets.xcassets/Milk.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Milk.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Milk.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Milk.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Milk.imageset/milk.png b/Shopping List/Resources/Assets.xcassets/Milk.imageset/milk.png similarity index 100% rename from Shopping List/Assets.xcassets/Milk.imageset/milk.png rename to Shopping List/Resources/Assets.xcassets/Milk.imageset/milk.png diff --git a/Shopping List/Assets.xcassets/Muffin.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Muffin.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Muffin.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Muffin.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Muffin.imageset/muffin.png b/Shopping List/Resources/Assets.xcassets/Muffin.imageset/muffin.png similarity index 100% rename from Shopping List/Assets.xcassets/Muffin.imageset/muffin.png rename to Shopping List/Resources/Assets.xcassets/Muffin.imageset/muffin.png diff --git a/Shopping List/Assets.xcassets/Popcorn.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Popcorn.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Popcorn.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Popcorn.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Popcorn.imageset/popcorn.png b/Shopping List/Resources/Assets.xcassets/Popcorn.imageset/popcorn.png similarity index 100% rename from Shopping List/Assets.xcassets/Popcorn.imageset/popcorn.png rename to Shopping List/Resources/Assets.xcassets/Popcorn.imageset/popcorn.png diff --git a/Shopping List/Assets.xcassets/Soda.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Soda.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Soda.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Soda.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Soda.imageset/soda.png b/Shopping List/Resources/Assets.xcassets/Soda.imageset/soda.png similarity index 100% rename from Shopping List/Assets.xcassets/Soda.imageset/soda.png rename to Shopping List/Resources/Assets.xcassets/Soda.imageset/soda.png diff --git a/Shopping List/Assets.xcassets/Strawberries.imageset/Contents.json b/Shopping List/Resources/Assets.xcassets/Strawberries.imageset/Contents.json similarity index 100% rename from Shopping List/Assets.xcassets/Strawberries.imageset/Contents.json rename to Shopping List/Resources/Assets.xcassets/Strawberries.imageset/Contents.json diff --git a/Shopping List/Assets.xcassets/Strawberries.imageset/strawberries.png b/Shopping List/Resources/Assets.xcassets/Strawberries.imageset/strawberries.png similarity index 100% rename from Shopping List/Assets.xcassets/Strawberries.imageset/strawberries.png rename to Shopping List/Resources/Assets.xcassets/Strawberries.imageset/strawberries.png diff --git a/Shopping List/Base.lproj/LaunchScreen.storyboard b/Shopping List/Stroyboards/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Shopping List/Base.lproj/LaunchScreen.storyboard rename to Shopping List/Stroyboards/Base.lproj/LaunchScreen.storyboard diff --git a/Shopping List/Stroyboards/Base.lproj/Main.storyboard b/Shopping List/Stroyboards/Base.lproj/Main.storyboard new file mode 100644 index 00000000..0187e883 --- /dev/null +++ b/Shopping List/Stroyboards/Base.lproj/Main.storyboard @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Shopping List/View Controllers/GroceryItemDetailViewController.swift b/Shopping List/View Controllers/GroceryItemDetailViewController.swift new file mode 100644 index 00000000..ab6545ea --- /dev/null +++ b/Shopping List/View Controllers/GroceryItemDetailViewController.swift @@ -0,0 +1,34 @@ +// +// GroceryItemDetailViewController.swift +// Shopping List +// +// Created by Ian Becker on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +protocol GroceryItemDelegate { + <#requirements#> +} + +class GroceryItemDetailViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + + /* + // 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/Shopping List/View Controllers/ShoppingListCollectionViewController.swift b/Shopping List/View Controllers/ShoppingListCollectionViewController.swift new file mode 100644 index 00000000..6752876b --- /dev/null +++ b/Shopping List/View Controllers/ShoppingListCollectionViewController.swift @@ -0,0 +1,51 @@ +// +// ShoppingListCollectionViewController.swift +// Shopping List +// +// Created by Ian Becker on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +class ShoppingListCollectionViewController: UICollectionViewController { + + let shoppingListController = ShoppingListController() + + override func viewDidLoad() { + super.viewDidLoad() + } + + + // MARK: - Navigation + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + segue.identifier == "showDetailView" { + guard let groceryItemVC == segue.destination as? GroceryItemDetailViewController else { return } + + groceryItemVC.delegate = self + } + } + + // MARK: UICollectionViewDataSource + + override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + + return shoppingListController.groceryItems.count + } + + override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "GroceryItemCell", for: indexPath) as? GroceryItemCollectionViewCell else { fatalError("Collection view cell identifier is wrong or the cell is not a PlanetCollectionViewCell")} + + // Configure the cell + + let groceryItem = shoppingListController.groceryItems[indexPath.item] + + cell. + + return cell + } +} + // MARK: UICollectionViewDelegate + +extension ShoppingListCollectionViewController: diff --git a/Shopping List/ViewController.swift b/Shopping List/ViewController.swift deleted file mode 100644 index eecb48b5..00000000 --- a/Shopping List/ViewController.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ViewController.swift -// Shopping List -// -// Created by Spencer Curtis on 8/3/18. -// Copyright © 2018 Lambda School. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} - diff --git a/Shopping List/Views/GroceryItemCollectionViewCell.swift b/Shopping List/Views/GroceryItemCollectionViewCell.swift new file mode 100644 index 00000000..3d900512 --- /dev/null +++ b/Shopping List/Views/GroceryItemCollectionViewCell.swift @@ -0,0 +1,13 @@ +// +// GroceryItemCollectionViewCell.swift +// Shopping List +// +// Created by Ian Becker on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +class GroceryItemCollectionViewCell: UICollectionViewCell { + +}