Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bd1ad6c
feat: UI 배치
dddowon Sep 22, 2022
82716e6
feat: 박람회 정보가 담긴 JSON파일을 디코딩하는 함수 구현, 함수 테스트를 위한 유닛테스트 구현
Schro2109 Sep 22, 2022
63cc308
STEP1 상태로 초기화
Schro2109 Sep 23, 2022
96417b0
feat: JSON Parsing 함수 추가, 파싱한 데이터가 nil 값인지 확인하는 함수 추가
dddowon Sep 26, 2022
189eee5
feat: Exposition 파싱에 대한 에러 핸들러 추가
Schro2109 Sep 27, 2022
098c024
feat: 만국박람회 뷰 구성 요소 추가
dddowon Sep 28, 2022
6d66b91
feat: expositionData를 이용한 ui 데이터 세팅 함수 구현
Schro2109 Sep 29, 2022
23fb45d
feat: 테이블 뷰 레이아웃 생성
dddowon Sep 29, 2022
81c8635
feat: CellController 추가
dddowon Sep 30, 2022
5ac2e7b
feat: Cell에 UI 연결
dddowon Sep 30, 2022
74f8786
feat: Parsing 해주는 모델 JSONPaser 구현, ItemQueue 구현
dddowon Oct 4, 2022
18c5de7
feat: ItemQueue 삭제, 테이블뷰 셀 구현 과정을 추가했으나 오류 발생
Schro2109 Oct 4, 2022
4b2be29
fix: 셀 구현중 발생한 오류 해결 - identifier 문제
dddowon Oct 4, 2022
cc6d640
feat: 셀 구현 과정에서 ui데이터를 설정하는 과정 함수로 구현, item 상세 정보 뷰를 위한 뷰컨트롤러 생성
Schro2109 Oct 5, 2022
5be5bf9
feat: 세번째 뷰 컨트롤러 ui 및 ItemInfoViewController 뷰컨 기능 구현
dddowon Oct 5, 2022
575d971
feat: UI 변수 네이밍 변경과 메인 뒤로가기 버튼 텍스트 구현
Schro2109 Oct 5, 2022
bf9575e
Merge pull request #3 from dddowon/STEP2
Schro2109 Oct 5, 2022
ba6a92a
fix: 피드백 반영
dddowon Oct 7, 2022
5864854
Merge pull request #4 from dddowon/STEP2
dddowon Oct 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 180 additions & 13 deletions Expo1900/Expo1900.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file modified Expo1900/Expo1900/.DS_Store
Binary file not shown.
27 changes: 27 additions & 0 deletions Expo1900/Expo1900/Controller/Cell/ItemTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// ItemTableViewCell.swift
// Expo1900
//
// Created by 박도원 on 2022/09/30.
//

import UIKit

class ItemTableViewCell: UITableViewCell {

@IBOutlet weak var itemImageView: UIImageView!
@IBOutlet weak var itemNameLabel: UILabel!
@IBOutlet weak var shortDescriptionLabel: UILabel!
var itemInfo: Item?

func setCellData(itemInfo: Item) {
self.itemInfo = itemInfo
if let item = self.itemInfo {
self.itemNameLabel.text = item.name
self.itemImageView.image = UIImage(named: item.image)
self.shortDescriptionLabel.text = item.shortDescription
}
}
}


55 changes: 55 additions & 0 deletions Expo1900/Expo1900/Controller/ExpositionViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Expo1900 - ViewController.swift
// Created by yagom.
// Copyright © yagom academy. All rights reserved.
//

import UIKit

