-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Week 3 - Added HStack and cell and table view kinda view.
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-21.8 KB
...odeproj/project.xcworkspace/xcuserdata/rapunde.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()!) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |