diff cagou/plugins/plugin_wid_chat.kv @ 413:c466678c57b2

chat: control send button visibility in core.platform_, and show it when there are attachments
author Goffi <goffi@goffi.org>
date Sun, 23 Feb 2020 15:39:06 +0100
parents 7c6149c249c1
children 3e2333a11f61
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.kv	Sun Feb 23 15:39:03 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.kv	Sun Feb 23 15:39:06 2020 +0100
@@ -171,6 +171,7 @@
     message_input: message_input
     messages_widget: messages_widget
     history_scroll: history_scroll
+    send_button_visible: G.local_platform.send_button_visible or bool(attachments_to_send.attachments.children)
     ScrollView:
         id: history_scroll
         scroll_y: 0
@@ -201,15 +202,15 @@
             multiline: True
             hint_text: _(u"Enter your message here")
             on_text_validate: root.onSend(args[0])
-
+        SymbolButton:
+            # "send" button, permanent visibility depends on platform
+            symbol: "forward"
+            size_hint: None, 1
+            width: dp(30) if root.send_button_visible else 0
+            opacity: 1 if root.send_button_visible else 0
+            font_size: dp(25)
+            on_release: self.parent.send_text()
 
-<SendButton>:
-    # SendButton is only shown on touch devices
-    symbol: "forward"
-    size_hint: None, 1
-    width: dp(30)
-    font_size: dp(25)
-    on_release: self.message_input_box.send_text()
 
 # Buttons added in header