class ExpositionViewController: UIViewController {
@IBOutlet private weak var titleLabel: UILabel!
@IBOutlet private weak var visitorsLabel: UILabel!
@IBOutlet private weak var locationLabel: UILabel!
@IBOutlet private weak var durationLabel: UILabel!
@IBOutlet private weak var descriptionLabel: UILabel!


override func viewDidLoad() {
super.viewDidLoad()

try? setView(from: getExpositionData())
}

private func getExpositionData() throws -> Exposition {
guard let expositionData = try? JSONParser().getExpositionData() else {
throw MyError.expositionParsingError
}

return expositionData
}

private func setView(from data: Exposition) {
let title = data.title
let visitors: String = "방문객 : "
let location: String = "개최지 : "
let duration: String = "개최 기간 : "
let description = data.description

titleLabel.text = title
visitorsLabel.text = try? visitors + numberFormatToDecimal(of: data.visitors)
locationLabel.text = location + data.location
durationLabel.text = duration + data.duration
descriptionLabel.text = description
}

private func numberFormatToDecimal(of number: Int?) throws -> String {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal

guard let newNumber = number, let result = numberFormatter.string(from: NSNumber(value: newNumber)) else {
throw MyError.decimalConversionError
}

return result + "명"
}
}
28 changes: 28 additions & 0 deletions Expo1900/Expo1900/Controller/ItemInfoViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// ItemInfoViewController.swift
// Expo1900
//
// Created by 박도원 on 2022/10/05.
//

import UIKit

class ItemInfoViewController: UIViewController {
@IBOutlet private weak var itemImageView: UIImageView!
@IBOutlet private weak var itemDescriptionLabel: UILabel!
var itemInfo: Item?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어디는 아웃렛변수가 위에있고 여기는 아웃렛변수가 프로퍼티 아래에 있네요!!
항상 통일성을 지켜주세요!!
저같은 경우는 아웃렛 변수를 가장 상단에 두는 편입니다 ㅎㅎ

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아웃렛 변수 전부 상단으로 통일해보겠습니다!


override func viewDidLoad() {
super.viewDidLoad()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super와 함수호출 사이에 한번 개행해주면 좋습니다!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵!

setItemData()
}

func setItemData() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

외부에서 접근하지 않는다면 은닉화 해주세요!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard let data = itemInfo else {
return
}
itemImageView.image = UIImage(named: data.image)
itemDescriptionLabel.text = data.description
}

}
55 changes: 55 additions & 0 deletions Expo1900/Expo1900/Controller/ItemsTableViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// ItemsTableViewController.swift
// Expo1900
//
// Created by 박도원 on 2022/10/04.
//

import UIKit

class ItemsTableViewController: UIViewController {
@IBOutlet private weak var itemTableView: UITableView!
private var itemList: [Item] = []

override func viewDidLoad() {
super.viewDidLoad()

try? self.itemList = getItemList()
}

private func getItemList() throws -> [Item] {
guard let items: [Item] = try? JSONParser().getItemsData() else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생명주기 내부에 바로 작성하기보다는 이 기능을 하는 메서드를 만들어서
이곳에 호출하는 방식으로 구현해보세요!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw MyError.itemParsingError
}

return items
}
}

extension ItemsTableViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath) as? ItemTableViewCell
let itemInfoVC = "ItemInfoVC"
guard let itemInfoVC = self.storyboard?.instantiateViewController(withIdentifier: itemInfoVC) as? ItemInfoViewController else {
return
}
itemInfoVC.itemInfo = cell?.itemInfo
navigationController?.pushViewController(itemInfoVC, animated: true)
}
}

extension ItemsTableViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemList.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let itemCell = "ItemCell"
guard let cell = tableView.dequeueReusableCell(withIdentifier: itemCell, for: indexPath) as? ItemTableViewCell else {
return UITableViewCell()
}

cell.setCellData(itemInfo: itemList[indexPath.row])
return cell
}
}
29 changes: 29 additions & 0 deletions Expo1900/Expo1900/Controller/SecondViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// SecondViewController.swift
// Expo1900
//
// Created by 박도원 on 2022/09/29.
//

import UIKit

class SecondViewController: 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.
}
*/

}
18 changes: 0 additions & 18 deletions Expo1900/Expo1900/Controller/ViewController.swift

This file was deleted.

23 changes: 23 additions & 0 deletions Expo1900/Expo1900/Error/Error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ExpositionError.swift
// Expo1900
//
// Created by Schro on 2022/09/27.
//

import Foundation

