EmojiText

4.0.0

😃 Render Custom Emoji in Text
divadretlaw/EmojiText

What's New

4.0.0

2024-02-04T12:21:49Z

What's Changed

  • Refactored Emoji Rendering
  • Now uses Swift Markdown to inject emojis in Markdown
  • LocalEmoji now supports overriding the color
  • Further default placeholder improvements
  • Swift Concurrency Improvements
  • Removed Support for Swift 5.8 or older
  • Minor API changes
    • Removed deprecations introduced in older version
    • Added deprecations where possible to migrate to new API

Full Changelog: 3.6.0...4.0.0

EmojiText

Render Custom Emoji in Text. Supports local and remote emojis. Remote emojis are loaded and cached using Nuke

Usage

Remote emoji

EmojiText(verbatim: "Hello :my_emoji:",
          emojis: [RemoteEmoji(shortcode: "my_emoji", url: /* URL to emoji */)])

Local emoji

EmojiText(verbatim: "Hello :my_emoji:",
          emojis: [LocalEmoji(shortcode: "my_emoji", image: /* some UIImage or NSImage */)])

SF Symbol

EmojiText(verbatim: "Hello Moon & Starts :moon.stars:",
          emojis: [SFSymbolEmoji(shortcode: "moon.stars")])

Markdown

Also supports Markdown

EmojiText(markdown: "**Hello** *World* :my_emoji:",
          emojis: [RemoteEmoji(shortcode: "my_emoji", url: /* URL to emoji */)])

Animated Emoji

Warning

This feature is in beta and therefore is opt-in only. Performance may vary.

Currently only UIKit platforms support animated emoji.

Enable animation by setting adding the .animated() modifier to EmojiText.

EmojiText(verbatim: "GIF :my_gif:",
          emojis: [RemoteEmoji(shortcode: "my_gif", url: /* URL to gif */)])
    .animated()

Supported formats:

  • APNG
  • GIF
  • WebP

[!INFO] The animation will automatically pause when using low-power mode. To always play animations, even in low-power mode set the animation mode to AnimatedEmojiMode.always

EmojiText(verbatim: "GIF :my_gif:",
          emojis: [RemoteEmoji(shortcode: "my_gif", url:  /* URL to gif */)])
  .animated()
  .environment(\.emojiText.AnimatedMode, .always)

Configuration

Remote emojis are replaced by a placeholder image when loading. Default is the SF Symbol square.dashed but you can overide the placeholder image with

.emojiText.placeholder(systemName: /* SF Symbol */)

or

.emojiText.placeholder(image: /* some UIImage or NSImage */)

Remote emojis use ImagePipeline.shared from Nuke to load them, but you can provide a custom pipeline with

.environment(\.emojiText.imagePipeline, ImagePipeline())

License

See LICENSE

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Tue Apr 09 2024 04:13:22 GMT-0900 (Hawaii-Aleutian Daylight Time)