From 8b7940492a2352e92ee630af6eb8b424989aee64 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 29 Jun 2020 21:19:51 +0800 Subject: [PATCH] Mac Toolbar Placement of buttons is not quite right, but the search bar is in the right place! --- Multiplatform/Shared/MainApp.swift | 60 ++++++++++++++++++++++++ Multiplatform/macOS/MacSearchField.swift | 49 +++++++++++++++++++ NetNewsWire.xcodeproj/project.pbxproj | 4 ++ 3 files changed, 113 insertions(+) create mode 100644 Multiplatform/macOS/MacSearchField.swift diff --git a/Multiplatform/Shared/MainApp.swift b/Multiplatform/Shared/MainApp.swift index 7eecc4e6a..e97ce65b2 100644 --- a/Multiplatform/Shared/MainApp.swift +++ b/Multiplatform/Shared/MainApp.swift @@ -27,6 +27,66 @@ struct MainApp: App { SceneNavigationView() .frame(minWidth: 600, idealWidth: 1000, maxWidth: .infinity, minHeight: 600, idealHeight: 700, maxHeight: .infinity) .environmentObject(sceneModel) + .toolbar { + + + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "plus").foregroundColor(.secondary) + }).help("New Feed") + } + + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "folder.fill.badge.plus").foregroundColor(.pink) + }).help("New Folder") + } + + + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "arrow.clockwise").foregroundColor(.secondary) + }).help("Refresh").padding(.trailing, 40) + } + + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "circle.dashed").foregroundColor(.orange) + }).help("Mark All as Read") + } + + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "arrow.triangle.turn.up.right.circle.fill").foregroundColor(.purple) + }).help("Go to Next Unread") + } + + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "star.fill").foregroundColor(.yellow) + }).help("Mark as Starred") + } + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "checkmark.circle.fill").foregroundColor(.green) + }).help("Mark as Unread") + } + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "safari").foregroundColor(.blue) + }).help("Open in Browser") + } + ToolbarItem { + Button(action: {}, label: { + Image(systemName: "square.and.arrow.up") + }).help("Share") + } + + ToolbarItem { + MacSearchField() + .frame(width: 300) + } + } } .commands { CommandGroup(after: .newItem, addition: { diff --git a/Multiplatform/macOS/MacSearchField.swift b/Multiplatform/macOS/MacSearchField.swift new file mode 100644 index 000000000..2ae870735 --- /dev/null +++ b/Multiplatform/macOS/MacSearchField.swift @@ -0,0 +1,49 @@ +// +// MacSearchField.swift +// Multiplatform macOS +// +// Created by Stuart Breckenridge on 29/6/20. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import AppKit +import SwiftUI + + +final class MacSearchField: NSViewRepresentable { + + typealias NSViewType = NSSearchField + + + func makeNSView(context: Context) -> NSSearchField { + let searchField = NSSearchField() + searchField.delegate = context.coordinator + return searchField + } + + func updateNSView(_ nsView: NSSearchField, context: Context) { + + } + + func makeCoordinator() -> Coordinator { + Coordinator(self) + } + + class Coordinator: NSObject, NSSearchFieldDelegate { + var parent: MacSearchField + + init(_ parent: MacSearchField) { + self.parent = parent + } + + func searchFieldDidStartSearching(_ sender: NSSearchField) { + // + } + + func searchFieldDidEndSearching(_ sender: NSSearchField) { + // + } + + } + +} diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index ccbe0c24c..a07d48ba7 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 1729529424AA1CAA00D65E66 /* AdvancedPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */; }; 1729529524AA1CAA00D65E66 /* GeneralPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */; }; 1729529724AA1CD000D65E66 /* MacPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529624AA1CD000D65E66 /* MacPreferencesView.swift */; }; + 1729529B24AA1FD200D65E66 /* MacSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529A24AA1FD200D65E66 /* MacSearchField.swift */; }; 179DB1DFBCF9177104B12E0F /* AccountsNewsBlurWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */; }; 179DB3CE822BFCC2D774D9F4 /* AccountsNewsBlurWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */; }; 3B3A32A5238B820900314204 /* FeedWranglerAccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */; }; @@ -1669,6 +1670,7 @@ 1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvancedPreferencesView.swift; sourceTree = ""; }; 1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesView.swift; sourceTree = ""; }; 1729529624AA1CD000D65E66 /* MacPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacPreferencesView.swift; sourceTree = ""; }; + 1729529A24AA1FD200D65E66 /* MacSearchField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacSearchField.swift; sourceTree = ""; }; 179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsNewsBlurWindowController.swift; sourceTree = ""; }; 3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerAccountViewController.swift; sourceTree = ""; }; 3B826DB02385C84800FC1ADB /* AccountsFeedWrangler.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AccountsFeedWrangler.xib; sourceTree = ""; }; @@ -2607,6 +2609,7 @@ 51C0514724A77DF800194D5E /* macOS.entitlements */, 51C051CD24A7A6DB00194D5E /* macOS-dev.entitlements */, 51E4993924A8708800B667CB /* AppDelegate.swift */, + 1729529A24AA1FD200D65E66 /* MacSearchField.swift */, ); path = macOS; sourceTree = ""; @@ -4749,6 +4752,7 @@ 51E4990E24A808CC00B667CB /* HTMLMetadataDownloader.swift in Sources */, 51E498FB24A808BA00B667CB /* FaviconGenerator.swift in Sources */, 51E4996724A8760B00B667CB /* ArticleStylesManager.swift in Sources */, + 1729529B24AA1FD200D65E66 /* MacSearchField.swift in Sources */, 51408B7F24A9EC6F0073CF4E /* SidebarItem.swift in Sources */, 51E4996E24A8764C00B667CB /* ActivityManager.swift in Sources */, 51E4995A24A873F900B667CB /* ErrorHandler.swift in Sources */,