Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

박스오피스 [Step3] 쥬봉이, 기석 #124

Open
wants to merge 88 commits into
base: ic_10_jyubong
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
a08cdb1
feat: collectionview 코드로 생성
jyubong Dec 5, 2023
6465bb1
feat: collectionView autolayout 설정
jyubong Dec 5, 2023
99f1779
feat: collectionview datasource 구현
jyubong Dec 5, 2023
09209c2
feat: codebase 세팅
carti1108 Dec 5, 2023
ba75de0
docs: MovieListCell 파일 생성
carti1108 Dec 5, 2023
5ab45ad
feat: available 추가
carti1108 Dec 5, 2023
a7f5b7a
feat: collectionView에 customCell 추가
carti1108 Dec 5, 2023
a5f8fea
style: 주석 제거
jyubong Dec 5, 2023
866569f
feat: MovieListCell 내 label, stackview 구현
jyubong Dec 5, 2023
ce2adc6
feat: MovieListCell label text 설정하는 메서드 구현
jyubong Dec 5, 2023
90c6c26
feat: MovieListCell accessary 설정
jyubong Dec 5, 2023
7114dbe
feat: autolayout 설정
carti1108 Dec 5, 2023
13d0dab
docs: target 버전 수정
jyubong Dec 5, 2023
0c19989
feat: 전일 날짜 반환하는 yesterday 프로퍼티 추가
jyubong Dec 5, 2023
b1479df
feat: network data를 담을 movie array 추가
jyubong Dec 5, 2023
6e02aa7
feat: network data decode 메서드 구현
jyubong Dec 5, 2023
95acea5
feat: viewcontroller에 network에서 데이터 가져오는 메서드 구현
jyubong Dec 5, 2023
ac0cc9d
docs: MovieConfiguration, MovieContentView 파일 생성
carti1108 Dec 7, 2023
8542191
feat: MovieConfiguration, MovieContentView class 생성
carti1108 Dec 7, 2023
bdb850c
refactor: MovieListCell 구현부 삭제
carti1108 Dec 7, 2023
8a4af0c
feat: MovieConfiguration 내부 구현
carti1108 Dec 7, 2023
77e1e5a
feat: configuration 변수 생성
carti1108 Dec 7, 2023
afb7870
feat: MovieContentView apply 메서드 추가
jyubong Dec 7, 2023
d0714bf
feat: MovieContentView configuration didtSet에 apply 메서드 실행 추가
jyubong Dec 7, 2023
fd6a01e
feat: label, stackView 생성
carti1108 Dec 7, 2023
3eaba16
feat: MovieContentView autolayout 설정
jyubong Dec 7, 2023
85b469c
style: 컨벤션 수정
jyubong Dec 7, 2023
e64b7c0
feat: apply 메서드 구현
jyubong Dec 7, 2023
dc446cf
feat: 메서드 호출 추가
jyubong Dec 7, 2023
b213956
feat: updateConfiguration 메서드 구현
carti1108 Dec 7, 2023
b51a2ce
refactor: collectionView autolayout 구현 위치 수정
carti1108 Dec 7, 2023
be5bf09
refactor: http -> https 로 수정
jyubong Dec 7, 2023
830637e
refactor: DailyBoxOffice struct Hashable 프로토콜 추가
jyubong Dec 7, 2023
b46ab9a
refactor: collectionview UI 수정
jyubong Dec 7, 2023
303d5d0
refactor: 접근 제어 추가
jyubong Dec 7, 2023
0fe264f
feat: section enum 구현
jyubong Dec 7, 2023
22dbf82
feat: datasource 프로퍼티 추가
jyubong Dec 7, 2023
3362e74
feat: diffabledatasource 구현 메서드 추가
jyubong Dec 7, 2023
845ada5
refactor: 불필요한 메서드 제거
jyubong Dec 7, 2023
b788b66
refactor: yesterday 연산프로퍼티를 메서드로 변경
jyubong Dec 7, 2023
ae270a0
feat: view background color, navigationbar title 변경
jyubong Dec 7, 2023
c0fb808
feat: 네임스페이스 생성
carti1108 Dec 7, 2023
75379fe
refactor: yesterday 메서드 적용부 수정
jyubong Dec 8, 2023
6c4a39d
refactor: contentview apply 타입캐스팅 수정, 초기화에 적용
jyubong Dec 8, 2023
772f571
refactor: datasource와 snapshot 호출 부분 수정
jyubong Dec 8, 2023
fb257e3
test: 테스트 코드 수정
carti1108 Dec 8, 2023
989275b
feat: Movie파일에 RankOldAndNew 타입 추가
carti1108 Dec 8, 2023
4196fa9
refactor: cell accessory 적용부 수정
jyubong Dec 8, 2023
4d1eb61
feat: viewController refrsher 적용
jyubong Dec 8, 2023
1bcfac9
refactor: 문자열 수정
carti1108 Dec 12, 2023
9414c03
refactor: 폰트 수정
carti1108 Dec 12, 2023
d225f80
refactor: 오토레이아웃 수정
carti1108 Dec 12, 2023
02c10ef
style: 개행 제거
carti1108 Dec 12, 2023
09e2471
docs: string, NSMutableAttributedString extension 파일 생성
carti1108 Dec 12, 2023
004a85c
feat: numberFormatter 메서드 구현
carti1108 Dec 12, 2023
2a873b6
feat: NSMutableAttributedString 구현
carti1108 Dec 12, 2023
087235c
refactor: rankFluctuationLabel폰트 body로 변경
carti1108 Dec 12, 2023
741ed2c
refactor: 문자열 수정
carti1108 Dec 12, 2023
5b4ffb6
feat: configuration.rankFluctuation 옵셔널 바인딩 추가
carti1108 Dec 12, 2023
0bcb2ea
feat: 조건 별 rankFluctuationLabel 내용 로직 추가
carti1108 Dec 12, 2023
9473ec6
feat: 오토레이아웃 수정
carti1108 Dec 12, 2023
967722d
feat: rankOldAndNew 변수 추가
carti1108 Dec 12, 2023
ffd7987
refactor: 메서드 구현부 수정
carti1108 Dec 12, 2023
cc46faa
feat: 오토레이아웃 수정
carti1108 Dec 12, 2023
0f082ed
style: 개행 추가
carti1108 Dec 12, 2023
31e3033
feat: bodyFont 프로퍼티 제거
carti1108 Dec 12, 2023
5cf398c
refactor: 메서드 구현부 수정
carti1108 Dec 12, 2023
34c63a7
refactor: 메서드 구현부 수정
carti1108 Dec 12, 2023
d76aa26
refactor: 메서드 구현부 수정
carti1108 Dec 12, 2023
1f1d81a
feat: 접근제어수준 변경
carti1108 Dec 13, 2023
adf4bd0
docs: 파일 위치 수정
carti1108 Dec 14, 2023
567a0f6
refactor: 메서드 구현부 수정
carti1108 Dec 14, 2023
ff03792
refactor: 옵셔널 타입으로 변경
carti1108 Dec 14, 2023
0d9fa94
style: 컨벤션 수정
carti1108 Dec 14, 2023
ba98458
refactor: networkManager인스턴스 위치 변경
carti1108 Dec 14, 2023
e8ed996
refactor: 사용하지 않는 스택뷰 인스턴스 제거
carti1108 Dec 14, 2023
c631667
refactor: UIView & UIContentView를 typealias로 변경
carti1108 Dec 14, 2023
cddc279
docs: Date extenstion 파일 생성
carti1108 Dec 14, 2023
5de2644
func: yesterday 함수 정의 및 구현
carti1108 Dec 14, 2023
13f3398
style: Mark 주석 추가
carti1108 Dec 14, 2023
16b9cb1
style: 불필요한 개행 제거
carti1108 Dec 14, 2023
482c95d
feat: 기본 decode 메서드 위치 Decoder 모델 파일로 변경
carti1108 Dec 14, 2023
cc91fdf
feat: endRefreshing 구현부 수정
carti1108 Dec 14, 2023
a332805
style: 개행 추가
carti1108 Dec 14, 2023
f468e00
refactor: UIRefreshControl 구현부 수정
carti1108 Dec 14, 2023
96bc37e
refactor: UIRefreshControl 구현부 수정
carti1108 Dec 14, 2023
f372443
docs: Decoder 모델 폴더 위치 변경
carti1108 Dec 14, 2023
276f110
feat: ViewController에서 BoxOfficeListViewController로 네이밍 변경
carti1108 Dec 14, 2023
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
62 changes: 42 additions & 20 deletions BoxOffice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
4F1710DB2B16E5B400907DEC /* Movie+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1710D42B16D27A00907DEC /* Movie+.swift */; };
4F1710E02B1869D400907DEC /* FetchError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1710DF2B1869D400907DEC /* FetchError.swift */; };
4F1710F72B19788800907DEC /* NetworkManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1710F62B19788800907DEC /* NetworkManagerTests.swift */; };
4F1711362B1EF07000907DEC /* MovieListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1711352B1EF07000907DEC /* MovieListCell.swift */; };
4F1BA3E42B2196990075A9BD /* MovieConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1BA3E32B2196990075A9BD /* MovieConfiguration.swift */; };
4F1BA3E62B2196B20075A9BD /* MovieContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1BA3E52B2196B20075A9BD /* MovieContentView.swift */; };
4F1BA3E82B21ACFE0075A9BD /* DateFormat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F1BA3E72B21ACFE0075A9BD /* DateFormat.swift */; };
4F40B6C62B286C9E00CFE8C1 /* NSMutableAttributedString+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F40B6C52B286C9E00CFE8C1 /* NSMutableAttributedString+.swift */; };
4F40B6C82B286CCA00CFE8C1 /* String+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F40B6C72B286CCA00CFE8C1 /* String+.swift */; };
4F81AA162B2AE44C00B3071B /* Date+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F81AA152B2AE44C00B3071B /* Date+.swift */; };
63DF20EF2970E1A0005DF7D1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63DF20EE2970E1A0005DF7D1 /* AppDelegate.swift */; };
63DF20F12970E1A0005DF7D1 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63DF20F02970E1A0005DF7D1 /* SceneDelegate.swift */; };
63DF20F32970E1A0005DF7D1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63DF20F22970E1A0005DF7D1 /* ViewController.swift */; };
63DF20F62970E1A0005DF7D1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63DF20F42970E1A0005DF7D1 /* Main.storyboard */; };
63DF20F32970E1A0005DF7D1 /* BoxOfficeListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63DF20F22970E1A0005DF7D1 /* BoxOfficeListViewController.swift */; };
63DF20F82970E1A1005DF7D1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 63DF20F72970E1A1005DF7D1 /* Assets.xcassets */; };
63DF20FB2970E1A1005DF7D1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63DF20F92970E1A1005DF7D1 /* LaunchScreen.storyboard */; };
BF8B53842B14638C000D8CEC /* Movie.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8B53832B14638C000D8CEC /* Movie.swift */; };
Expand Down Expand Up @@ -50,11 +56,17 @@
4F1710DF2B1869D400907DEC /* FetchError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchError.swift; sourceTree = "<group>"; };
4F1710F42B19788800907DEC /* NetworkManagerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NetworkManagerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4F1710F62B19788800907DEC /* NetworkManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManagerTests.swift; sourceTree = "<group>"; };
4F1711352B1EF07000907DEC /* MovieListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieListCell.swift; sourceTree = "<group>"; };
4F1BA3E32B2196990075A9BD /* MovieConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieConfiguration.swift; sourceTree = "<group>"; };
4F1BA3E52B2196B20075A9BD /* MovieContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieContentView.swift; sourceTree = "<group>"; };
4F1BA3E72B21ACFE0075A9BD /* DateFormat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateFormat.swift; sourceTree = "<group>"; };
4F40B6C52B286C9E00CFE8C1 /* NSMutableAttributedString+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableAttributedString+.swift"; sourceTree = "<group>"; };
4F40B6C72B286CCA00CFE8C1 /* String+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+.swift"; sourceTree = "<group>"; };
4F81AA152B2AE44C00B3071B /* Date+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+.swift"; sourceTree = "<group>"; };
63DF20EB2970E1A0005DF7D1 /* BoxOffice.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BoxOffice.app; sourceTree = BUILT_PRODUCTS_DIR; };
63DF20EE2970E1A0005DF7D1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
63DF20F02970E1A0005DF7D1 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
63DF20F22970E1A0005DF7D1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
63DF20F52970E1A0005DF7D1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
63DF20F22970E1A0005DF7D1 /* BoxOfficeListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxOfficeListViewController.swift; sourceTree = "<group>"; };
63DF20F72970E1A1005DF7D1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
63DF20FA2970E1A1005DF7D1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
63DF20FC2970E1A1005DF7D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,6 +110,9 @@
isa = PBXGroup;
children = (
4F1710D42B16D27A00907DEC /* Movie+.swift */,
4F40B6C52B286C9E00CFE8C1 /* NSMutableAttributedString+.swift */,
4F40B6C72B286CCA00CFE8C1 /* String+.swift */,
4F81AA152B2AE44C00B3071B /* Date+.swift */,
);
path = Extension;
sourceTree = "<group>";
Expand Down Expand Up @@ -160,20 +175,30 @@
4F1711012B19818400907DEC /* Controller */ = {
isa = PBXGroup;
children = (
63DF20F22970E1A0005DF7D1 /* ViewController.swift */,
63DF20F22970E1A0005DF7D1 /* BoxOfficeListViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
};
4F1711022B19819400907DEC /* View */ = {
isa = PBXGroup;
children = (
63DF20F42970E1A0005DF7D1 /* Main.storyboard */,
63DF20F92970E1A1005DF7D1 /* LaunchScreen.storyboard */,
4F1BA3E32B2196990075A9BD /* MovieConfiguration.swift */,
4F1BA3E52B2196B20075A9BD /* MovieContentView.swift */,
4F1711352B1EF07000907DEC /* MovieListCell.swift */,
);
path = View;
sourceTree = "<group>";
};
4F1BA3E92B21ADED0075A9BD /* NameSpace */ = {
isa = PBXGroup;
children = (
4F1BA3E72B21ACFE0075A9BD /* DateFormat.swift */,
);
path = NameSpace;
sourceTree = "<group>";
};
63DF20E22970E1A0005DF7D1 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -230,6 +255,7 @@
4F1710FE2B19815E00907DEC /* Error */,
4F1710FD2B19814800907DEC /* Network */,
4F1710D32B16D26F00907DEC /* Extension */,
4F1BA3E92B21ADED0075A9BD /* NameSpace */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -347,7 +373,6 @@
files = (
63DF20FB2970E1A1005DF7D1 /* LaunchScreen.storyboard in Resources */,
63DF20F82970E1A1005DF7D1 /* Assets.xcassets in Resources */,
63DF20F62970E1A0005DF7D1 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -376,15 +401,22 @@
BFB8F2E82B18618400ECB799 /* NetworkManager.swift in Sources */,
4F1710DA2B16E5A700907DEC /* TestMovieJsonData.swift in Sources */,
4F1710D92B16E5A300907DEC /* DummyMovie.swift in Sources */,
63DF20F32970E1A0005DF7D1 /* ViewController.swift in Sources */,
63DF20F32970E1A0005DF7D1 /* BoxOfficeListViewController.swift in Sources */,
BFB8F31E2B19762600ECB799 /* URLManager.swift in Sources */,
4F40B6C82B286CCA00CFE8C1 /* String+.swift in Sources */,
4F1BA3E82B21ACFE0075A9BD /* DateFormat.swift in Sources */,
4F81AA162B2AE44C00B3071B /* Date+.swift in Sources */,
BFB8F3202B1977ED00ECB799 /* TestURLProtocol.swift in Sources */,
63DF20EF2970E1A0005DF7D1 /* AppDelegate.swift in Sources */,
4F40B6C62B286C9E00CFE8C1 /* NSMutableAttributedString+.swift in Sources */,
4F1BA3E62B2196B20075A9BD /* MovieContentView.swift in Sources */,
4F1710DB2B16E5B400907DEC /* Movie+.swift in Sources */,
4F1BA3E42B2196990075A9BD /* MovieConfiguration.swift in Sources */,
BF8B53842B14638C000D8CEC /* Movie.swift in Sources */,
4F1710E02B1869D400907DEC /* FetchError.swift in Sources */,
63DF20F12970E1A0005DF7D1 /* SceneDelegate.swift in Sources */,
BFB8F2E52B185D2900ECB799 /* MovieDetail.swift in Sources */,
4F1711362B1EF07000907DEC /* MovieListCell.swift in Sources */,
BFB8F3322B1DED7700ECB799 /* Decoder.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -413,14 +445,6 @@
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
63DF20F42970E1A0005DF7D1 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
63DF20F52970E1A0005DF7D1 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
63DF20F92970E1A1005DF7D1 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand Down Expand Up @@ -610,10 +634,9 @@
INFOPLIST_FILE = BoxOffice/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -638,10 +661,9 @@
INFOPLIST_FILE = BoxOffice/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "5D674CB9-279F-4BE0-B165-47BCA5B92AF9"
type = "1"
version = "2.0">
</Bucket>
115 changes: 115 additions & 0 deletions BoxOffice/Controller/BoxOfficeListViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// ViewController.swift
// BoxOffice
//
// Created by kjs on 13/01/23.
//

import UIKit

final class BoxOfficeListViewController: UIViewController {
private enum Section: Hashable {
case main
}

private var collectionView : UICollectionView = {
let configuration = UICollectionLayoutListConfiguration(appearance: .plain)
let layout = UICollectionViewCompositionalLayout.list(using: configuration)
let collectionView = UICollectionView(
frame: .zero,
collectionViewLayout: layout
)

collectionView.translatesAutoresizingMaskIntoConstraints = false

return collectionView
}()

private var dataSource: UICollectionViewDiffableDataSource<Section, DailyBoxOfficeList>?
private var movieList: [DailyBoxOfficeList] = []
private let networkManager = NetworkManager()

override func viewDidLoad() {
super.viewDidLoad()

configureUI()
configureDataSource()
fetchData()
}

private func configureDataSource() {
let cellRegistration = UICollectionView.CellRegistration<MovieListCell, DailyBoxOfficeList> { cell, indexPath, item in
cell.movie = item
cell.accessories = [.disclosureIndicator()]
}

dataSource = UICollectionViewDiffableDataSource<Section, DailyBoxOfficeList>(collectionView: collectionView) {
(collectionView: UICollectionView, indexPath: IndexPath, identifier: DailyBoxOfficeList) -> UICollectionViewCell? in
let cell = collectionView.dequeueConfiguredReusableCell(using: cellRegistration,
for: indexPath,
item: identifier)

return cell
}
}

private func applySnapshot() {
var snapshot = NSDiffableDataSourceSnapshot<Section, DailyBoxOfficeList>()
snapshot.appendSections([.main])
snapshot.appendItems(movieList, toSection: .main)

dataSource?.apply(snapshot, animatingDifferences: false)
}

private func fetchData() {
let date = Date().yesterday(format: DateFormat.forURL)
let url = URLManager.dailyBoxOffice(date: date).url

networkManager.fetchData(url: url) { response in
switch response {
case .success(let data):
self.movieList = Decoder().decodeDailyBoxOfficeList(data)
DispatchQueue.main.async {
self.applySnapshot()
self.collectionView.refreshControl?.endRefreshing()
}
case .failure(let error):
print(error.localizedDescription)
}
}
}

@objc func handleRefreshControl() {
fetchData()
}
}

// MARK: Layout

extension BoxOfficeListViewController {
private func configureUI() {
collectionView.refreshControl = UIRefreshControl()
collectionView.refreshControl?.addTarget(
self,
action: #selector(handleRefreshControl),
for: .valueChanged
)
view.addSubview(collectionView)
view.backgroundColor = .systemBackground
self.title = Date().yesterday(format: DateFormat.forTitle)

autoLayout()
}

private func autoLayout() {
let safeArea = view.safeAreaLayoutGuide

NSLayoutConstraint.activate([
collectionView.topAnchor.constraint(equalTo: safeArea.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor),
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
}
}

19 changes: 0 additions & 19 deletions BoxOffice/Controller/ViewController.swift

This file was deleted.

2 changes: 0 additions & 2 deletions BoxOffice/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
Expand Down
22 changes: 22 additions & 0 deletions BoxOffice/Model/Extension/Date+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Date+.swift
// BoxOffice
//
// Created by Kiseok on 12/14/23.
//

import Foundation

extension Date {
func yesterday(format: String) -> String {
let yesterday = Date(timeIntervalSinceNow: DateFormat.forTimeInterval)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format

guard let dateString = dateFormatter.string(for: yesterday) else {
return DateFormat.empty
}

return dateString
}
}
38 changes: 38 additions & 0 deletions BoxOffice/Model/Extension/NSMutableAttributedString+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// NSMutableAttributedString.swift
// BoxOffice
//
// Created by Kiseok on 12/12/23.
//

import UIKit

extension NSMutableAttributedString {
func body(string: String, fontSize: CGFloat) -> NSMutableAttributedString {
let font = UIFont.preferredFont(forTextStyle: .body)
let attributes: [NSAttributedString.Key: Any] = [.font: font]

self.append(NSAttributedString(string: string, attributes: attributes))
return self
}

func redColor(_ value:String) -> NSMutableAttributedString {
let attributes:[NSAttributedString.Key : Any] = [
.font: UIFont.preferredFont(forTextStyle: .body),
.foregroundColor: UIColor.red
]

self.append(NSAttributedString(string: value, attributes:attributes))
return self
}

func blueColor(_ value:String) -> NSMutableAttributedString {
let attributes:[NSAttributedString.Key : Any] = [
.font: UIFont.preferredFont(forTextStyle: .body),
.foregroundColor: UIColor.blue
]

self.append(NSAttributedString(string: value, attributes:attributes))
return self
}
}
17 changes: 17 additions & 0 deletions BoxOffice/Model/Extension/String+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// String+.swift
// BoxOffice
//
// Created by Kiseok on 12/12/23.
//

import Foundation

extension String {
func numberFormatter() -> String {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal

return numberFormatter.string(for: Int(self)) ?? ""
}
}
Loading