diff --git a/Shopping List.xcodeproj/project.pbxproj b/Shopping List.xcodeproj/project.pbxproj index 9970ba97..fa73b7bd 100644 --- a/Shopping List.xcodeproj/project.pbxproj +++ b/Shopping List.xcodeproj/project.pbxproj @@ -7,20 +7,28 @@ objects = { /* Begin PBXBuildFile section */ + 389B958C247833D900C97B5D /* ShoppingListCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 389B958B247833D900C97B5D /* ShoppingListCollectionViewController.swift */; }; + 389B958E2478356E00C97B5D /* PlaceOrderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 389B958D2478356E00C97B5D /* PlaceOrderViewController.swift */; }; + 389B95902478362E00C97B5D /* ShoppingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 389B958F2478362E00C97B5D /* ShoppingItem.swift */; }; + 389B95922478374100C97B5D /* ShoppingItemsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 389B95912478374100C97B5D /* ShoppingItemsController.swift */; }; + 389B959624783D2900C97B5D /* ShoppingListCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 389B959524783D2900C97B5D /* ShoppingListCollectionViewCell.swift */; }; 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 */; }; + 4613E91721143BFC00E7FF73 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91521143BFC00E7FF73 /* LaunchScreen.storyboard */; }; 4613E91921143BFD00E7FF73 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91821143BFD00E7FF73 /* Assets.xcassets */; }; - 4613E91C21143BFD00E7FF73 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91A21143BFD00E7FF73 /* LaunchScreen.storyboard */; }; + 4613E91C21143BFD00E7FF73 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4613E91A21143BFD00E7FF73 /* Main.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 389B958B247833D900C97B5D /* ShoppingListCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingListCollectionViewController.swift; sourceTree = ""; }; + 389B958D2478356E00C97B5D /* PlaceOrderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceOrderViewController.swift; sourceTree = ""; }; + 389B958F2478362E00C97B5D /* ShoppingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingItem.swift; sourceTree = ""; }; + 389B95912478374100C97B5D /* ShoppingItemsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingItemsController.swift; sourceTree = ""; }; + 389B959524783D2900C97B5D /* ShoppingListCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingListCollectionViewCell.swift; sourceTree = ""; }; 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 = ""; }; + 4613E91621143BFC00E7FF73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.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 = ""; }; + 4613E91B21143BFD00E7FF73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 4613E91D21143BFD00E7FF73 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ @@ -35,6 +43,43 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 389B9587247822FD00C97B5D /* Resources */ = { + isa = PBXGroup; + children = ( + 4613E91121143BFC00E7FF73 /* AppDelegate.swift */, + 4613E91821143BFD00E7FF73 /* Assets.xcassets */, + ); + path = Resources; + sourceTree = ""; + }; + 389B95882478231A00C97B5D /* View */ = { + isa = PBXGroup; + children = ( + 4613E91521143BFC00E7FF73 /* LaunchScreen.storyboard */, + 4613E91A21143BFD00E7FF73 /* Main.storyboard */, + ); + path = View; + sourceTree = ""; + }; + 389B95892478232A00C97B5D /* Controller */ = { + isa = PBXGroup; + children = ( + 389B958B247833D900C97B5D /* ShoppingListCollectionViewController.swift */, + 389B958D2478356E00C97B5D /* PlaceOrderViewController.swift */, + ); + path = Controller; + sourceTree = ""; + }; + 389B958A2478233500C97B5D /* Model */ = { + isa = PBXGroup; + children = ( + 389B959524783D2900C97B5D /* ShoppingListCollectionViewCell.swift */, + 389B958F2478362E00C97B5D /* ShoppingItem.swift */, + 389B95912478374100C97B5D /* ShoppingItemsController.swift */, + ); + path = Model; + sourceTree = ""; + }; 4613E90521143BFC00E7FF73 = { isa = PBXGroup; children = ( @@ -54,11 +99,10 @@ 4613E91021143BFC00E7FF73 /* Shopping List */ = { isa = PBXGroup; children = ( - 4613E91121143BFC00E7FF73 /* AppDelegate.swift */, - 4613E91321143BFC00E7FF73 /* ViewController.swift */, - 4613E91521143BFC00E7FF73 /* Main.storyboard */, - 4613E91821143BFD00E7FF73 /* Assets.xcassets */, - 4613E91A21143BFD00E7FF73 /* LaunchScreen.storyboard */, + 389B958A2478233500C97B5D /* Model */, + 389B95892478232A00C97B5D /* Controller */, + 389B95882478231A00C97B5D /* View */, + 389B9587247822FD00C97B5D /* Resources */, 4613E91D21143BFD00E7FF73 /* Info.plist */, ); path = "Shopping List"; @@ -122,9 +166,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4613E91C21143BFD00E7FF73 /* LaunchScreen.storyboard in Resources */, + 4613E91C21143BFD00E7FF73 /* Main.storyboard in Resources */, 4613E91921143BFD00E7FF73 /* Assets.xcassets in Resources */, - 4613E91721143BFC00E7FF73 /* Main.storyboard in Resources */, + 4613E91721143BFC00E7FF73 /* LaunchScreen.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -135,28 +179,32 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4613E91421143BFC00E7FF73 /* ViewController.swift in Sources */, + 389B95902478362E00C97B5D /* ShoppingItem.swift in Sources */, + 389B958C247833D900C97B5D /* ShoppingListCollectionViewController.swift in Sources */, 4613E91221143BFC00E7FF73 /* AppDelegate.swift in Sources */, + 389B95922478374100C97B5D /* ShoppingItemsController.swift in Sources */, + 389B959624783D2900C97B5D /* ShoppingListCollectionViewCell.swift in Sources */, + 389B958E2478356E00C97B5D /* PlaceOrderViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 4613E91521143BFC00E7FF73 /* Main.storyboard */ = { + 4613E91521143BFC00E7FF73 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( 4613E91621143BFC00E7FF73 /* Base */, ); - name = Main.storyboard; + name = LaunchScreen.storyboard; sourceTree = ""; }; - 4613E91A21143BFD00E7FF73 /* LaunchScreen.storyboard */ = { + 4613E91A21143BFD00E7FF73 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 4613E91B21143BFD00E7FF73 /* Base */, ); - name = LaunchScreen.storyboard; + name = Main.storyboard; sourceTree = ""; }; /* End PBXVariantGroup section */ diff --git a/Shopping List/Base.lproj/LaunchScreen.storyboard b/Shopping List/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index f83f6fd5..00000000 --- a/Shopping List/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Shopping List/Controller/PlaceOrderViewController.swift b/Shopping List/Controller/PlaceOrderViewController.swift new file mode 100644 index 00000000..86dae613 --- /dev/null +++ b/Shopping List/Controller/PlaceOrderViewController.swift @@ -0,0 +1,31 @@ +// +// PlaceOrderViewController.swift +// Shopping List +// +// Created by Jason Hoover on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +class PlaceOrderViewController: 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/Controller/ShoppingListCollectionViewController.swift b/Shopping List/Controller/ShoppingListCollectionViewController.swift new file mode 100644 index 00000000..973d68f6 --- /dev/null +++ b/Shopping List/Controller/ShoppingListCollectionViewController.swift @@ -0,0 +1,80 @@ +// +// ShoppingListCollectionViewController.swift +// Shopping List +// +// Created by Jason Hoover on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +class ShoppingListCollectionViewController: UICollectionViewController { + + let shoppingItemsController = ShoppingItemController() + + override func viewDidLoad() { + super.viewDidLoad() + + } + + + // MARK: - Navigation + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "toOrderScreen" { + guard let placeOrderVC = segue.destination as? PlaceOrderViewController else { + return + } + + + + } + } + + + // MARK: UICollectionViewDataSource + + override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + // #warning Incomplete implementation, return the number of items + return shoppingItemsController.itemsAvailable.count + } + + override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ShoppingItems", for: indexPath) as? ShoppingListCollectionViewCell else { fatalError("Collection view cell identifier is wrong or the cell is not a ShoppingListCollectionViewCell")} + + + return cell + } + + // MARK: UICollectionViewDelegate + + /* + // Uncomment this method to specify if the specified item should be highlighted during tracking + override func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool { + return true + } + */ + + /* + // Uncomment this method to specify if the specified item should be selected + override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + return true + } + */ + + /* + // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item + override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool { + return false + } + + override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool { + return false + } + + override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) { + + } + */ + +} diff --git a/Shopping List/Model/ShoppingItem.swift b/Shopping List/Model/ShoppingItem.swift new file mode 100644 index 00000000..82cee8a5 --- /dev/null +++ b/Shopping List/Model/ShoppingItem.swift @@ -0,0 +1,22 @@ +// +// ShoppingItem.swift +// Shopping List +// +// Created by Jason Hoover on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +struct ShoppingItem { + + var name: String + var image: UIImage + var inCart: Bool + + init(name: String, imageName: String) { + self.name = name + self.image = UIImage(named: imageName)! + self.inCart = false + } +} diff --git a/Shopping List/Model/ShoppingItemsController.swift b/Shopping List/Model/ShoppingItemsController.swift new file mode 100644 index 00000000..4db0996c --- /dev/null +++ b/Shopping List/Model/ShoppingItemsController.swift @@ -0,0 +1,27 @@ +// +// ShoppingItemsController.swift +// Shopping List +// +// Created by Jason Hoover on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import Foundation + +class ShoppingItemController { + + var itemsAvailable: [ShoppingItem] { + + let items = [ + ShoppingItem(name: "Apple", imageName: "Apple"), + ShoppingItem(name: "Grapes", imageName: "Grapes"), + ShoppingItem(name: "Milk", imageName: "Milk"), + ShoppingItem(name: "Muffins", imageName: "Muffins"), + ShoppingItem(name: "Popcorn", imageName: "Popcorn"), + ShoppingItem(name: "Soda", imageName: "Soda"), + ShoppingItem(name: "Strawberry", imageName: "Strawberry") + ] + + return items + } +} diff --git a/Shopping List/Model/ShoppingListCollectionViewCell.swift b/Shopping List/Model/ShoppingListCollectionViewCell.swift new file mode 100644 index 00000000..2529afce --- /dev/null +++ b/Shopping List/Model/ShoppingListCollectionViewCell.swift @@ -0,0 +1,17 @@ +// +// ShoppingListCollectionViewCell.swift +// Shopping List +// +// Created by Jason Hoover on 5/22/20. +// Copyright © 2020 Lambda School. All rights reserved. +// + +import UIKit + +class ShoppingListCollectionViewCell: UICollectionViewCell { + + @IBOutlet weak var addedTOCartLabel: UILabel! + @IBOutlet weak var imageView: UIImageView! + @IBOutlet weak var nameLabel: UILabel! + +} 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/Main.storyboard b/Shopping List/View/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Shopping List/Base.lproj/Main.storyboard rename to Shopping List/View/Base.lproj/LaunchScreen.storyboard diff --git a/Shopping List/View/Base.lproj/Main.storyboard b/Shopping List/View/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f0963b76 --- /dev/null +++ b/Shopping List/View/Base.lproj/Main.storyboard @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. - } - - -} -