Skip to content

Commit

Permalink
Week4 and Week 5 Done
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhole committed Jul 31, 2020
1 parent 155bdfc commit 1ca09bb
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 24 deletions.
16 changes: 12 additions & 4 deletions SwiftUIPractice/SwiftUIPractice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@
/* Begin PBXBuildFile section */
8928727C24B9AC7300799950 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8928727B24B9AC7300799950 /* AppDelegate.swift */; };
8928727E24B9AC7300799950 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8928727D24B9AC7300799950 /* SceneDelegate.swift */; };
8928728024B9AC7300799950 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8928727F24B9AC7300799950 /* ContentView.swift */; };
8928728024B9AC7300799950 /* ImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8928727F24B9AC7300799950 /* ImageView.swift */; };
8928728224B9AC7400799950 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8928728124B9AC7400799950 /* Assets.xcassets */; };
8928728524B9AC7400799950 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8928728424B9AC7400799950 /* Preview Assets.xcassets */; };
8928728824B9AC7400799950 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8928728624B9AC7400799950 /* LaunchScreen.storyboard */; };
897AD13B24C441420076DD13 /* SegmentedControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897AD13A24C441420076DD13 /* SegmentedControlView.swift */; };
89AFC52024C330EB005ABCDB /* StackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89AFC51F24C330EB005ABCDB /* StackView.swift */; };
89DE15D824D3E3820042E1D8 /* LoginScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89DE15D724D3E3820042E1D8 /* LoginScreenView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
8928727824B9AC7300799950 /* SwiftUIPractice.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUIPractice.app; sourceTree = BUILT_PRODUCTS_DIR; };
8928727B24B9AC7300799950 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8928727D24B9AC7300799950 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
8928727F24B9AC7300799950 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
8928727F24B9AC7300799950 /* ImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageView.swift; sourceTree = "<group>"; };
8928728124B9AC7400799950 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8928728424B9AC7400799950 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
8928728724B9AC7400799950 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
8928728924B9AC7400799950 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
897AD13A24C441420076DD13 /* SegmentedControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentedControlView.swift; sourceTree = "<group>"; };
89AFC51F24C330EB005ABCDB /* StackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackView.swift; sourceTree = "<group>"; };
89DE15D724D3E3820042E1D8 /* LoginScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreenView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -60,12 +64,14 @@
children = (
8928727B24B9AC7300799950 /* AppDelegate.swift */,
8928727D24B9AC7300799950 /* SceneDelegate.swift */,
8928727F24B9AC7300799950 /* ContentView.swift */,
8928727F24B9AC7300799950 /* ImageView.swift */,
8928728124B9AC7400799950 /* Assets.xcassets */,
8928728624B9AC7400799950 /* LaunchScreen.storyboard */,
8928728924B9AC7400799950 /* Info.plist */,
8928728324B9AC7400799950 /* Preview Content */,
89AFC51F24C330EB005ABCDB /* StackView.swift */,
897AD13A24C441420076DD13 /* SegmentedControlView.swift */,
89DE15D724D3E3820042E1D8 /* LoginScreenView.swift */,
);
path = SwiftUIPractice;
sourceTree = "<group>";
Expand Down Expand Up @@ -149,9 +155,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
897AD13B24C441420076DD13 /* SegmentedControlView.swift in Sources */,
8928727C24B9AC7300799950 /* AppDelegate.swift in Sources */,
8928727E24B9AC7300799950 /* SceneDelegate.swift in Sources */,
8928728024B9AC7300799950 /* ContentView.swift in Sources */,
8928728024B9AC7300799950 /* ImageView.swift in Sources */,
89DE15D824D3E3820042E1D8 /* LoginScreenView.swift in Sources */,
89AFC52024C330EB005ABCDB /* StackView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Nature2.jpeg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "ferrari.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

struct ContentView: View {
struct ImageView: View {
@State var scale: CGFloat = 1.0
@State private var half = false
@State private var dim = false
Expand Down Expand Up @@ -46,6 +46,6 @@ struct ContentView: View {

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
ImageView()
}
}
82 changes: 82 additions & 0 deletions SwiftUIPractice/SwiftUIPractice/LoginScreenView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// LoginScreenView.swift
// SwiftUIPractice
//
// Created by Bhole, Kaustubh Satish on 31/07/20.
// Copyright © 2020 Bhole, Kaustubh Satish. All rights reserved.
//

import SwiftUI

struct LoginScreenView: View {
@State var email = ""
@State var password = ""
@State var loginBittonClick: Int? = nil

var body: some View {

NavigationView {
VStack(alignment: .leading) {
Text("Let's Login.")
.bold()
.font(.system(size: 40))
.multilineTextAlignment(.leading)
.frame(width: 300, height: 100, alignment: .topLeading)
.padding(Edge.Set.bottom, 50)

Text("Email address:")
.font(.headline)
TextField("Email", text: $email)
.frame(height:44)
.accentColor(Color.white)
.background(Color(UIColor.lightGray))
.cornerRadius(4.0)

Text("Password:")
.font(.headline)

SecureField("Password", text: $password)
.frame(height:44)
.accentColor(Color.white)
.background(Color(UIColor.lightGray))
.cornerRadius(4.0)
HStack {
Spacer()
Button(action: {
print("Forgot password tapped")
}) {
Text("Forgot Password?").foregroundColor(Color.gray).bold()
}
.accentColor(Color.black)
.padding(Edge.Set.vertical, 5)
}
Spacer()
NavigationLink(destination: SegmentedControlView(), tag: 1, selection: $loginBittonClick) {
Button(action: {
self.loginBittonClick = 1
}) {
HStack {
Spacer()
Text("Login").foregroundColor(Color.white).bold()
Spacer()
}
}
.accentColor(Color.black)
.padding()
.background(Color(UIColor.red))
.cornerRadius(20.0)
.padding(Edge.Set.vertical, 20)
}
Spacer()
}
.padding(.horizontal,30)
}
.navigationBarTitle(Text("Login"))
}
}

struct LoginScreenView_Previews: PreviewProvider {
static var previews: some View {
LoginScreenView()
}
}
2 changes: 1 addition & 1 deletion SwiftUIPractice/SwiftUIPractice/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

// Create the SwiftUI view that provides the window contents.
let contentView = StackView()
let contentView = LoginScreenView()

// Use a UIHostingController as window root view controller.
if let windowScene = scene as? UIWindowScene {
Expand Down
106 changes: 106 additions & 0 deletions SwiftUIPractice/SwiftUIPractice/SegmentedControlView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// SegmentedControlView.swift
// SwiftUIPractice
//
// Created by Bhole, Kaustubh Satish on 19/07/20.
// Copyright © 2020 Bhole, Kaustubh Satish. All rights reserved.
//

import SwiftUI

struct SegmentedControlView: View {
@State private var selectedIndex = 0
private let segmentItems = ["Nature","Birds","Cars"]
private let images = ["Nature2","bird1","ferrari"]

var body: some View {
VStack {
Picker("", selection: $selectedIndex) {
ForEach(0 ..< segmentItems.count) {
Text(self.segmentItems[$0])
}
}.pickerStyle(SegmentedPickerStyle())
.padding(.all, 20)
.onReceive([self.selectedIndex].publisher.first()) { index in
switch index {
case 0:
print("First Tab selected")
case 1:
print("Second Tab selected")
default:
break
}
}
List {
ForEach (0...4, id: \.self) { contact in
NavigationLink(destination: Image(self.images[self.selectedIndex])) {
CellRow(selectedIndex: self.selectedIndex)
}
}
}
}
}
}

struct CellRow: View {
var selectedIndex = 0

var body: some View {
containViews()
}

func containViews() -> AnyView {
switch self.selectedIndex {
case 0:
return AnyView(ListRow(text: "Colors are the smiles of Nature", image: "Nature2"))
case 1:
return AnyView(ListRow(text: "A bird who dares to fall is the bird who learn to fly", image: "bird1"))
case 2:
return AnyView(ListRow(text: "No road is long with Good Company", image: "ferrari"))
default:
return AnyView(ListRow(text: "cars are just Awesome", image: "ferrari"))
}
}
}

struct ListRow: View {
var text: String
var image: String

var body: some View {
HStack {
VStack(alignment: .leading, spacing: 5) {
Text(text)
}
Image(image)
.resizable()
.scaledToFit()
.frame(height: 160, alignment: .center)
}.background(Color(.lightGray))

}
}

struct Car: View {
var body: some View {
Image("ferrari")
.resizable()
.scaledToFit()
.frame(height: 160, alignment: .center)
}
}

struct Nature: View {
var body: some View {
Image("Nature2")
.resizable()
.scaledToFit()
.frame(height: 160, alignment: .center)
}
}

struct SegmentedControlView_Previews: PreviewProvider {
static var previews: some View {
SegmentedControlView()
}
}
17 changes: 0 additions & 17 deletions SwiftUIPractice/SwiftUIPractice/StackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@ struct StackView: View {
}
}

struct CellRow: View {
var body: some View {
HStack {
VStack(alignment: .leading, spacing: 10) {
Image("treeImage")
.frame(width: 100, height: 100, alignment: .center)
.clipShape(Circle())
.padding(.leading, 20)
Text("Nature is So beautiful")
}
Image("bird1")
.resizable()
.frame(width: 160, height: 160, alignment: .center)
}.background(Color(.lightGray))
}
}

struct StackView_Previews: PreviewProvider {
static var previews: some View {
StackView()
Expand Down

0 comments on commit 1ca09bb

Please sign in to comment.