Skip to content

tddworks/EmojiPicker

 
 

Repository files navigation

EmojiPicker

This Swift package allows you to show a view with all available emoji on the OS, navigate through the list of emojis and categories, search for emojis based on keywords, and select an emoji.

Screenshots

Emoji list Emoji search Emoji settings
Emoji list Emoji search Emoji settings

Macos Screenshots

Emoji list Emoji search
Emoji preview Emoji mac popover

Dependencies

Installation

EmojiPicker can be integrated as an Xcode project target or a Swift package target.

Xcode Project Target

  1. Go to File -> Add Package Dependencies.
  2. Type https://github.com/tyiu/EmojiPicker.git into the search field.
  3. Select EmojiPicker from the search results.
  4. Select Up to Next Major Version starting from the latest release as the dependency rule.
  5. Ensure your project is selected next to Add to Project.
  6. Click Add Package.
  7. On the package product dialog, add EmojiPicker to your target and click Add Package.

Swift Package Target

In your Package.swift file:

  1. Add the EmojiPicker package dependency to https://github.com/tyiu/EmojiPicker.git
  2. Add EmojiPicker as a dependency on the targets that need to use the SDK.
let package = Package(
    // ...
    dependencies: [
        // ...
        .package(url: "https://github.com/tyiu/EmojiPicker.git", .upToNextMajor(from: "0.1.1"))
    ],
    targets: [
        .target(
            // ...
            dependencies: ["EmojiPicker"]
        ),
        .testTarget(
            // ...
            dependencies: ["EmojiPicker"]
        )
    ]
)

Usage

Import EmojiPicker in the file you want to use it in:

import EmojiPicker

Then add EmojiPickerView as a view. Here is a complete example:

import SwiftUI
import EmojiPicker
import EmojiKit

struct ContentView: View {

    @State
    var selectedEmoji: Emoji?

    @State
    var displayEmojiPicker: Bool = false

    var body: some View {
        VStack {
            VStack {
                Text(selectedEmoji?.value ?? "")
                    .font(.largeTitle)
                Text(selectedEmoji?.localizedKeywords["en"]?.joined(separator: ", ") ?? "")
                    .font(.title3)
            }
            .padding(8)
            Button {
                displayEmojiPicker = true
            } label: {
                Text("Select standard emoji")
            }
            .buttonStyle(.borderedProminent)
        }
        .padding()
        .sheet(isPresented: $displayEmojiPicker) {
            NavigationView {
                EmojiPickerView(selectedEmoji: $selectedEmoji)
                    .padding(.top, 32)
                    .navigationTitle("Emojis")
                    .navigationBarTitleDisplayMode(.inline)
            }
        }
    }

}

Samples

You can access to sample project on folder EmojiPickerSample

Acknowledgements

This Swift package was forked from Kelvas09/EmojiPicker.

About

Display emoji picker on SwiftUI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%