Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
7821D5EC287EEAB200ACDF65 /* ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7821D5EB287EEAB200ACDF65 /* ViewModel.swift */; };
7821D691287EFF6500ACDF65 /* MovieData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7821D690287EFF6500ACDF65 /* MovieData.swift */; };
7821D693287F005C00ACDF65 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7821D692287F005C00ACDF65 /* Data.swift */; };
7821D695287F00FA00ACDF65 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7821D694287F00FA00ACDF65 /* Result.swift */; };
78268A9A287016BB0099F75C /* NeflixCloneCodingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78268A99287016BB0099F75C /* NeflixCloneCodingApp.swift */; };
78268A9C287016BB0099F75C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78268A9B287016BB0099F75C /* ContentView.swift */; };
78268A9E287016BC0099F75C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 78268A9D287016BC0099F75C /* Assets.xcassets */; };
Expand All @@ -23,6 +27,10 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
7821D5EB287EEAB200ACDF65 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = "<group>"; };
7821D690287EFF6500ACDF65 /* MovieData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieData.swift; sourceTree = "<group>"; };
7821D692287F005C00ACDF65 /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = "<group>"; };
7821D694287F00FA00ACDF65 /* Result.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
78268A96287016BB0099F75C /* NeflixCloneCoding.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NeflixCloneCoding.app; sourceTree = BUILT_PRODUCTS_DIR; };
78268A99287016BB0099F75C /* NeflixCloneCodingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NeflixCloneCodingApp.swift; sourceTree = "<group>"; };
78268A9B287016BB0099F75C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -51,6 +59,24 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
7821D5EA287EEAA300ACDF65 /* ViewModel */ = {
isa = PBXGroup;
children = (
7821D5EB287EEAB200ACDF65 /* ViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
7821D5ED287EF1A500ACDF65 /* Models */ = {
isa = PBXGroup;
children = (
7821D690287EFF6500ACDF65 /* MovieData.swift */,
7821D692287F005C00ACDF65 /* Data.swift */,
7821D694287F00FA00ACDF65 /* Result.swift */,
);
path = Models;
sourceTree = "<group>";
};
78268A8D287016BB0099F75C = {
isa = PBXGroup;
children = (
Expand All @@ -70,6 +96,8 @@
78268A98287016BB0099F75C /* NeflixCloneCoding */ = {
isa = PBXGroup;
children = (
7821D5ED287EF1A500ACDF65 /* Models */,
7821D5EA287EEAA300ACDF65 /* ViewModel */,
78AF38AD287A9EA600BA81D4 /* Info.plist */,
78AF38AB287A9E7400BA81D4 /* fonts */,
7862CCDB2875B0DA00FE3545 /* Main */,
Expand Down Expand Up @@ -199,13 +227,17 @@
buildActionMask = 2147483647;
files = (
78268A9C287016BB0099F75C /* ContentView.swift in Sources */,
7821D5EC287EEAB200ACDF65 /* ViewModel.swift in Sources */,
78AF38B5287AB2D600BA81D4 /* RowMovieList.swift in Sources */,
78AF38AA287A9BA700BA81D4 /* MainPoster.swift in Sources */,
7821D693287F005C00ACDF65 /* Data.swift in Sources */,
B919C98C287EB44D00EB9D42 /* Color.swift in Sources */,
B919C987287DF5AA00EB9D42 /* ContentDetailView.swift in Sources */,
7821D695287F00FA00ACDF65 /* Result.swift in Sources */,
78268A9A287016BB0099F75C /* NeflixCloneCodingApp.swift in Sources */,
78AF38A328770BE700BA81D4 /* TopContent.swift in Sources */,
78AF38A72878798600BA81D4 /* CategoryselectionView.swift in Sources */,
7821D691287EFF6500ACDF65 /* MovieData.swift in Sources */,
78AF389F2877033E00BA81D4 /* NetflixMain.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
5 changes: 5 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>BebasNeue.otf</string>
Expand Down
22 changes: 13 additions & 9 deletions NeflixCloneCoding/NeflixCloneCoding/Main/MainPoster.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@
import SwiftUI

struct MainPoster: View {
@EnvironmentObject var viewModel: ViewModel
var posterName : String
var movieName : String
var toystory2 = "http://file.koreafilm.or.kr/thm/02/00/01/61/tn_DPF002688.JPG"
var body: some View {
ZStack{
NavigationLink {
ContentDetailView()
.navigationBarTitleDisplayMode(.inline) //this must be empty

} label: {
Image(posterName)
.resizable()
.scaledToFill()
AsyncImage(url: URL(string: viewModel.mainPosterImageUrl)) { image in
image.resizable()
} placeholder: {
Color.gray
}
.frame(width: UIScreen.main.bounds.width , height: UIScreen.main.bounds.height * 0.5, alignment: .center)
}





}
.mask(LinearGradient(gradient: Gradient(colors: [.clear, .black, .black, .black,.clear]), startPoint: .top, endPoint: .bottom))

.onAppear(){
viewModel.getmoviePoster()
}

}


}

struct MainPoster_Previews: PreviewProvider {
Expand Down
32 changes: 24 additions & 8 deletions NeflixCloneCoding/NeflixCloneCoding/Main/NetflixMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@
import SwiftUI

struct NetflixMain: View {
@EnvironmentObject var viewModel: ViewModel
@State var iscategoryClicked = false

@State private var showingSheet = false

var categoryList = ["미국 블록버스터 영화","심리 게임 영화","실화 바탕 영화","인디 영화","오늘 대한민국의 Top 10 영화","호러 영화"]
init(){
UITabBar.appearance().barTintColor = .black
UITabBar.appearance().backgroundColor = .black
}
var body: some View {
ZStack{
NavigationView{
TabView{
ZStack{
Color.black
ScrollView{
ZStack{
//main Poster 이미지 들어가는 부분
VStack{
MainPoster(posterName: "MainTitle",movieName: "Toy Story3")
.padding(.bottom,80)
Button{
self.showingSheet.toggle()
}label: {
MainPoster(posterName: "MainTitle",movieName: "Toy Story2")
.padding(.bottom,80)
}
ForEach(categoryList,id:\.self){category in
RowMovieList(categoryName: category)
}
Expand All @@ -36,10 +43,15 @@ struct NetflixMain: View {
//상단 탭바
TopContent(iscategoryClicked: $iscategoryClicked)
//영화 제목
Text("Toy Story3")
.font(.custom("BebasNeue", size: 80))
.foregroundColor(.white)
.padding(.top,UIScreen.main.bounds.height * 0.2)



Text("Toy Story2")
.font(.custom("BebasNeue", size: 80))
.foregroundColor(.white)
.padding(.top,UIScreen.main.bounds.height * 0.2)


// 영화 카테고리
HStack{
Text("Friendship *")
Expand Down Expand Up @@ -95,6 +107,10 @@ struct NetflixMain: View {

}
}
.sheet(isPresented: $showingSheet) {
//sheet에 표시될 뷰를 할당
ContentDetailView()
}

}
.ignoresSafeArea()
Expand All @@ -119,7 +135,7 @@ struct NetflixMain: View {
}
}
.accentColor(.white)
}

if iscategoryClicked{
CategoryselectionView(iscategoryClicked: $iscategoryClicked)
}
Expand Down
15 changes: 15 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding/Models/Data.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Data.swift
// NeflixCloneCoding
//
// Created by dohankim on 2022/07/13.
//

import Foundation

struct Data : Codable{
var CollName : String?
var TotalCount : Int?
var Count : Int?
var Result : [Result]?
}
15 changes: 15 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding/Models/MovieData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// MovieData.swift
// NeflixCloneCoding
//
// Created by dohankim on 2022/07/13.
//

import Foundation

struct MovieData : Codable{
var Query : String?
var KMAQuery : String?
var TotalCount : Int?
var Data : [Data]? = []
}
55 changes: 55 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding/Models/Result.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Result.swift
// NeflixCloneCoding
//
// Created by dohankim on 2022/07/13.
//

import Foundation

struct Result :Codable{
var DOCID : String? = nil
var movieId : String? = nil
var movieSeq : String? = nil
var title : String? = nil
var titleEng : String? = nil
var titleOrg : String? = nil
var titleEtc : String? = nil
var prodYear : String? = nil

var nation : String? = nil
var company : String? = nil

var runtime : String? = nil
var rating : String? = nil
var genre : String? = nil
var kmdbUrl : String? = nil
var type : String? = nil
var use : String? = nil
var episodes : String? = nil
var ratedYn : String? = nil
var repRatDate : String? = nil
var repRlsDate : String? = nil

var keywords : String? = nil
var posters : String? = nil
var stlls : String? = nil

var openThtr : String? = nil

var screenArea : String? = nil
var screenCnt : String? = nil
var salesAcc : String? = nil
var audiAcc : String? = nil
var statSouce : String? = nil
var statDate : String? = nil
var themeSong : String? = nil
var soundtrack : String? = nil
var fLocation : String? = nil
var Awards1 : String? = nil
var Awards2 : String? = nil
var regDate : String? = nil
var modDate : String? = nil

var ALIAS : String? = nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct NeflixCloneCodingApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(ViewModel())
}
}
}
55 changes: 55 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding/ViewModel/ViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// ViewModel.swift
// NeflixCloneCoding
//
// Created by dohankim on 2022/07/13.
//

import SwiftUI
import Combine
class ViewModel : ObservableObject{
//스트링키 추가
//var stringKey =
@Published var mainPosterImageUrl = ""
@Published var imageurlArr : [String] = []

func loadData(completionHandler: @escaping (_ data:String)->Void) {
var urlString = "http://api.koreafilm.or.kr/openapi-data2/wisenut/search_api/search_json2.jsp?collection=kmdb_new2&detail=Y&title=토이스토리2&ServiceKey="+stringKey

let encodedString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
guard let url = URL(string: encodedString ) else {
print(encodedString)
fatalError("Invalid URL")
}

URLSession.shared.dataTask(with: url) { data, response, error in
guard let data = data, error == nil else {
print("error")
return
}
let result = try? JSONDecoder().decode(MovieData.self, from: data)
if let result = result {

result.Data?.forEach {
self.imageurlArr = ($0.Result?[0].posters?.components(separatedBy : "|"))!
print($0.Result?[0].posters)
print($0.TotalCount)
}
completionHandler(self.imageurlArr[1])
print(self.imageurlArr[0])
}


}.resume()

}

func getmoviePoster(){
loadData { [weak self] data in
self?.mainPosterImageUrl = data
}
}
}