From 5b50e8cdd2b77811f976a8d893c1d6d9a6c15656 Mon Sep 17 00:00:00 2001 From: Alex Faber Date: Thu, 9 Jul 2020 20:31:37 +0200 Subject: [PATCH] OPT: Cleanup Add Folder view on Mac, change SceneNavigationView to support multiple sheet types. --- Multiplatform/Shared/Add/AddFolderView.swift | 20 ++++++++++++------- .../Shared/SceneNavigationView.swift | 20 ++++++++++++++----- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Multiplatform/Shared/Add/AddFolderView.swift b/Multiplatform/Shared/Add/AddFolderView.swift index d53b18a29..44152d382 100644 --- a/Multiplatform/Shared/Add/AddFolderView.swift +++ b/Multiplatform/Shared/Add/AddFolderView.swift @@ -71,22 +71,28 @@ struct AddFolderView: View { Form { HStack { Spacer() - Image("FaviconTemplateImage") + Image(rsImage: AppAssets.faviconTemplateImage) .resizable() .renderingMode(.template) .frame(width: 30, height: 30) - .foregroundColor(.accentColor).font(.title) Text("Add a Folder") .font(.title) Spacer() } - TextField("Name", text: $viewModel.folderName) - .textFieldStyle(RoundedBorderTextFieldStyle()) - .help("The name of the folder you want to create") - accountPicker - .help("Pick the account you want to create a folder in.") + + LazyVGrid(columns: [GridItem(.fixed(75), spacing: 10, alignment: .trailing),GridItem(.fixed(400), spacing: 0, alignment: .leading) ], alignment: .leading, spacing: 10, pinnedViews: [], content:{ + Text("Name:").bold() + TextField("Name", text: $viewModel.folderName) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .help("The name of the folder you want to create") + Text("Account:").bold() + accountPicker + .help("Pick the account you want to create a folder in.") + }) buttonStack } + .frame(maxWidth: 485) + .padding(12) } #endif diff --git a/Multiplatform/Shared/SceneNavigationView.swift b/Multiplatform/Shared/SceneNavigationView.swift index 0c90cf3d6..96cab8c76 100644 --- a/Multiplatform/Shared/SceneNavigationView.swift +++ b/Multiplatform/Shared/SceneNavigationView.swift @@ -11,7 +11,8 @@ import SwiftUI struct SceneNavigationView: View { @StateObject private var sceneModel = SceneModel() - @State private var showSheet = false + @State private var showSheet: Bool = false + @State private var sheetToShow: ToolbarSheets = .none #if os(iOS) @Environment(\.horizontalSizeClass) private var horizontalSizeClass @@ -49,18 +50,27 @@ struct SceneNavigationView: View { .onAppear { sceneModel.startup() } - .sheet(isPresented: $showSheet, onDismiss: { showSheet = false }) { - AddWebFeedView() + .sheet(isPresented: $showSheet, onDismiss: { sheetToShow = .none }) { + + if sheetToShow == .web { + AddWebFeedView() + } + if sheetToShow == .folder { + AddFolderView() + } + } + .onChange(of: sheetToShow) { value in + value != .none ? (showSheet = true) : (showSheet = false) } .toolbar { #if os(macOS) ToolbarItem() { Menu { - Button("Add Web Feed", action: { showSheet = true }) + Button("Add Web Feed", action: { sheetToShow = .web }) Button("Add Reddit Feed", action: { }) Button("Add Twitter Feed", action: { }) - Button("Add Folder", action: { }) + Button("Add Folder", action: { sheetToShow = .folder}) } label : { AppAssets.addMenuImage }