Sha256: fe06a4a1c243fd18de9f0ee3e4fdd38adb2671109e26cf7749117a10e1238312
Contents?: true
Size: 1.18 KB
Versions: 18
Compression:
Stored size: 1.18 KB
Contents
package <%= package_name %>.strada import android.util.Log import androidx.fragment.app.Fragment import com.google.android.material.snackbar.Snackbar import dev.hotwire.strada.BridgeComponent import dev.hotwire.strada.BridgeDelegate import dev.hotwire.strada.Message import <%= package_name %>.base.NavDestination import kotlinx.serialization.Serializable class FlashMessageComponent( name: String, private val delegate: BridgeDelegate<NavDestination> ) : BridgeComponent<NavDestination>(name, delegate) { private val fragment: Fragment get() = delegate.destination.fragment override fun onReceive(message: Message) { if (message.event == "connect") { handleConnectEvent(message) } else { Log.w("TurboNative", "Unknown event for message: $message") } } private fun handleConnectEvent(message: Message) { val data = message.data<MessageData>() ?: return showSnackBar(data) } private fun showSnackBar(data: MessageData) { Snackbar.make(fragment.requireView(), data.title, Snackbar.LENGTH_SHORT).show() } @Serializable data class MessageData( val title: String ) }
Version data entries
18 entries across 9 versions & 1 rubygems