diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index 34c34c0..c67efba 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -1,27 +1,28 @@ import SwiftUI struct ContentView: View { @ObservedObject var postStore: PostStore var body: some View { NavigationView { PostList(postStore: postStore) .frame(maxHeight: .infinity) .navigationTitle("Posts") .toolbar { - NavigationLink(destination: PostEditor(post: Post()).environmentObject(self.postStore)) { + NavigationLink(destination: PostEditor(post: Post())) { Image(systemName: "plus") } } Text("Select a post, or create a new draft.") .foregroundColor(.secondary) } + .environmentObject(self.postStore) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView(postStore: testPostStore) } } diff --git a/Shared/Post/PostCell.swift b/Shared/Post/PostCell.swift index 86ea0b3..3696b0f 100644 --- a/Shared/Post/PostCell.swift +++ b/Shared/Post/PostCell.swift @@ -1,40 +1,40 @@ import SwiftUI struct PostCell: View { @EnvironmentObject var postStore: PostStore @ObservedObject var post: Post var body: some View { NavigationLink( - destination: PostEditor(post: post).environmentObject(self.postStore) + destination: PostEditor(post: post) ) { HStack { VStack(alignment: .leading) { Text(post.title) .font(.headline) .lineLimit(1) Text(buildDateString(from: post.createdDate)) .font(.caption) .foregroundColor(.secondary) .lineLimit(1) } Spacer() PostStatusBadge(post: post) } } } func buildDateString(from date: Date) -> String { let dateFormatter = DateFormatter() dateFormatter.dateStyle = .long dateFormatter.timeStyle = .short return dateFormatter.string(from: date) } } struct PostCell_Previews: PreviewProvider { static var previews: some View { PostCell(post: testPost) } } diff --git a/Shared/Post/PostList.swift b/Shared/Post/PostList.swift index 07bf01c..03d2b1c 100644 --- a/Shared/Post/PostList.swift +++ b/Shared/Post/PostList.swift @@ -1,21 +1,21 @@ import SwiftUI struct PostList: View { @ObservedObject var postStore: PostStore var body: some View { List { Text("\(postStore.posts.count) Posts") .foregroundColor(.secondary) ForEach(postStore.posts) { post in - PostCell(post: post).environmentObject(self.postStore) + PostCell(post: post) } } } } struct PostList_Previews: PreviewProvider { static var previews: some View { PostList(postStore: testPostStore) } } diff --git a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist index 6cd8075..2723ebe 100644 --- a/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/WriteFreely-MultiPlatform.xcodeproj/xcuserdata/angelo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -1,19 +1,19 @@ SchemeUserState WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_ orderHint - 1 + 0 WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_ orderHint - 0 + 1