diff --git a/Shared/Navigation/SidebarView.swift b/Shared/Navigation/SidebarView.swift index dadd91d..88df9b9 100644 --- a/Shared/Navigation/SidebarView.swift +++ b/Shared/Navigation/SidebarView.swift @@ -1,35 +1,15 @@ import SwiftUI struct SidebarView: View { @State var isPresentingSettings = false var body: some View { - #if os(iOS) - VStack { - CollectionListView() - Spacer() - Button(action: { - isPresentingSettings = true - }, label: { - Text("Settings") - }).sheet( - isPresented: $isPresentingSettings, - onDismiss: { - isPresentingSettings = false - }, - content: { - SettingsView(isPresented: $isPresentingSettings) - } - ) - } - #else CollectionListView() - #endif } } struct SidebarView_Previews: PreviewProvider { static var previews: some View { SidebarView() } } diff --git a/Shared/Post/PostList.swift b/Shared/Post/PostList.swift index 8577636..2682b9f 100644 --- a/Shared/Post/PostList.swift +++ b/Shared/Post/PostList.swift @@ -1,91 +1,104 @@ import SwiftUI struct PostList: View { @EnvironmentObject var postStore: PostStore @State var selectedCollection: PostCollection + @State var isPresentingSettings = false var body: some View { #if os(iOS) List { ForEach(showPosts(for: selectedCollection)) { post in NavigationLink( destination: PostEditor(post: post) ) { PostCell( post: post ) } } } .navigationTitle(selectedCollection.title) .toolbar { ToolbarItem(placement: .primaryAction) { Button(action: { let post = Post() postStore.add(post) }, label: { Image(systemName: "square.and.pencil") }) } ToolbarItem(placement: .bottomBar) { - Spacer() + Button(action: { + isPresentingSettings = true + }, label: { + Image(systemName: "gear") + }).sheet( + isPresented: $isPresentingSettings, + onDismiss: { + isPresentingSettings = false + }, + content: { + SettingsView(isPresented: $isPresentingSettings) + } + ) } ToolbarItem(placement: .bottomBar) { - Text(pluralizedPostCount(for: showPosts(for: selectedCollection))) + Spacer() } ToolbarItem(placement: .bottomBar) { - Spacer() + Text(pluralizedPostCount(for: showPosts(for: selectedCollection))) } } #else //if os(macOS) List { ForEach(showPosts(for: selectedCollection)) { post in NavigationLink( destination: PostEditor(post: post) ) { PostCell( post: post ) } } } .navigationTitle(selectedCollection.title) .navigationSubtitle(pluralizedPostCount(for: showPosts(for: selectedCollection))) .toolbar { Button(action: { let post = Post() postStore.add(post) }, label: { Image(systemName: "square.and.pencil") }) } #endif } private func pluralizedPostCount(for posts: [Post]) -> String { if posts.count == 1 { return "1 post" } else { return "\(posts.count) posts" } } private func showPosts(for collection: PostCollection) -> [Post] { if collection == allPostsCollection { return postStore.posts } else { return postStore.posts.filter { $0.collection.title == collection.title } } } } struct PostList_Previews: PreviewProvider { static var previews: some View { Group { PostList(selectedCollection: allPostsCollection) .environmentObject(testPostStore) } } } diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index f82ce57..daed735 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -1,25 +1,25 @@ import SwiftUI struct SettingsView: View { @Binding var isPresented: Bool var body: some View { VStack { SettingsHeaderView(isPresented: $isPresented) Form { - Section(header: Text("Account")) { + Section(header: Text("Login Details")) { AccountView() } Section(header: Text("Appearance")) { PreferencesView() } } } } } struct SettingsView_Previews: PreviewProvider { static var previews: some View { SettingsView(isPresented: .constant(true)) } }