Skip to content

Commit

Permalink
Week 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Bhasin committed Aug 29, 2020
1 parent f8748b4 commit a57b63f
Show file tree
Hide file tree
Showing 27 changed files with 642 additions and 1 deletion.
52 changes: 52 additions & 0 deletions SwiftUI_Starter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
776E672524CDC1680085CED6 /* MyContacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776E672424CDC1680085CED6 /* MyContacts.swift */; };
776E672724CDC7A80085CED6 /* ContactRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776E672624CDC7A80085CED6 /* ContactRow.swift */; };
776E672924E0601C0085CED6 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776E672824E0601C0085CED6 /* LoginView.swift */; };
7799E0EE24FA7699000EAB83 /* CastAndCrewSingleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0ED24FA7699000EAB83 /* CastAndCrewSingleView.swift */; };
7799E0F024FA76B8000EAB83 /* CastAndCrewsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0EF24FA76B8000EAB83 /* CastAndCrewsView.swift */; };
7799E0F224FA76CF000EAB83 /* CornerRadiusViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0F124FA76CF000EAB83 /* CornerRadiusViewModifier.swift */; };
7799E0F424FA78D8000EAB83 /* GenreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0F324FA78D8000EAB83 /* GenreView.swift */; };
7799E0F624FA78EE000EAB83 /* ImageAndRatingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0F524FA78EE000EAB83 /* ImageAndRatingsView.swift */; };
7799E0F824FA7900000EAB83 /* Movie.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0F724FA7900000EAB83 /* Movie.swift */; };
7799E0FA24FA7925000EAB83 /* MovieDescriptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0F924FA7925000EAB83 /* MovieDescriptionView.swift */; };
7799E0FC24FA793B000EAB83 /* MovieDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0FB24FA793B000EAB83 /* MovieDetailView.swift */; };
7799E0FE24FA7965000EAB83 /* MovieImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0FD24FA7965000EAB83 /* MovieImageView.swift */; };
7799E10024FA7978000EAB83 /* MovieRatingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E0FF24FA7978000EAB83 /* MovieRatingsView.swift */; };
7799E10224FA798D000EAB83 /* MovieSubDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E10124FA798D000EAB83 /* MovieSubDetailView.swift */; };
7799E10424FA799B000EAB83 /* NameAndGenreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E10324FA799B000EAB83 /* NameAndGenreView.swift */; };
7799E10624FA79AE000EAB83 /* RatingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7799E10524FA79AE000EAB83 /* RatingsView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -36,6 +49,19 @@
776E672424CDC1680085CED6 /* MyContacts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyContacts.swift; sourceTree = "<group>"; };
776E672624CDC7A80085CED6 /* ContactRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactRow.swift; sourceTree = "<group>"; };
776E672824E0601C0085CED6 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
7799E0ED24FA7699000EAB83 /* CastAndCrewSingleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CastAndCrewSingleView.swift; sourceTree = "<group>"; };
7799E0EF24FA76B8000EAB83 /* CastAndCrewsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CastAndCrewsView.swift; sourceTree = "<group>"; };
7799E0F124FA76CF000EAB83 /* CornerRadiusViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerRadiusViewModifier.swift; sourceTree = "<group>"; };
7799E0F324FA78D8000EAB83 /* GenreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenreView.swift; sourceTree = "<group>"; };
7799E0F524FA78EE000EAB83 /* ImageAndRatingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageAndRatingsView.swift; sourceTree = "<group>"; };
7799E0F724FA7900000EAB83 /* Movie.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Movie.swift; sourceTree = "<group>"; };
7799E0F924FA7925000EAB83 /* MovieDescriptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieDescriptionView.swift; sourceTree = "<group>"; };
7799E0FB24FA793B000EAB83 /* MovieDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieDetailView.swift; sourceTree = "<group>"; };
7799E0FD24FA7965000EAB83 /* MovieImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieImageView.swift; sourceTree = "<group>"; };
7799E0FF24FA7978000EAB83 /* MovieRatingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieRatingsView.swift; sourceTree = "<group>"; };
7799E10124FA798D000EAB83 /* MovieSubDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieSubDetailView.swift; sourceTree = "<group>"; };
7799E10324FA799B000EAB83 /* NameAndGenreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameAndGenreView.swift; sourceTree = "<group>"; };
7799E10524FA79AE000EAB83 /* RatingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RatingsView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -77,6 +103,19 @@
776E672424CDC1680085CED6 /* MyContacts.swift */,
776E672624CDC7A80085CED6 /* ContactRow.swift */,
776E672824E0601C0085CED6 /* LoginView.swift */,
7799E0ED24FA7699000EAB83 /* CastAndCrewSingleView.swift */,
7799E0EF24FA76B8000EAB83 /* CastAndCrewsView.swift */,
7799E0F124FA76CF000EAB83 /* CornerRadiusViewModifier.swift */,
7799E0F324FA78D8000EAB83 /* GenreView.swift */,
7799E0F524FA78EE000EAB83 /* ImageAndRatingsView.swift */,
7799E0F724FA7900000EAB83 /* Movie.swift */,
7799E0F924FA7925000EAB83 /* MovieDescriptionView.swift */,
7799E0FB24FA793B000EAB83 /* MovieDetailView.swift */,
7799E0FD24FA7965000EAB83 /* MovieImageView.swift */,
7799E0FF24FA7978000EAB83 /* MovieRatingsView.swift */,
7799E10124FA798D000EAB83 /* MovieSubDetailView.swift */,
7799E10324FA799B000EAB83 /* NameAndGenreView.swift */,
7799E10524FA79AE000EAB83 /* RatingsView.swift */,
77029AF324AA7282007896AD /* Assets.xcassets */,
77029AF824AA7282007896AD /* LaunchScreen.storyboard */,
77029AFB24AA7282007896AD /* Info.plist */,
Expand Down Expand Up @@ -164,11 +203,24 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7799E0FE24FA7965000EAB83 /* MovieImageView.swift in Sources */,
776E672524CDC1680085CED6 /* MyContacts.swift in Sources */,
77029AEE24AA727F007896AD /* AppDelegate.swift in Sources */,
7799E0F424FA78D8000EAB83 /* GenreView.swift in Sources */,
7799E10024FA7978000EAB83 /* MovieRatingsView.swift in Sources */,
77029AF024AA727F007896AD /* SceneDelegate.swift in Sources */,
7799E10224FA798D000EAB83 /* MovieSubDetailView.swift in Sources */,
7799E10624FA79AE000EAB83 /* RatingsView.swift in Sources */,
7799E0F224FA76CF000EAB83 /* CornerRadiusViewModifier.swift in Sources */,
7799E0EE24FA7699000EAB83 /* CastAndCrewSingleView.swift in Sources */,
7799E0F824FA7900000EAB83 /* Movie.swift in Sources */,
7799E0FA24FA7925000EAB83 /* MovieDescriptionView.swift in Sources */,
7799E10424FA799B000EAB83 /* NameAndGenreView.swift in Sources */,
7799E0F624FA78EE000EAB83 /* ImageAndRatingsView.swift in Sources */,
776E672924E0601C0085CED6 /* LoginView.swift in Sources */,
7729D99E24C0B9AA00FB8EFF /* ListView.swift in Sources */,
7799E0F024FA76B8000EAB83 /* CastAndCrewsView.swift in Sources */,
7799E0FC24FA793B000EAB83 /* MovieDetailView.swift in Sources */,
77029AF224AA727F007896AD /* ContentView.swift in Sources */,
7729D99C24C0B69300FB8EFF /* CellRow.swift in Sources */,
7729D99A24B9C0A500FB8EFF /* LearnImagesView.swift in Sources */,
Expand Down
Binary file not shown.
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,15 @@
{
"images" : [
{
"filename" : "Caitriona Balfe.jpg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
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,15 @@
{
"images" : [
{
"filename" : "Christian Bale.jpg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Ford V Ferrari.jpeg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
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,15 @@
{
"images" : [
{
"filename" : "James Mangold.jpg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SwiftUI_Starter/Assets.xcassets/James Mangold.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions SwiftUI_Starter/Assets.xcassets/Matt Damon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Matt Damon.jpg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions SwiftUI_Starter/CastAndCrewSingleView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CastAndCrewSingleView.swift
// SwiftUI_Starter
//
// Created by Karan Bhasin on 29/08/20.
// Copyright © 2020 Karan Bhaisn. All rights reserved.
//

import SwiftUI

struct CastAndCrewSingleView: View {
var castAndCrew: CastAndCrew
var body: some View {
return VStack(spacing: 3) {
Image(castAndCrew.image)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 80, height: 80)
.cornerRadius(40)
Text(castAndCrew.name)
.frame(width: 100)
.multilineTextAlignment(.center)
.fixedSize(horizontal: false, vertical: true)
Text(castAndCrew.designation)
.font(.subheadline)
.frame(width: 100)
.foregroundColor(.secondary)
}
}
}

struct CastAndCrewSingleView_Previews: PreviewProvider {
static var previews: some View {
CastAndCrewSingleView(castAndCrew: CastAndCrew(name: "JK", designation: "kjhgjk"))
}
}
33 changes: 33 additions & 0 deletions SwiftUI_Starter/CastAndCrewsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// CastAndCrewsView.swift
// SwiftUI_Starter
//
// Created by Karan Bhasin on 29/08/20.
// Copyright © 2020 Karan Bhaisn. All rights reserved.
//

import SwiftUI

struct CastAndCrewsView: View {
let castAndCrews: [CastAndCrew]

var body: some View {
VStack(alignment: .leading) {
Text("Cast and Crew")
.padding(.all)
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .top, spacing: 10) {
ForEach(castAndCrews) { castAndCrew in
CastAndCrewSingleView(castAndCrew: castAndCrew)
}
}
}
}
}
}

struct CastAndCrewsView_Previews: PreviewProvider {
static var previews: some View {
CastAndCrewsView(castAndCrews: [CastAndCrew(name: "K", designation: "Mr. K"), CastAndCrew(name: "B", designation: "Mr. B")])
}
}
37 changes: 37 additions & 0 deletions SwiftUI_Starter/CornerRadiusViewModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// CornerRadiusViewModifier.swift
// SwiftUI_Starter
//
// Created by Karan Bhasin on 29/08/20.
// Copyright © 2020 Karan Bhaisn. All rights reserved.
//

import SwiftUI

struct CornerRadiusViewModifier: ViewModifier {
var radius: CGFloat
var corners: UIRectCorner

struct CornerRadiusShape: Shape {

var radius = CGFloat.infinity
var corners = UIRectCorner.allCorners

func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
}
}

func body(content: Content) -> some View {
content
.clipShape(CornerRadiusShape(radius: radius, corners: corners))
}
}

extension View {
func cornerRadius(radius: CGFloat, corners: UIRectCorner) -> some View {
ModifiedContent(content: self, modifier: CornerRadiusViewModifier(radius: radius, corners: corners))
}
}

53 changes: 53 additions & 0 deletions SwiftUI_Starter/GenreView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// GenreView.swift
// SwiftUI_Starter
//
// Created by Karan Bhasin on 29/08/20.
// Copyright © 2020 Karan Bhaisn. All rights reserved.
//

import SwiftUI

struct GenreView: View {
var body: some View {
return HStack(spacing: 15) {
Button(action: actionMethod) {
Text("Action")
.padding([.leading,.trailing], 20)
.padding([.top,.bottom], 5)
.overlay(
Capsule(style: .continuous)
.stroke(Color.gray, lineWidth: 1)
)
}.accentColor(.black)
Button(action: actionMethod) {
Text("Biography")
.padding([.leading,.trailing], 20)
.padding([.top,.bottom], 5)
.overlay(
Capsule(style: .continuous)
.stroke(Color.gray, lineWidth: 1)
)
}.accentColor(.black)
Button(action: actionMethod) {
Text("Drama")
.padding([.leading,.trailing], 20)
.padding([.top,.bottom], 5)
.overlay(
Capsule(style: .continuous)
.stroke(Color.gray, lineWidth: 1)
)
}.accentColor(.black)
}.padding([.top], 10)
}

func actionMethod() {

}
}

struct GenreView_Previews: PreviewProvider {
static var previews: some View {
GenreView()
}
}
26 changes: 26 additions & 0 deletions SwiftUI_Starter/ImageAndRatingsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ImageAndRatingsView.swift
// SwiftUI_Starter
//
// Created by Karan Bhasin on 29/08/20.
// Copyright © 2020 Karan Bhaisn. All rights reserved.
//

import SwiftUI

struct ImageAndRatingsView: View {
var image: String

var body: some View {
ZStack(alignment: .bottomTrailing) {
MovieImageView(image: image)
MovieRatingsView()
}
}
}

struct ImageAndRatingsView_Previews: PreviewProvider {
static var previews: some View {
ImageAndRatingsView(image: "apple")
}
}
44 changes: 44 additions & 0 deletions SwiftUI_Starter/Movie.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Movie.swift
// SwiftUI_Starter
//
// Created by Karan Bhasin on 29/08/20.
// Copyright © 2020 Karan Bhaisn. All rights reserved.
//

import SwiftUI

struct Movie : Identifiable {
var id = UUID()
var name: String
var description: String
var castAndCrews: [CastAndCrew]

var image: String { return name }
}

struct CastAndCrew: Identifiable {
var id = UUID()
let name: String
let designation: String
var image: String { return name }

// static func data() -> [ListModel] {
// return [ListModel(id: 0, name: "Karan", imageName: "Bhasin"),
// ListModel(id: 0, name: "Nila", imageName: "Akash"),
// ListModel(id: 0, name: "Nitin", imageName: "Pant"),
// ListModel(id: 0, name: "Deepak", imageName: "Carpenter"),
// ListModel(id: 0, name: "Dileep", imageName: "M")]
// }
}

let testMovieDetailData = Movie(name: "Ford V Ferrari",
description: "American automotive designer Carroll Shelby and fearless British race car driver Ken Miles battle corporate interference, the laws of physics and their own personal demons to build a revolutionary vehicle for the Ford Motor Co.",
castAndCrews: testCastAndCrewData)

let testCastAndCrewData = [
CastAndCrew(name: "James Mangold", designation: "Director"),
CastAndCrew(name: "Matt Damon", designation: "Carroll"),
CastAndCrew(name: "Christian Bale", designation: "Ken Miles"),
CastAndCrew(name: "Caitriona Balfe", designation: "Mollie")
]
Loading

0 comments on commit a57b63f

Please sign in to comment.