vanniktech / Emoji

A library to add Emoji support to your Android / iOS / JVM Application
Apache License 2.0
1.55k stars 292 forks source link

Integration with Jetpack Compose ? #690

Open noe opened 2 years ago

noe commented 2 years ago

Is it possible to integrate Emoji with Jetpack Compose? If so, how? If not, is it planned?

vanniktech commented 2 years ago

Currently not. Probably similar to emoji-material there should be a emoji-compose library module which has compose support

PGautam27 commented 2 years ago

It's possible now. I've used it in few application. You don't typically need any dependency for that. And Also I'll add up a bit of code how to convert the unicode to emotes using the function.

The code to convert unicode to emote. String(Character.toChars(/ur unicode/))

@Composable fun Smily() { Column( verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxSize() ) { Text(text = String(Character.toChars(0x1F642)), fontSize = 100.sp) } }

Screenshot 2022-06-16 133639

frhnfrq commented 2 years ago

I am trying to use the EmojiView in Jetpack like this,

val view = LocalView.current
AndroidView(factory = { context ->
                EmojiView(context).apply {
                    setUp(
                        onEmojiClickListener = { emoji ->
                            Log.d("emoji", emoji.unicode)
                        },
                        rootView = view,
                        editText = null,
                        onEmojiBackspaceClickListener = null
                    )
                }
            }, modifier = Modifier.weight(1f).fillMaxWidth())

Getting this error android.view.InflateException: Binary XML file line #2 in com.qwillio.vendi:layout/emoji_view_category: Binary XML file line #2 in com.qwillio.vendi:layout/emoji_view_category: Error inflating class android.widget.ImageButton Caused by: android.view.InflateException: Binary XML file line #2 in com.qwillio.vendi:layout/emoji_view_category: Error inflating class android.widget.ImageButton Caused by: java.lang.reflect.InvocationTargetException

how to properly use EmojiView in Jetpack compose? @vanniktech

dessalines commented 1 year ago

How do we use this in jetpack compose?

artemptushkin commented 6 months ago

any update here? I'm just trying to add the library to a KMP app and in the common compose module it's not available though in others it is