Snackbar¶
Screenshot¶
Example¶
from enamlnative.widgets.api import *
from enamlnative.android.app import AndroidApplication
enamldef ContentView(CoordinatorLayout):
attr app = AndroidApplication.instance()
Flexbox:
flex_direction = "column"
width = 'match_parent'
Button:
text = "Show snackbar"
clicked :: sb.show = True
TextView:
text << "Snackbar state: {}".format("active" if sb.show else "hidden")
TextView: tv:
attr action = ""
text << "Snackbar action: {}".format(self.action)
Button:
text = "Show snackbar with action"
clicked :: sb2.show = True
Snackbar: sb:
duration = 4000
text = "Cheers!"
Snackbar: sb2:
text = "Email deleted"
action_text = "Undo"
clicked :: app.show_toast("action clicked!")
action :: tv.action = change['value']
Declaration¶
- class enamlnative.widgets.snackbar.Snackbar(parent=None, **kwargs)[source]¶
Bases:
enaml.widgets.toolkit_object.ToolkitObject
A toast is a view containing a quick little message for the user.
- text¶
Text to display if this node has a child view this is ignored
- action_text¶
Text to display in the action button
- action_text_color¶
Color for the action text button
- duration¶
Duration to display in ms or 0 for infinite
- clicked¶
Alias for the action is clicked
- action¶
When an action occurs such as swiped out, clicked, timed out, etc..
- show¶
Show the snackbar for the given duration
- proxy¶
A reference to the proxy object.
Android Implementation¶
- class enamlnative.android.android_snackbar.AndroidSnackbar[source]¶
Bases:
enamlnative.android.android_toolkit_object.AndroidToolkitObject
,enamlnative.widgets.snackbar.ProxySnackbar
An Android implementation of an Enaml ProxySnackbar.
- widget¶
A reference to the widget created by the proxy.
- create_widget()[source]¶
Create the underlying widget.
A toast is not a subclass of view, hence we don’t set name as widget or children will try to use it as their parent (which crashes).
- init_widget()[source]¶
Our widget may not exist yet so we have to diverge from the normal way of doing initialization. See update_widget
No iOS implementation found.