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

[FEAT] #21, #2 UI 구현 및 디테일 수정 #32

Merged
merged 6 commits into from Jul 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding.xcodeproj/project.pbxproj
Expand Up @@ -18,6 +18,8 @@
78AF38B2287A9FBC00BA81D4 /* BebasNeue.otf in Resources */ = {isa = PBXBuildFile; fileRef = 78AF38B1287A9FBC00BA81D4 /* BebasNeue.otf */; };
78AF38B5287AB2D600BA81D4 /* RowMovieList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78AF38B4287AB2D600BA81D4 /* RowMovieList.swift */; };
B919C987287DF5AA00EB9D42 /* ContentDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B919C986287DF5AA00EB9D42 /* ContentDetailView.swift */; };
B919C989287DF62F00EB9D42 /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B919C988287DF62F00EB9D42 /* Storage.swift */; };
B919C98C287EB44D00EB9D42 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = B919C98B287EB44D00EB9D42 /* Color.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -34,6 +36,8 @@
78AF38B1287A9FBC00BA81D4 /* BebasNeue.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = BebasNeue.otf; sourceTree = "<group>"; };
78AF38B4287AB2D600BA81D4 /* RowMovieList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowMovieList.swift; sourceTree = "<group>"; };
B919C986287DF5AA00EB9D42 /* ContentDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentDetailView.swift; sourceTree = "<group>"; };
B919C988287DF62F00EB9D42 /* Storage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Storage.swift; sourceTree = "<group>"; };
B919C98B287EB44D00EB9D42 /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -72,6 +76,7 @@
B919C985287DF58500EB9D42 /* Detail */,
78268A99287016BB0099F75C /* NeflixCloneCodingApp.swift */,
78268A9B287016BB0099F75C /* ContentView.swift */,
B919C98A287EB41E00EB9D42 /* Extensions */,
78268A9D287016BC0099F75C /* Assets.xcassets */,
78268A9F287016BC0099F75C /* Preview Content */,
);
Expand Down Expand Up @@ -114,6 +119,14 @@
path = Detail;
sourceTree = "<group>";
};
B919C98A287EB41E00EB9D42 /* Extensions */ = {
isa = PBXGroup;
children = (
B919C98B287EB44D00EB9D42 /* Color.swift */,
);
path = Extensions;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -188,6 +201,7 @@
78268A9C287016BB0099F75C /* ContentView.swift in Sources */,
78AF38B5287AB2D600BA81D4 /* RowMovieList.swift in Sources */,
78AF38AA287A9BA700BA81D4 /* MainPoster.swift in Sources */,
B919C98C287EB44D00EB9D42 /* Color.swift in Sources */,
B919C987287DF5AA00EB9D42 /* ContentDetailView.swift in Sources */,
78268A9A287016BB0099F75C /* NeflixCloneCodingApp.swift in Sources */,
78AF38A328770BE700BA81D4 /* TopContent.swift in Sources */,
Expand Down
242 changes: 169 additions & 73 deletions NeflixCloneCoding/NeflixCloneCoding/Detail/ContentDetailView.swift
Expand Up @@ -15,96 +15,192 @@ struct ContentDetailView: View {
Color.black
.ignoresSafeArea()

ScrollView {
VStack(alignment: .leading, spacing: 0) {
TopRoundedRectangleImage(radius: 13, height: 220, imageName: "MainTitle")

Text("이상한 나라의 수학자")
.font(.system(size: 16))
.padding(.horizontal, 8)
.padding(.vertical, 10)

Text("학업과 재정 측면에서 어려움을 겪고 있는 학생. 학교 경비원에게 수학을 가르쳐 달라고 요청한다. 그리고 성적보다 훨씬 더 많은 것을 얻게 되는데.")
.font(.system(size: 12))
.padding(.horizontal, 8)

HStack(spacing: 0) {
Text("출연: ")
.font(.system(size: 10))
ZStack(alignment: .topTrailing) {
ScrollView {
VStack(alignment: .leading, spacing: 0) {
Image("MainTitle")
.resizable()
.frame(height: 220)

Text("최민식, 김동회, 박병은 ...")
.font(.system(size: 10))
Text("이상한 나라의 수학자")
.font(.system(size: 17, weight: .semibold))
.fontWeight(.semibold)
.padding(.horizontal, 10)
.padding(.vertical, 12)

Button(action: {}, label: {
Text("더보기")
.font(.system(size: 10))
.fontWeight(.semibold)
.foregroundColor(.secondary)
ZStack {
RoundedRectangle(cornerRadius: 4)
.frame(height: 35)
.foregroundColor(.white)

HStack(spacing: 0) {
Image(systemName: "play.fill")
.foregroundColor(.black)
.padding(.trailing, 6)

Text("재생")
.font(.system(size: 16))
.foregroundColor(.black)
}
}
})
}
.padding(.horizontal, 8)
.padding(.top, 10)

HStack(spacing: 0) {
Text("감독: ")
.font(.system(size: 10))
.padding(.horizontal, 10)

Text("박동훈")
.font(.system(size: 10))
}
.padding(.horizontal, 8)
.padding(.top, 4)

VStack(alignment: .leading, spacing: 0) {
Rectangle()
.fill(.red)
.frame(maxWidth: 97, maxHeight: 4)
Button(action: {}, label: {
ZStack {
RoundedRectangle(cornerRadius: 4)
.frame(height: 35)
.foregroundColor(Color.grayButton)

HStack(spacing: 0) {
Image(systemName: "square.and.arrow.down")
.foregroundColor(.white)
.padding(.trailing, 6)

Text("저장")
.font(.system(size: 16))
.foregroundColor(.white)
}
}
})
.padding(.horizontal, 10)
.padding(.top, 10)

Text("학업과 재정 측면에서 어려움을 겪고 있는 학생. 학교 경비원에게 수학을 가르쳐 달라고 요청한다. 그리고 성적보다 훨씬 더 많은 것을 얻게 되는데.")
.font(.system(size: 13))
.padding(.horizontal, 10)
.padding(.top, 16)

HStack(spacing: 0) {
Text("출연: ")
.font(.system(size: 11))
.foregroundColor(.secondary)

Text("최민식, 김동회, 박병은 ...")
.font(.system(size: 11))
.foregroundColor(.secondary)

Button(action: {}, label: {
Text("더보기")
.font(.system(size: 11))
.fontWeight(.semibold)
.foregroundColor(.secondary)
})
}
.padding(.horizontal, 10)
.padding(.top, 10)

Text("함께 시청된 컨텐츠")
.font(.system(size: 13, weight: .semibold))
.padding(.top, 10)
HStack(spacing: 0) {
Text("감독: ")
.font(.system(size: 11))
.foregroundColor(.secondary)

Text("박동훈")
.font(.system(size: 11))
.foregroundColor(.secondary)
}
.padding(.horizontal, 10)
.padding(.top, 4)

HStack(spacing: 0) {
VStack(spacing: 0) {
Image(systemName: "plus")
.font(.system(size: 24))
.frame(height: 24)

Text("내가 찜한 콘텐츠")
.font(.system(size: 10))
.padding(.top, 8)
}
.frame(width: 100)

VStack(spacing: 0) {
Image(systemName: "hand.thumbsup")
.font(.system(size: 20))
.frame(height: 24)

Text("평가")
.font(.system(size: 10))
.padding(.top, 8)
}
.frame(width: 100)

VStack(spacing: 0) {
Image(systemName: "paperplane")
.font(.system(size: 20))
.frame(height: 24)

Text("공유")
.font(.system(size: 10))
.padding(.top, 8)
}
.frame(width: 100)
}
.padding(.horizontal, 10)
.padding(.top, 10)

VStack(alignment: .leading, spacing: 0) {
Rectangle()
.fill(.red)
.frame(maxWidth: 105, maxHeight: 4)

Text("함께 시청된 컨텐츠")
.font(.system(size: 14, weight: .semibold))
.padding(.top, 12)
}
.padding(.horizontal, 12)
.padding(.top, 16)

LazyVGrid(columns: columns, spacing: 7) {
ForEach((0...5), id: \.self) { _ in
Image("MainPoster")
.resizable()
.cornerRadius(4)
.frame(height: 174)
}
}
.padding(.horizontal, 10)
.padding(.top, 20)
}
.padding(.horizontal, 12)
.padding(.top, 10)
}

HStack(spacing: 0) {
Button(action: {}, label: {
ZStack {
Circle()
.fill(Color.grayButton)
.frame(width: 30, height: 30)

Image(systemName: "airplayvideo")
.foregroundColor(.white)
.font(.system(size: 14))
}
})
.padding(.trailing, 13)

LazyVGrid(columns: columns, spacing: 7) {
ForEach((0...5), id: \.self) { _ in
Image("MainPoster")
.resizable()
.cornerRadius(4)
.frame(height: 174)
Button(action: {}, label: {
ZStack {
Circle()
.fill(Color.grayButton)
.frame(width: 30, height: 30)

Image(systemName: "xmark")
.foregroundColor(.white)
.font(.system(size: 17))
}
}
.padding(.horizontal, 8)
.padding(.top, 16)
})
}
.padding(10)
}
.preferredColorScheme(.dark)
}
.preferredColorScheme(.dark)
}
}

struct ContentDetailView_Previews: PreviewProvider {
static var previews: some View {
ContentDetailView()
.previewDevice("iPhone 13 Pro")
}
}

// 상단 모서리만 둥근 모서리로 만드는 코드
// https://stackoverflow.com/questions/56760335/round-specific-corners-swiftui
struct TopRoundedRectangleImage: View {
var radius: CGFloat;
var height: CGFloat;
var imageName: String;

var body: some View {
Image(imageName)
.resizable()
.frame(height: height)
.foregroundColor(.orange)
.padding(.bottom, radius)
.cornerRadius(radius)
.padding(.bottom, -radius)
.previewDevice("iPhone 13 Pro Max")
}
}
26 changes: 26 additions & 0 deletions NeflixCloneCoding/NeflixCloneCoding/Extensions/Color.swift
@@ -0,0 +1,26 @@
//
// Color.swift
// NeflixCloneCoding
//
// Created by 정지혁 on 2022/07/13.
//

import Foundation
import SwiftUI

extension Color {
static let grayButton = Color(hex: "#292929")

init(hex: String) {
let scanner = Scanner(string: hex)
_ = scanner.scanString("#")

var rgb: UInt64 = 0
scanner.scanHexInt64(&rgb)

let r = Double((rgb >> 16) & 0xFF) / 255.0
let g = Double((rgb >> 8) & 0xFF) / 255.0
let b = Double((rgb >> 0) & 0xFF) / 255.0
self.init(red: r, green: g, blue: b)
}
}