Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/divadretlaw/emojitext
😃 Render Custom Emoji in Text
https://github.com/divadretlaw/emojitext
emoji markdown swift swiftui
Last synced: 6 days ago
JSON representation
😃 Render Custom Emoji in Text
- Host: GitHub
- URL: https://github.com/divadretlaw/emojitext
- Owner: divadretlaw
- License: apache-2.0
- Created: 2023-01-11T08:39:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-13T08:05:29.000Z (2 months ago)
- Last Synced: 2024-12-16T20:09:25.161Z (6 days ago)
- Topics: emoji, markdown, swift, swiftui
- Language: Swift
- Homepage:
- Size: 1.28 MB
- Stars: 68
- Watchers: 5
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EmojiText
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdivadretlaw%2FEmojiText%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/divadretlaw/EmojiText)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdivadretlaw%2FEmojiText%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/divadretlaw/EmojiText)Render Custom Emoji in `Text`. Supports local and remote emojis. Remote emojis are loaded and cached using [Nuke](https://github.com/kean/Nuke)
## Usage
Remote emoji
```swift
EmojiText(verbatim: "Hello :my_emoji:",
emojis: [RemoteEmoji(shortcode: "my_emoji", url: /* URL to emoji */)])
```Local emoji
```swift
EmojiText(verbatim: "Hello :my_emoji:",
emojis: [LocalEmoji(shortcode: "my_emoji", image: /* some UIImage or NSImage */)])
```SF Symbol
```swift
EmojiText(verbatim: "Hello Moon & Starts :moon.stars:",
emojis: [SFSymbolEmoji(shortcode: "moon.stars")])
```### Markdown
Also supports Markdown
```swift
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`.
```swift
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`
>
> ```swift
> 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
```swift
.emojiText.placeholder(systemName: /* SF Symbol */)
```or
```swift
.emojiText.placeholder(image: /* some UIImage or NSImage */)
```Remote emojis use `ImagePipeline.shared` from [Nuke](https://github.com/kean/Nuke) to load them, but you can provide a custom pipeline with
```swift
.environment(\.emojiText.imagePipeline, ImagePipeline())
```## License
See [LICENSE](LICENSE)