diff cagou/plugins/plugin_wid_chat.kv @ 412:7c6149c249c1

chat: attachment sending: - files to send are not sent directly anymore, but added to attachment, and linked to the message when it is sent, this is more user friendly and avoid the accidental sending of wrong file - user can remove the attachment before sending the message, using the "close" symbol - new "Chat.addAtachment" method - upload progress is shown on the AttachmentItem thanks to the "progress" property - AttachmentItem stays in the attachments layout until uploaded or an error happens. Messages can still be sent while the item is being uploaded.
author Goffi <goffi@goffi.org>
date Sun, 23 Feb 2020 15:39:03 +0100
parents b018386653c2
children c466678c57b2
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.kv	Sat Feb 22 18:34:09 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.kv	Sun Feb 23 15:39:03 2020 +0100
@@ -16,6 +16,7 @@
 
 #:import _ sat.core.i18n._
 #:import C cagou.core.constants.Const
+#:import G cagou.G
 #:import escape kivy.utils.escape_markup
 #:import SimpleXHTMLWidget cagou.core.simple_xhtml.SimpleXHTMLWidget
 #:import DelayedBoxLayout cagou.core.common_widgets.DelayedBoxLayout
@@ -29,9 +30,26 @@
 <AttachmentItem>:
     size_hint: None, None
     size: self.minimum_width, dp(50)
+    canvas.before:
+        Color:
+            rgb: app.c_prim_dark
+        RoundedRectangle:
+            pos: self.pos
+            size: self.size
+        Color:
+            rgb: 1, 1, 1, 1
+        RoundedRectangle:
+            pos: self.x + dp(1), self.y + dp(1)
+            size: self.width - dp(2), self.height - dp(2)
+        Color:
+            rgb: app.c_sec_light
+        RoundedRectangle:
+            pos: self.x + dp(1), self.y + dp(1)
+            size: (self.width - dp(2)) * root.progress / 100, self.height - dp(2)
     SymbolLabel:
         symbol: root.get_symbol(root.data)
-        text: root.data.get('name', '')
+        color: 0, 0, 0, 1
+        text: root.data.get('name', _('unnamed'))
         bold: False
         on_press: root.on_press()
 
@@ -40,6 +58,7 @@
     attachments: self
     size_hint: 1, None
     height: self.minimum_height
+    spacing: dp(5)
 
 
 <MessAvatar>:
@@ -117,7 +136,38 @@
             bold: True if root.mess_type == "info" else False
 
 
+<AttachmentToSendItem>:
+    SymbolButton:
+        opacity: 0 if root.sending else 1
+        size_hint: None, 1
+        symbol: "cancel-circled"
+        on_press: root.parent.remove_widget(root)
+
+
+<AttachmentsToSend>:
+    attachments: attachments_layout.attachments
+    orientation: "vertical"
+    size_hint: 1, None
+    height: self.minimum_height if self.attachments.children else 0
+    opacity: 1 if self.attachments.children else 0
+    padding: [app.MARGIN_LEFT, dp(5), app.MARGIN_RIGHT, dp(5)]
+    Label:
+        size_hint: 1, None
+        size: self.texture_size
+        text: _("attachments:")
+        bold: True
+    AttachmentsLayout:
+        id: attachments_layout
+        canvas.before:
+            Color:
+                rgba: app.c_prim
+            Rectangle:
+                pos: self.pos
+                size: self.size
+
+
 <Chat>:
+    attachments_to_send: attachments_to_send
     message_input: message_input
     messages_widget: messages_widget
     history_scroll: history_scroll
@@ -136,6 +186,8 @@
             spacing: dp(10)
             height: self.minimum_height
             orientation: 'vertical'
+    AttachmentsToSend:
+        id: attachments_to_send
     MessageInputBox:
         size_hint: 1, None
         height: self.minimum_height