diff --git a/brain-marks.xcodeproj/project.pbxproj b/brain-marks.xcodeproj/project.pbxproj index 4ae0c84..20a94f0 100644 --- a/brain-marks.xcodeproj/project.pbxproj +++ b/brain-marks.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 91C8958926228D1500689196 /* Tweet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91C8958826228D1500689196 /* Tweet.swift */; }; + A205CD422622A3EB00517DB5 /* TweetList.swift in Sources */ = {isa = PBXBuildFile; fileRef = A205CD412622A3EB00517DB5 /* TweetList.swift */; }; A2F4498C2622802B00725FEA /* CategoryRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2F4498B2622802B00725FEA /* CategoryRow.swift */; }; A2F449912622829D00725FEA /* CategoryList.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2F449902622829D00725FEA /* CategoryList.swift */; }; A2F449A22622883E00725FEA /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2F449A12622883E00725FEA /* Category.swift */; }; @@ -39,6 +40,7 @@ /* Begin PBXFileReference section */ 91C8958826228D1500689196 /* Tweet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tweet.swift; sourceTree = ""; }; + A205CD412622A3EB00517DB5 /* TweetList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TweetList.swift; sourceTree = ""; }; A2F4498B2622802B00725FEA /* CategoryRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryRow.swift; sourceTree = ""; }; A2F449902622829D00725FEA /* CategoryList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryList.swift; sourceTree = ""; }; A2F449A12622883E00725FEA /* Category.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = ""; }; @@ -119,6 +121,7 @@ FFEBBB3B26223F75000F475F /* ContentView.swift */, A2F4498B2622802B00725FEA /* CategoryRow.swift */, A2F449902622829D00725FEA /* CategoryList.swift */, + A205CD412622A3EB00517DB5 /* TweetList.swift */, FFEBBB3D26223F7E000F475F /* Assets.xcassets */, FFEBBB4226223F7E000F475F /* Info.plist */, FFEBBB3F26223F7E000F475F /* Preview Content */, @@ -310,6 +313,7 @@ A2F4498C2622802B00725FEA /* CategoryRow.swift in Sources */, FFEBBB3A26223F75000F475F /* brain_marksApp.swift in Sources */, A2F449A22622883E00725FEA /* Category.swift in Sources */, + A205CD422622A3EB00517DB5 /* TweetList.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/brain-marks/CategoryList.swift b/brain-marks/CategoryList.swift index 456fb71..1fb3e8c 100644 --- a/brain-marks/CategoryList.swift +++ b/brain-marks/CategoryList.swift @@ -12,8 +12,13 @@ struct CategoryList: View { var categories: [Category] var body: some View { - List(categories) { category in - CategoryRow(category: category) + NavigationView { + List(categories) { category in + NavigationLink(destination: TweetList(category: category)) { + CategoryRow(category: category) + } + } + .navigationTitle("Categories") } } } diff --git a/brain-marks/TweetList.swift b/brain-marks/TweetList.swift new file mode 100644 index 0000000..60ffab4 --- /dev/null +++ b/brain-marks/TweetList.swift @@ -0,0 +1,41 @@ +// +// TweetList.swift +// brain-marks +// +// Created by Shloak Aggarwal on 11/04/21. +// + +import SwiftUI + +struct TweetList: View { + var category: Category + + var body: some View { + + List { + Text("This is a tweet!") + } + .toolbar { + ToolbarItem(placement: .principal) { + HStack { + Image(systemName: category.imageName) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 25, height: 25) + Text(category.name) + } + } + } + + Spacer() + } +} + +struct TweetList_Previews: PreviewProvider { + static var previews: some View { + TweetList(category: Category(id: 0, + name: "SwiftUI", + numberOfTweets: 3, + imageName: "swift")) + } +}