diff --git a/iOS_Study_A.xcodeproj/project.pbxproj b/iOS_Study_A.xcodeproj/project.pbxproj index 1f5c336..c48116c 100644 --- a/iOS_Study_A.xcodeproj/project.pbxproj +++ b/iOS_Study_A.xcodeproj/project.pbxproj @@ -13,6 +13,13 @@ 954B6B682AC57BE100FDCFAB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B662AC57BE100FDCFAB /* Main.storyboard */; }; 954B6B6A2AC57BE200FDCFAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B692AC57BE200FDCFAB /* Assets.xcassets */; }; 954B6B6D2AC57BE200FDCFAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B6B2AC57BE200FDCFAB /* LaunchScreen.storyboard */; }; + DFA4DC122AD684C8005B5834 /* orderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFA4DC102AD684C8005B5834 /* orderTableViewCell.swift */; }; + DFA4DC132AD684C8005B5834 /* orderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFA4DC112AD684C8005B5834 /* orderTableViewCell.xib */; }; + DFA4DC172AD6AAEC005B5834 /* InfoTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFA4DC152AD6AAEC005B5834 /* InfoTableViewCell.swift */; }; + DFA4DC182AD6AAEC005B5834 /* InfoTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFA4DC162AD6AAEC005B5834 /* InfoTableViewCell.xib */; }; + DFA4DC1B2AD6BE16005B5834 /* SizeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFA4DC192AD6BE16005B5834 /* SizeTableViewCell.swift */; }; + DFA4DC1C2AD6BE16005B5834 /* SizeTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFA4DC1A2AD6BE16005B5834 /* SizeTableViewCell.xib */; }; + DFA4DC2E2AD6DE47005B5834 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFA4DC2D2AD6DE47005B5834 /* SecondViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -24,6 +31,13 @@ 954B6B692AC57BE200FDCFAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 954B6B6C2AC57BE200FDCFAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 954B6B6E2AC57BE200FDCFAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DFA4DC102AD684C8005B5834 /* orderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = orderTableViewCell.swift; sourceTree = ""; }; + DFA4DC112AD684C8005B5834 /* orderTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = orderTableViewCell.xib; sourceTree = ""; }; + DFA4DC152AD6AAEC005B5834 /* InfoTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoTableViewCell.swift; sourceTree = ""; }; + DFA4DC162AD6AAEC005B5834 /* InfoTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InfoTableViewCell.xib; sourceTree = ""; }; + DFA4DC192AD6BE16005B5834 /* SizeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeTableViewCell.swift; sourceTree = ""; }; + DFA4DC1A2AD6BE16005B5834 /* SizeTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SizeTableViewCell.xib; sourceTree = ""; }; + DFA4DC2D2AD6DE47005B5834 /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -56,9 +70,11 @@ 954B6B5F2AC57BE100FDCFAB /* iOS_Study_A */ = { isa = PBXGroup; children = ( + DFA4DC142AD6AABC005B5834 /* cell */, 954B6B602AC57BE100FDCFAB /* AppDelegate.swift */, 954B6B622AC57BE100FDCFAB /* SceneDelegate.swift */, 954B6B642AC57BE100FDCFAB /* ViewController.swift */, + DFA4DC2D2AD6DE47005B5834 /* SecondViewController.swift */, 954B6B662AC57BE100FDCFAB /* Main.storyboard */, 954B6B692AC57BE200FDCFAB /* Assets.xcassets */, 954B6B6B2AC57BE200FDCFAB /* LaunchScreen.storyboard */, @@ -67,6 +83,19 @@ path = iOS_Study_A; sourceTree = ""; }; + DFA4DC142AD6AABC005B5834 /* cell */ = { + isa = PBXGroup; + children = ( + DFA4DC102AD684C8005B5834 /* orderTableViewCell.swift */, + DFA4DC112AD684C8005B5834 /* orderTableViewCell.xib */, + DFA4DC152AD6AAEC005B5834 /* InfoTableViewCell.swift */, + DFA4DC162AD6AAEC005B5834 /* InfoTableViewCell.xib */, + DFA4DC192AD6BE16005B5834 /* SizeTableViewCell.swift */, + DFA4DC1A2AD6BE16005B5834 /* SizeTableViewCell.xib */, + ); + path = cell; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -125,8 +154,11 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + DFA4DC1C2AD6BE16005B5834 /* SizeTableViewCell.xib in Resources */, + DFA4DC182AD6AAEC005B5834 /* InfoTableViewCell.xib in Resources */, 954B6B6D2AC57BE200FDCFAB /* LaunchScreen.storyboard in Resources */, 954B6B6A2AC57BE200FDCFAB /* Assets.xcassets in Resources */, + DFA4DC132AD684C8005B5834 /* orderTableViewCell.xib in Resources */, 954B6B682AC57BE100FDCFAB /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -139,7 +171,11 @@ buildActionMask = 2147483647; files = ( 954B6B652AC57BE100FDCFAB /* ViewController.swift in Sources */, + DFA4DC172AD6AAEC005B5834 /* InfoTableViewCell.swift in Sources */, + DFA4DC1B2AD6BE16005B5834 /* SizeTableViewCell.swift in Sources */, 954B6B612AC57BE100FDCFAB /* AppDelegate.swift in Sources */, + DFA4DC2E2AD6DE47005B5834 /* SecondViewController.swift in Sources */, + DFA4DC122AD684C8005B5834 /* orderTableViewCell.swift in Sources */, 954B6B632AC57BE100FDCFAB /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/iOS_Study_A/Assets.xcassets/hot.imageset/Contents.json b/iOS_Study_A/Assets.xcassets/hot.imageset/Contents.json new file mode 100644 index 0000000..89adeab --- /dev/null +++ b/iOS_Study_A/Assets.xcassets/hot.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "스크린샷 2023-10-11 오후 7.34.24.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git "a/iOS_Study_A/Assets.xcassets/hot.imageset/\354\212\244\355\201\254\353\246\260\354\203\267 2023-10-11 \354\230\244\355\233\204 7.34.24.png" "b/iOS_Study_A/Assets.xcassets/hot.imageset/\354\212\244\355\201\254\353\246\260\354\203\267 2023-10-11 \354\230\244\355\233\204 7.34.24.png" new file mode 100644 index 0000000..33c0946 Binary files /dev/null and "b/iOS_Study_A/Assets.xcassets/hot.imageset/\354\212\244\355\201\254\353\246\260\354\203\267 2023-10-11 \354\230\244\355\233\204 7.34.24.png" differ diff --git a/iOS_Study_A/Assets.xcassets/pizza.imageset/Contents.json b/iOS_Study_A/Assets.xcassets/pizza.imageset/Contents.json new file mode 100644 index 0000000..a2598c7 --- /dev/null +++ b/iOS_Study_A/Assets.xcassets/pizza.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "스크린샷 2023-10-11 오후 2.44.12.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git "a/iOS_Study_A/Assets.xcassets/pizza.imageset/\354\212\244\355\201\254\353\246\260\354\203\267 2023-10-11 \354\230\244\355\233\204 2.44.12.png" "b/iOS_Study_A/Assets.xcassets/pizza.imageset/\354\212\244\355\201\254\353\246\260\354\203\267 2023-10-11 \354\230\244\355\233\204 2.44.12.png" new file mode 100644 index 0000000..f6b5759 Binary files /dev/null and "b/iOS_Study_A/Assets.xcassets/pizza.imageset/\354\212\244\355\201\254\353\246\260\354\203\267 2023-10-11 \354\230\244\355\233\204 2.44.12.png" differ diff --git a/iOS_Study_A/Base.lproj/Main.storyboard b/iOS_Study_A/Base.lproj/Main.storyboard index 25a7638..b2b9c22 100644 --- a/iOS_Study_A/Base.lproj/Main.storyboard +++ b/iOS_Study_A/Base.lproj/Main.storyboard @@ -1,24 +1,157 @@ - + + - + + - + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS_Study_A/SecondViewController.swift b/iOS_Study_A/SecondViewController.swift new file mode 100644 index 0000000..0c92de4 --- /dev/null +++ b/iOS_Study_A/SecondViewController.swift @@ -0,0 +1,26 @@ +// +// SecondViewController.swift +// iOS_Study_A +// +// Created by 박현수 on 2023/10/11. +// + +import UIKit + +class SecondViewController: UIViewController { + + var data : String = "" + + @IBOutlet weak var receivedDataLabel: UILabel! + + + @IBAction func goPreviousView(_ sender: Any) { + self.presentingViewController?.dismiss(animated: true) + } + + override func viewDidLoad() { + super.viewDidLoad() + receivedDataLabel.text = data + } + +} diff --git a/iOS_Study_A/ViewController.swift b/iOS_Study_A/ViewController.swift index 0804a27..9387813 100644 --- a/iOS_Study_A/ViewController.swift +++ b/iOS_Study_A/ViewController.swift @@ -8,12 +8,97 @@ import UIKit class ViewController: UIViewController { + + var data : String = "" + + @IBOutlet var orderView: UIView! + @IBOutlet weak var orderTableView: UITableView! + + @IBOutlet weak var minimumCostLabel: UILabel! + + @IBOutlet weak var howMuchMinimumCost: UILabel! + @IBOutlet weak var putShoppingCartButton: UIButton! + + @IBAction func toCartView(_ sender: Any) { + guard let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as? SecondViewController else { return } + guard let cell = orderTableView.cellForRow(at: IndexPath(row: 2, section: 0)) as? SizeTableViewCell else { return } + + if cell.mediumButton.isSelected { + data = "20000" + } + else { + data = "25000" + } + secondViewController.data = data + secondViewController.modalTransitionStyle = .coverVertical + secondViewController.modalPresentationStyle = .fullScreen + self.present(secondViewController, animated: true, completion: nil) + } + + + + override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + + orderTableView.allowsSelection = false + + orderTableView.dataSource = self + orderTableView.delegate = self + + let infoNib = UINib (nibName: "InfoTableViewCell", bundle: nil) + orderTableView.register(infoNib,forCellReuseIdentifier:"InfoTableViewCell") + + let orderNib = UINib (nibName: "orderTableViewCell", bundle: nil) + orderTableView.register(orderNib,forCellReuseIdentifier:"orderTableViewCell") + + let sizeNib = UINib (nibName: "SizeTableViewCell", bundle: nil) + orderTableView.register(sizeNib,forCellReuseIdentifier:"SizeTableViewCell") + orderTableView.separatorStyle = .singleLine + minimumCostLabel.textColor = .gray + minimumCostLabel.font = .systemFont(ofSize: 14) + howMuchMinimumCost.text = "20,000원" + putShoppingCartButton.layer.cornerRadius = 5 } - - } +extension ViewController: UITableViewDelegate, UITableViewDataSource { + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.row == 0 { + return 200 + } + else if indexPath.row == 1 { + return 150 + } + else { + return 170 + } + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + 3 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.row == 0 { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "orderTableViewCell", for: indexPath) as? orderTableViewCell else { + return UITableViewCell() + } + return cell + } + else if indexPath.row == 1 { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "InfoTableViewCell", for: indexPath) as? InfoTableViewCell else { + return UITableViewCell() + } + return cell + } + else { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "SizeTableViewCell", for: indexPath) as? SizeTableViewCell else { + return UITableViewCell() + } + return cell + } + } +} diff --git a/iOS_Study_A/cell/InfoTableViewCell.swift b/iOS_Study_A/cell/InfoTableViewCell.swift new file mode 100644 index 0000000..9da8f57 --- /dev/null +++ b/iOS_Study_A/cell/InfoTableViewCell.swift @@ -0,0 +1,34 @@ +// +// InfoTableViewCell.swift +// iOS_Study_A +// +// Created by 박현수 on 2023/10/11. +// + +import UIKit + +class InfoTableViewCell: UITableViewCell { + + @IBOutlet weak var hotImageView: UIImageView! + @IBOutlet weak var titleLabelView: UILabel! + @IBOutlet weak var contentsLabelView: UILabel! + @IBOutlet weak var nutritionLabelView: UILabel! + override func awakeFromNib() { + super.awakeFromNib() + titleLabelView.font = .boldSystemFont(ofSize: 20) + contentsLabelView.textColor = .gray + contentsLabelView.font = .systemFont(ofSize: 16) + contentsLabelView.numberOfLines = 0 + contentsLabelView.lineBreakMode = .byCharWrapping + nutritionLabelView.font = .systemFont(ofSize: 14) + nutritionLabelView.backgroundColor = .lightGray.withAlphaComponent(0.2) + nutritionLabelView.layer.cornerRadius = 20 + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/iOS_Study_A/cell/InfoTableViewCell.xib b/iOS_Study_A/cell/InfoTableViewCell.xib new file mode 100644 index 0000000..2493bc2 --- /dev/null +++ b/iOS_Study_A/cell/InfoTableViewCell.xib @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS_Study_A/cell/SizeTableViewCell.swift b/iOS_Study_A/cell/SizeTableViewCell.swift new file mode 100644 index 0000000..161aad0 --- /dev/null +++ b/iOS_Study_A/cell/SizeTableViewCell.swift @@ -0,0 +1,65 @@ +// +// SizeTableViewCell.swift +// iOS_Study_A +// +// Created by 박현수 on 2023/10/11. +// + +import UIKit + +class SizeTableViewCell: UITableViewCell { + + @IBOutlet weak var priceLabelView: UILabel! + @IBOutlet weak var necessaryLabelView: UILabel! + @IBOutlet weak var mediumButton: UIButton! + @IBOutlet weak var largeButton: UIButton! + + @IBOutlet weak var mediumLabel: UILabel! + + @IBOutlet weak var largeLabel: UILabel! + + @IBOutlet weak var mediumPriceLabel: UILabel! + + @IBOutlet weak var largePriceLabel: UILabel! + + + @IBAction func mediumSelected(_ sender: Any) { + mediumButton.isSelected = true + largeButton.isSelected = false + print("medium") + } + + @IBAction func largeSelected(_ sender: Any) { + largeButton.isSelected = true + mediumButton.isSelected = false + print("large") + } + + + override func awakeFromNib() { + super.awakeFromNib() + + priceLabelView.text = "가격" + priceLabelView.font = .boldSystemFont(ofSize: 20) + necessaryLabelView.text = "필수" + necessaryLabelView.textColor = .blue + necessaryLabelView.backgroundColor = .blue.withAlphaComponent(0.1) + mediumLabel.font = .systemFont(ofSize: 20) + largeLabel.font = .systemFont(ofSize: 20) + mediumButton.setImage(UIImage(systemName: "dot.circle"), for: .selected) + mediumButton.setImage(UIImage(systemName: "circle"), for: .normal) + largeButton.setImage(UIImage(systemName: "dot.circle"), for: .selected) + largeButton.setImage(UIImage(systemName: "circle"), for: .normal) + mediumPriceLabel.font = .systemFont(ofSize: 20) + largePriceLabel.font = .systemFont(ofSize: 20) + mediumPriceLabel.text = "20,000원" + largePriceLabel.text = "25,000원" + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/iOS_Study_A/cell/SizeTableViewCell.xib b/iOS_Study_A/cell/SizeTableViewCell.xib new file mode 100644 index 0000000..75eff43 --- /dev/null +++ b/iOS_Study_A/cell/SizeTableViewCell.xib @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS_Study_A/cell/orderTableViewCell.swift b/iOS_Study_A/cell/orderTableViewCell.swift new file mode 100644 index 0000000..db959ed --- /dev/null +++ b/iOS_Study_A/cell/orderTableViewCell.swift @@ -0,0 +1,23 @@ +// +// orderTableViewCell.swift +// iOS_Study_A +// +// Created by 박현수 on 2023/10/11. +// + +import UIKit + +class orderTableViewCell: UITableViewCell { + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/iOS_Study_A/cell/orderTableViewCell.xib b/iOS_Study_A/cell/orderTableViewCell.xib new file mode 100644 index 0000000..dc5798c --- /dev/null +++ b/iOS_Study_A/cell/orderTableViewCell.xib @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +