Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug that prevented custom emoji from being redrawn #16

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

mironal
Copy link
Contributor

@mironal mironal commented Sep 21, 2023

I have found a bug that sometimes "loadEmojis()" is not called when a redraw occurs while displaying a placeholder anymore, so the placeholder remains.

I am attaching a video as it can be easily reproduced by changing the emojiSize fast with "animated()" enabled.

example code

import SwiftUI
import EmojiText

struct ContentView: View {
    @State private var size: CGFloat = 20
    var body: some View {
        VStack {
            Slider(value: $size, in: 10...100, step: 0.05)
            Spacer()
            EmojiText(
                markdown: "PNG :emoji: AAA :large:",
                emojis: [
                    RemoteEmoji(
                        shortcode: "emoji",
                        url: .init(string: "https://files.mastodon.social/custom_emojis/images/000/003/675/original/089aaae26a2abcc1.png")!
                    ),
                    RemoteEmoji(
                        shortcode: "large",
                        url: .init(string: "https://s3.fedibird.com/custom_emojis/images/000/358/023/static/5fe65ba070089507.png")!
                    )
                ]
            )
            .animated()
            .emojiSize(size)
            .font(.system(size: size))
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

Before

The placeholder has continued to remain.

loadEmoji-before-fix.mp4

Fixed

loadEmoji-fixed.mov

@divadretlaw divadretlaw merged commit 59e6b92 into divadretlaw:main Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants