Skip to content

Commit

Permalink
Week 3 - Added HStack and cell and table view kinda view.
Browse files Browse the repository at this point in the history
  • Loading branch information
rapunde committed Jul 29, 2020
1 parent 665ccd9 commit 39c123e
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 100DaysOfSwiftUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/* Begin PBXBuildFile section */
F014A2CB24B72B07002A8543 /* ImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F014A2CA24B72B07002A8543 /* ImageView.swift */; };
F01D9CF424D19FBC0070D6B3 /* CellRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = F01D9CF324D19FBC0070D6B3 /* CellRow.swift */; };
F01D9CF724D1A2620070D6B3 /* ListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F01D9CF624D1A2620070D6B3 /* ListModel.swift */; };
F01D9CF924D1A3000070D6B3 /* MyFirstView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F01D9CF824D1A3000070D6B3 /* MyFirstView.swift */; };
F087E2CF24AF39E8003E3128 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F087E2CE24AF39E8003E3128 /* AppDelegate.swift */; };
F087E2D124AF39E8003E3128 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F087E2D024AF39E8003E3128 /* SceneDelegate.swift */; };
F087E2D324AF39E8003E3128 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F087E2D224AF39E8003E3128 /* ContentView.swift */; };
Expand All @@ -18,6 +21,9 @@

/* Begin PBXFileReference section */
F014A2CA24B72B07002A8543 /* ImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageView.swift; sourceTree = "<group>"; };
F01D9CF324D19FBC0070D6B3 /* CellRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CellRow.swift; sourceTree = "<group>"; };
F01D9CF624D1A2620070D6B3 /* ListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListModel.swift; sourceTree = "<group>"; };
F01D9CF824D1A3000070D6B3 /* MyFirstView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyFirstView.swift; sourceTree = "<group>"; };
F087E2CB24AF39E8003E3128 /* 100DaysOfSwiftUI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 100DaysOfSwiftUI.app; sourceTree = BUILT_PRODUCTS_DIR; };
F087E2CE24AF39E8003E3128 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
F087E2D024AF39E8003E3128 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -66,6 +72,9 @@
F087E2DC24AF39EC003E3128 /* Info.plist */,
F087E2D624AF39EC003E3128 /* Preview Content */,
F014A2CA24B72B07002A8543 /* ImageView.swift */,
F01D9CF324D19FBC0070D6B3 /* CellRow.swift */,
F01D9CF624D1A2620070D6B3 /* ListModel.swift */,
F01D9CF824D1A3000070D6B3 /* MyFirstView.swift */,
);
path = 100DaysOfSwiftUI;
sourceTree = "<group>";
Expand Down Expand Up @@ -149,9 +158,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F01D9CF924D1A3000070D6B3 /* MyFirstView.swift in Sources */,
F014A2CB24B72B07002A8543 /* ImageView.swift in Sources */,
F01D9CF724D1A2620070D6B3 /* ListModel.swift in Sources */,
F087E2CF24AF39E8003E3128 /* AppDelegate.swift in Sources */,
F087E2D124AF39E8003E3128 /* SceneDelegate.swift in Sources */,
F01D9CF424D19FBC0070D6B3 /* CellRow.swift in Sources */,
F087E2D324AF39E8003E3128 /* ContentView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file not shown.
50 changes: 50 additions & 0 deletions 100DaysOfSwiftUI/CellRow.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// CellRow.swift
// 100DaysOfSwiftUI
//
// Created by Punde, Rasika Nanasaheb on 29/07/20.
// Copyright © 2020 Punde, Rasika Nanasaheb (US - Mumbai). All rights reserved.
//

import SwiftUI

struct CellRow: View {
let cellData: ListModel

var body: some View {
HStack(spacing: 10) {

Image(cellData.imageName)
.resizable()
.frame(width: 40,
height: 40)
VStack(alignment: .leading) {
Text(cellData.title)
.font(.headline)
.foregroundColor(Color.blue)
Text(cellData.subtitle)
.font(.subheadline)
.foregroundColor(Color.blue)
}

Spacer()
Button(action: buttonAction) {

Image(systemName: "chevron.right")
.frame(width: 20, height: 20)

}

}.padding()
}

private func buttonAction() {

}
}

struct CellRow_Previews: PreviewProvider {
static var previews: some View {
CellRow(cellData: ListModel.dummyData().randomElement()!)
}
}
23 changes: 23 additions & 0 deletions 100DaysOfSwiftUI/ListModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// File.swift
// 100DaysOfSwiftUI
//
// Created by Punde, Rasika Nanasaheb on 29/07/20.
// Copyright © 2020 Punde, Rasika Nanasaheb (US - Mumbai). All rights reserved.
//

import SwiftUI
struct ListModel: Identifiable, Hashable {

let id: Int
let title: String
let subtitle: String
let imageName: String

static func dummyData() -> [ListModel] {
return [ListModel(id: 0, title: "title1", subtitle: "subtitle1", imageName: "1"),
ListModel(id: 1, title: "title2", subtitle: "subtitle2", imageName: "1"),
ListModel(id: 2, title: "title3", subtitle: "subtitle3", imageName: "1")]
}

}
27 changes: 27 additions & 0 deletions 100DaysOfSwiftUI/MyFirstView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// MyFirstView.swift
// 100DaysOfSwiftUI
//
// Created by Punde, Rasika Nanasaheb on 29/07/20.
// Copyright © 2020 Punde, Rasika Nanasaheb (US - Mumbai). All rights reserved.
//

import SwiftUI

struct MyFirstView: View {
var body: some View {
NavigationView {
List {
ForEach(ListModel.dummyData(), id: \.self) { listObj in
CellRow(cellData: listObj)
}
}.navigationBarTitle(Text("List View"))
}
}
}

struct MyFirstView_Previews: PreviewProvider {
static var previews: some View {
MyFirstView()
}
}

0 comments on commit 39c123e

Please sign in to comment.