comparison 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
comparison
equal deleted inserted replaced
411:b018386653c2 412:7c6149c249c1
14 # You should have received a copy of the GNU Affero General Public License 14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16
17 #:import _ sat.core.i18n._ 17 #:import _ sat.core.i18n._
18 #:import C cagou.core.constants.Const 18 #:import C cagou.core.constants.Const
19 #:import G cagou.G
19 #:import escape kivy.utils.escape_markup 20 #:import escape kivy.utils.escape_markup
20 #:import SimpleXHTMLWidget cagou.core.simple_xhtml.SimpleXHTMLWidget 21 #:import SimpleXHTMLWidget cagou.core.simple_xhtml.SimpleXHTMLWidget
21 #:import DelayedBoxLayout cagou.core.common_widgets.DelayedBoxLayout 22 #:import DelayedBoxLayout cagou.core.common_widgets.DelayedBoxLayout
22 #:import ScrollEffect kivy.effects.scroll.ScrollEffect 23 #:import ScrollEffect kivy.effects.scroll.ScrollEffect
23 #:import CategorySeparator cagou.core.common_widgets.CategorySeparator 24 #:import CategorySeparator cagou.core.common_widgets.CategorySeparator
27 28
28 29
29 <AttachmentItem>: 30 <AttachmentItem>:
30 size_hint: None, None 31 size_hint: None, None
31 size: self.minimum_width, dp(50) 32 size: self.minimum_width, dp(50)
33 canvas.before:
34 Color:
35 rgb: app.c_prim_dark
36 RoundedRectangle:
37 pos: self.pos
38 size: self.size
39 Color:
40 rgb: 1, 1, 1, 1
41 RoundedRectangle:
42 pos: self.x + dp(1), self.y + dp(1)
43 size: self.width - dp(2), self.height - dp(2)
44 Color:
45 rgb: app.c_sec_light
46 RoundedRectangle:
47 pos: self.x + dp(1), self.y + dp(1)
48 size: (self.width - dp(2)) * root.progress / 100, self.height - dp(2)
32 SymbolLabel: 49 SymbolLabel:
33 symbol: root.get_symbol(root.data) 50 symbol: root.get_symbol(root.data)
34 text: root.data.get('name', '') 51 color: 0, 0, 0, 1
52 text: root.data.get('name', _('unnamed'))
35 bold: False 53 bold: False
36 on_press: root.on_press() 54 on_press: root.on_press()
37 55
38 56
39 <AttachmentsLayout>: 57 <AttachmentsLayout>:
40 attachments: self 58 attachments: self
41 size_hint: 1, None 59 size_hint: 1, None
42 height: self.minimum_height 60 height: self.minimum_height
61 spacing: dp(5)
43 62
44 63
45 <MessAvatar>: 64 <MessAvatar>:
46 size_hint: None, None 65 size_hint: None, None
47 size: dp(30), dp(30) 66 size: dp(30), dp(30)
115 color: (0.74,0.74,0.24,1) if root.mess_type == "info" else (0, 0, 0, 1) 134 color: (0.74,0.74,0.24,1) if root.mess_type == "info" else (0, 0, 0, 1)
116 padding: root.mess_padding 135 padding: root.mess_padding
117 bold: True if root.mess_type == "info" else False 136 bold: True if root.mess_type == "info" else False
118 137
119 138
139 <AttachmentToSendItem>:
140 SymbolButton:
141 opacity: 0 if root.sending else 1
142 size_hint: None, 1
143 symbol: "cancel-circled"
144 on_press: root.parent.remove_widget(root)
145
146
147 <AttachmentsToSend>:
148 attachments: attachments_layout.attachments
149 orientation: "vertical"
150 size_hint: 1, None
151 height: self.minimum_height if self.attachments.children else 0
152 opacity: 1 if self.attachments.children else 0
153 padding: [app.MARGIN_LEFT, dp(5), app.MARGIN_RIGHT, dp(5)]
154 Label:
155 size_hint: 1, None
156 size: self.texture_size
157 text: _("attachments:")
158 bold: True
159 AttachmentsLayout:
160 id: attachments_layout
161 canvas.before:
162 Color:
163 rgba: app.c_prim
164 Rectangle:
165 pos: self.pos
166 size: self.size
167
168
120 <Chat>: 169 <Chat>:
170 attachments_to_send: attachments_to_send
121 message_input: message_input 171 message_input: message_input
122 messages_widget: messages_widget 172 messages_widget: messages_widget
123 history_scroll: history_scroll 173 history_scroll: history_scroll
124 ScrollView: 174 ScrollView:
125 id: history_scroll 175 id: history_scroll
134 size_hint_y: None 184 size_hint_y: None
135 padding: [app.MARGIN_LEFT, 0, app.MARGIN_RIGHT, dp(10)] 185 padding: [app.MARGIN_LEFT, 0, app.MARGIN_RIGHT, dp(10)]
136 spacing: dp(10) 186 spacing: dp(10)
137 height: self.minimum_height 187 height: self.minimum_height
138 orientation: 'vertical' 188 orientation: 'vertical'
189 AttachmentsToSend:
190 id: attachments_to_send
139 MessageInputBox: 191 MessageInputBox:
140 size_hint: 1, None 192 size_hint: 1, None
141 height: self.minimum_height 193 height: self.minimum_height
142 spacing: dp(10) 194 spacing: dp(10)
143 padding: [app.MARGIN_LEFT, 0, app.MARGIN_RIGHT, dp(10)] 195 padding: [app.MARGIN_LEFT, 0, app.MARGIN_RIGHT, dp(10)]