enum MyError: Error, LocalizedError {
case expositionParsingError, itemParsingError, decimalConversionError

var errorDescription: String {
switch self {
case .expositionParsingError:
return "ExpositionParsing 실패"
case .itemParsingError:
return "ItemParsing 실패"
case .decimalConversionError:
return "소수 변환 실패"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

import Foundation

struct Expo: Decodable {
struct Exposition: Decodable {
let title: String
let visitors: Int
let locations: String
let location: String
let duration: String
let description: String

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Schro on 2022/09/20.
//

import UIKit
import Foundation

struct Relic: Decodable {
struct Item: Decodable {
let name: String
let image: String
let shortDescription: String
Expand Down
40 changes: 40 additions & 0 deletions Expo1900/Expo1900/Model/JSONParser.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// JSONParser.swift
// Expo1900
//
// Created by 박도원 on 2022/10/04.
//

import UIKit

class JSONParser {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VC에 직접적으로 파싱하지 않고 객체를 통해 파싱을 구현한 부분에 대해서 매우 칭찬합니다!! 👏
다만 파싱할 데이터가 열 개,백 개가 되버리면 그만큼의 메서드를 만들어줘야하는데
반복되는 코드들을 줄이기위해 프로토콜과 제네릭등을 활용해서도 구현해 볼 수 있을 거같습니다 ☺️

이번 스텝에서는 JSON 데이터를 화면에 잘 표시하는 것이 목적이기때문에 지금 방법도 너무 좋아요 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한번 제네릭으로 구현해보려고 시도했으나 아직 부족한 점이 있는 것 같습니다..
이부분에 대해서 공부해보겠습니다!

enum FileName: String {
case expositionFile = "exposition_universelle_1900"
case itemsFile = "items"
}

func getExpositionData() throws -> Exposition {
guard let expositionDataAsset = NSDataAsset(name: FileName.expositionFile.rawValue) else {
throw MyError.expositionParsingError
}
let expositionJsonDecoder = JSONDecoder()

guard let expositionData = try? expositionJsonDecoder.decode(Exposition.self, from: expositionDataAsset.data) else{
throw MyError.expositionParsingError
}
return expositionData
}

func getItemsData() throws -> [Item] {
guard let itemDataAsset = NSDataAsset(name: FileName.itemsFile.rawValue) else {
throw MyError.itemParsingError
}
let itemJsonDecoder = JSONDecoder()

guard let itemData = try? itemJsonDecoder.decode([Item].self, from: itemDataAsset.data) else {
throw MyError.itemParsingError
}

return itemData
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "bangjja~universal@1x.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "bangjja~universal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "bangjja~universal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "buddhism~universal@1x.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "buddhism~universal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "buddhism~universal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"data" : [
{
"filename" : "exposition_universelle_1900.json",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title":"파리 만국박람회 1900(L'Exposition de Paris 1900)",
"visitors":48130300,
"location":"프랑스 파리",
"duration":"1900. 04. 14 - 1900. 11. 12",
"description":"1900년 파리 만국박람회(지금의 세계 박람회[World’s Fair/Exposition/Expo])는 지난 세기를 기념하고 다음 세기를 향한 발전을 가속하자는 의미에서 1900년 4월 14일부터 11월 12일까지 프랑스 파리에서 열린 세계 박람회였다. 이 박람회에서 널리 선보였던 건축 양식이 바로 '아르누보'였다. 총 관람객수가 5000만 명에 달한 1900년 세계 박람회에서는 수많은 기계와 발명품, 그리고 건축물들이 전시됐는데 그 중에는 그랑드 루 드 파리 대관람차, 마트료시카 인형, 디젤 엔진, 유성영화, 에스컬레이터, 텔레그라폰 (최초의 자석식 녹음기) 등 지금도 널리 알려져 있는 것들도 등장했다.\n\n프랑스는 1855년에도 만국 박람회를 개최한 전력이 있었는데 전쟁 후 국가의 자부심과 신념을 다시 세우고자 하는 욕구로부터 비롯된 것이었다. 1900년 박람회가 성공을 거둔 것도 전후 국가 부흥이라는 똑같은 주제에 따른 것이었다. 1900년 파리 세계 박람회가 개최되기 8년 전인 1892년, 프랑스 정부는 새 세기의 도래를 환영하고 축하하는 박람회를 열 것이라고 발표했다.\n\n프랑스는 전세계 56개국에 초청장을 보냈고, 그 중 40개국이 수락하여 참가했다.참가국들이 이룬 것과 생활양식을 전시했다. 이 세계 박람회는 여러 가지 체험을 종합하여 익히도록 한 것이었다. 이를 통해 외국인들에게 각 국가들 간의 유사성은 물론 그 사이의 독특한 다양성을 깨닫도록 하는 기회를 제공했다. 또 새로운 문화를 경험하고 각국이 전시해 놓은 자국의 가치들을 전반적으로 더욱 이해할 수 있도록 했다. 이러한 상호 이해의 환경이 전쟁 시대 이후 필요하다고 여겨졌던 문화적 관용을 늘리는데 한몫하도록 했다. 박람회 개최 소식이 발표되자 독일에서 처음으로 열린 국제 박람회에 쏠렸던 관심은 풀리고 박람회 개최에 대한 호응이 어마어마하게 쏟아졌다. 박람회에 대한 지지도 대단해서 각국에서는 즉시 자국 전시관 계획을 세우기 시작했다. \n\n파리 만국박람회가 개최된 1900년 4월 14일부터 11월 12일까지 프랑스 파리에는 대한제국의 문화와 문물이 전시된 한국관이 세워졌습니다. 한국관은 경복궁의 근정전을 재현한 주전시관과 옛 국왕들의 위패를 모셔놓은 사당을 별채로 구성되었는데, 이는 우리 건축의 아름다움을 세계에 알린 첫 건축물이 되었습니다. 특히 만국박 람회의 대한제국관을 묘사한 프랑스 잡지 ‘르 프티 주르날(Le Petit Journal)’은 태극기를 표시해 당당하게 대한 제국의 상징으로 많은 관심을 받을 수 있었습니다.\n\n한국관의 전시품은 정확하게 어떤 것이 전시되었는지 알 수는 없지만 대한제국과 프랑스 정부간에 오고 간 문 서를 통해 짐작할 수 있습니다. 대한제국 정부는 우리의 다양한 전통문화를 나타내는 비단, 놋그릇, 도자기, 칠 보 등의 공예품을 제공한 것으로 보이며, 이 밖에도 악기, 옷, 가구, 예술품 등도 있었다고 합니다. 만국박람회는 참가한 나라들의 산업을 소개하는 역할을 했고, 전시는 물론 시상도 했는데 대한제국은 식물성 농업식품 분야 에서 그랑프리(대상)을 수상하였다고 합니다.\n\n1900년 11월 12일 파리 만국박람회가 폐막된 후 한국관에 출품되었던 전시품들은 다시 본국으로 돌아오지 못하고 대부분 현지에 기증되었는데, 이는 일종의 관례이기도 했지만 본국으로 회수하는데 드는 과도한 운송비용 때문이기도 했습니다.\n\n현재 이 전시품들은 프랑스에 있는 국립공예박물관, 국립예술직업전문학교, 국립음악원 음악박물관, 국립 기메 아시아박물관 등에 소장되어있습니다. 특히 전시품으로 기증된 악기들 중 해금은 현존하는 해금 가운데 가장 오래된 것으로 추정되고 있다고도 합니다. 우리의 소중한 역사적 유물을 멀리 두고 올 수 밖에 없던 상황이 안타깝게 느껴집니다.\n\n작고 힘없는 나라 대한제국이 세계 강국들이 모인 만국박람회에 참가한다는 자체가 불가능하다는 의견이 지배 적이었지만 1900년 프랑스 파리에 근정전을 본뜬 한국관이 우뚝 세워졌습니다. 그 존재만으로 독립된 나라임을 세계에 알리고자 했던 목표는 이루어진 것 같습니다. 그러나 안타깝게도 그로부터 5년 후인 1905년 을사늑약이 체결되었고, 대한제국은 독립국가로서 세계에서 점점 잊혀져 갔습니다."
}
12 changes: 12 additions & 0 deletions Expo1900/Expo1900/View/Assets.xcassets/flag.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "flag~universal.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Loading