diff --git a/100DaysOfSwiftUI.xcodeproj/project.pbxproj b/100DaysOfSwiftUI.xcodeproj/project.pbxproj index 48421f4..29b5b22 100644 --- a/100DaysOfSwiftUI.xcodeproj/project.pbxproj +++ b/100DaysOfSwiftUI.xcodeproj/project.pbxproj @@ -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 */; }; @@ -18,6 +21,9 @@ /* Begin PBXFileReference section */ F014A2CA24B72B07002A8543 /* ImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageView.swift; sourceTree = ""; }; + F01D9CF324D19FBC0070D6B3 /* CellRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CellRow.swift; sourceTree = ""; }; + F01D9CF624D1A2620070D6B3 /* ListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListModel.swift; sourceTree = ""; }; + F01D9CF824D1A3000070D6B3 /* MyFirstView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyFirstView.swift; sourceTree = ""; }; 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 = ""; }; F087E2D024AF39E8003E3128 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -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 = ""; @@ -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; diff --git a/100DaysOfSwiftUI.xcodeproj/project.xcworkspace/xcuserdata/rapunde.xcuserdatad/UserInterfaceState.xcuserstate b/100DaysOfSwiftUI.xcodeproj/project.xcworkspace/xcuserdata/rapunde.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index 0d5fb4a..0000000 Binary files a/100DaysOfSwiftUI.xcodeproj/project.xcworkspace/xcuserdata/rapunde.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/100DaysOfSwiftUI/CellRow.swift b/100DaysOfSwiftUI/CellRow.swift new file mode 100644 index 0000000..0f12719 --- /dev/null +++ b/100DaysOfSwiftUI/CellRow.swift @@ -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()!) + } +} diff --git a/100DaysOfSwiftUI/ListModel.swift b/100DaysOfSwiftUI/ListModel.swift new file mode 100644 index 0000000..14bc88a --- /dev/null +++ b/100DaysOfSwiftUI/ListModel.swift @@ -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")] + } + +} diff --git a/100DaysOfSwiftUI/MyFirstView.swift b/100DaysOfSwiftUI/MyFirstView.swift new file mode 100644 index 0000000..522f035 --- /dev/null +++ b/100DaysOfSwiftUI/MyFirstView.swift @@ -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() + } +}