impleneted chatroom UI

This commit is contained in:
navjot 2020-04-21 23:03:38 +05:30
parent c70d9c8952
commit 130c63f226
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
4 changed files with 176 additions and 1 deletions

View File

@ -0,0 +1,52 @@
<ChatList>:
name: 'chlist'
MDTabs:
id: chat_panel
tab_display_mode:'text'
Tab:
text: "Chats"
BoxLayout:
id: chat_box
orientation: 'vertical'
ScrollView:
id: scroll_y
do_scroll_x: False
MDList:
id: ml
MDLabel:
font_style: 'Caption'
theme_text_color: 'Primary'
text: 'No Chat'
halign: 'center'
size_hint_y: None
bold: True
valign: 'top'
# OneLineAvatarListItem:
# text: "Single-line item with avatar"
# divider: None
# _no_ripple_effect: True
# ImageLeftWidget:
# source: './images/text_images/A.png'
# OneLineAvatarListItem:
# text: "Single-line item with avatar"
# divider: None
# _no_ripple_effect: True
# ImageLeftWidget:
# source: './images/text_images/B.png'
# OneLineAvatarListItem:
# text: "Single-line item with avatar"
# divider: None
# _no_ripple_effect: True
# ImageLeftWidget:
# source: './images/text_images/A.png'
Tab:
text: "Contacts"
BoxLayout:
id: contact_box
orientation: 'vertical'
ScrollView:
id: scroll_y
do_scroll_x: False
MDList:
id: ml

View File

@ -0,0 +1,40 @@
#:import C kivy.utils.get_color_from_hex
<ChatRoom>:
name: 'chroom'
BoxLayout:
orientation: 'vertical'
ScrollView:
Label:
id: chat_logs
text: ''
color: C('#101010')
text_size: (self.width, None)
halign: 'left'
valign: 'top'
padding: (0, 0) # fixed in Kivy 1.8.1
size_hint: (1, None)
height: self.texture_size[1]
markup: True
font_size: sp(20)
BoxLayout:
height: 50
orientation: 'horizontal'
padding: 0
size_hint: (1, None)
TextInput:
id: message
size_hint: (1, 1)
multiline: False
font_size: sp(20)
on_text_validate: root.send_msg()
MDRaisedButton:
text: "Send"
elevation_normal: 2
opposite_colors: True
size_hint: (0.3, 1)
pos_hint: {"center_x": .5}
on_press: root.send_msg()

View File

@ -155,6 +155,13 @@
on_release: app.root.ids.scr_mngr.current = 'allmails'
on_release: root.parent.set_state()
on_press: app.load_screen(self)
NavigationItem:
id: chat_rm
text: 'Chat Room'
icon: 'wechat'
divider: None
on_release: app.root.ids.scr_mngr.current = 'chlist'
on_release: root.parent.set_state()
NavigationDrawerDivider:
NavigationDrawerSubheader:
text: "All labels"
@ -260,6 +267,10 @@ NavigationLayout:
id:sc19
Archieve:
id:sc20
ChatRoom:
id:sc21
ChatList:
id:sc22
MDNavigationDrawer:
id: nav_drawer

View File

@ -73,7 +73,8 @@ KVFILES = [
'settings', 'popup', 'allmails', 'draft',
'maildetail', 'common_widgets', 'addressbook',
'myaddress', 'composer', 'payment', 'sent',
'network', 'login', 'credits', 'trash', 'inbox'
'network', 'login', 'credits', 'trash', 'inbox',
'chat_room', 'chat_list'
]
@ -3018,3 +3019,74 @@ class ToAddrBoxlayout(BoxLayout):
class RandomBoxlayout(BoxLayout):
"""class for BoxLayout behaviour"""
pass
def esc_markup(msg):
return (msg.replace('&', '&amp;')
.replace('[', '&bl;')
.replace(']', '&br;'))
class ChatRoom(Screen):
"""class for chatroom screen"""
def send_msg(self):
"""This method is for sending message"""
msg = self.ids.message.text
if msg:
self.ids.chat_logs.text += (
'[b][color=2980b9]{}:[/color][/b] {}\n'
.format('Me', esc_markup(msg)))
# obj = MDChip(label=msg, radius=7)
# obj.icon = ''
# self.ids.ml.add_widget(obj)
self.ids.message.text = ''
class ChatList(Screen):
"""class for showing chat list"""
queryreturn = ListProperty()
has_refreshed = True
def __init__(self, *args, **kwargs):
"""Getting ChatList Details"""
super(ChatList, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0):
"""Clock Schdule for method ChatList"""
self.loadAddresslist(None, 'All', '')
print(dt)
def loadAddresslist(self, account="", where="", what=""):
"""Clock Schdule for method ChatList"""
self.queryreturn = kivy_helper_search.search_sql(
'', account, "addressbook", where, what, False)
self.queryreturn = [obj for obj in reversed(self.queryreturn)]
if self.queryreturn:
self.set_mdList()
else:
content = MDLabel(
font_style='Caption',
theme_text_color='Primary',
text="No contact found!",
halign='center',
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content)
def set_mdList(self):
"""Creating the mdList"""
for item in self.queryreturn:
meny = TwoLineAvatarIconListItem(
text=item[0], secondary_text=item[1], theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item[0].strip()))))
# meny.bind(on_press=self.redirect_on_chat())
meny.bind(on_press=partial(
self.redirect_on_chat,))
self.ids.ml.add_widget(meny)
def redirect_on_chat(self, *args):
self.manager.current = 'chroom'