Swiftpack.co - francisfeng/SymbolPicker as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
francisfeng/SymbolPicker
A SF Symbols picker for Mac apps. Built with AppKit.
.package(url: "https://github.com/francisfeng/SymbolPicker.git", from: "0.1.1")

Symbol Picker

A SF Symbols picker for Mac apps. Built with AppKit.

Compatibility

  • macOS 11.0+

Install

Add https://github.com/francisfeng/SymbolPicker in the “Swift Package Manager” tab in Xcode.

Usage

screenshot of Symbol Picker

  1. AppKit

// in your NSViewController subclass
import SymbolPicker

@objc func pickIcon(_ sender: NSMenuItem) {
  if let windowController = SymbolPicker.windowController(
      symbol: collection.symbol,
      color: collection.color ?? .labelColor,
      delegate: self,
      title: collection.name),
     let iconSheet = windowController.window {
    
    // You need to persist this windowController in your app.
    symbolPickerWindowController = windowController
    
    window.beginSheet(iconSheet) {
      _ in
      self.symbolPickerWindowController = nil
    }
  }
}

extension ViewController: SymbolPickerDelegate {
  func symbolPicker(_ symbol: String, color: NSColor?) {
  
  }
}
  1. SwiftUI

I haven't try it with SwiftUI yet. Any contributions will be welcome.

Known Issues

  1. Memory footprint will go up everytime the window is presented and dimissed. Too much work has went into it and I think it's now acceptable after a few symbol selections. Any contributions will be welcome.

  2. The app can't be presented like a modal dialog. I don't know why. Any help will be appreciated. To mimic the experience, the window is not movable or resizable. You may also want to implement click-outside to dismiss in your app. You can do this by overriding func mouseDown(with: NSEvent) in your NSWindowController subclass.

override func mouseDown(with event: NSEvent) {
  super.mouseDown(with: event)
  if let sheetwindow = window?.attachedSheet {
    window?.endSheet(sheetwindow)
  }
}

Lisense

MIT

GitHub

link
Stars: 2
Last commit: 3 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics