Mac Toolbar

Placement of buttons is not quite right, but the search bar is in the right place!
This commit is contained in:
Stuart Breckenridge 2020-06-29 21:19:51 +08:00
parent 1f6f5fa054
commit 8b7940492a
3 changed files with 113 additions and 0 deletions

View File

@ -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: {

View File

@ -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) {
//
}
}
}

View File

@ -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 = "<group>"; };
1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesView.swift; sourceTree = "<group>"; };
1729529624AA1CD000D65E66 /* MacPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MacPreferencesView.swift; sourceTree = "<group>"; };
1729529A24AA1FD200D65E66 /* MacSearchField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacSearchField.swift; sourceTree = "<group>"; };
179DBBA2B22A659F81EED6F9 /* AccountsNewsBlurWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsNewsBlurWindowController.swift; sourceTree = "<group>"; };
3B3A328B238B820900314204 /* FeedWranglerAccountViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedWranglerAccountViewController.swift; sourceTree = "<group>"; };
3B826DB02385C84800FC1ADB /* AccountsFeedWrangler.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AccountsFeedWrangler.xib; sourceTree = "<group>"; };
@ -2607,6 +2609,7 @@
51C0514724A77DF800194D5E /* macOS.entitlements */,
51C051CD24A7A6DB00194D5E /* macOS-dev.entitlements */,
51E4993924A8708800B667CB /* AppDelegate.swift */,
1729529A24AA1FD200D65E66 /* MacSearchField.swift */,
);
path = macOS;
sourceTree = "<group>";
@ -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 */,