Add Chat screen

This commit is contained in:
osamacis 2022-12-15 20:01:41 +05:30
parent 7ee2217c4e
commit 255cffd061
No known key found for this signature in database
GPG Key ID: 15F978BEFADAB9E1
5 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# pylint: disable=import-error, no-name-in-module, too-few-public-methods, too-many-ancestors
'''
Chats are managed in this screen
'''
from kivy.uix.screenmanager import Screen
class Chat(Screen):
"""Chat Screen class for kivy Ui"""

View File

@ -0,0 +1,82 @@
#:import C kivy.utils.get_color_from_hex
#:import MDTextField kivymd.uix.textfield.MDTextField
<Chat>:
name: 'chat'
BoxLayout:
orientation: 'vertical'
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
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)
MDBoxLayout:
size_hint_y: None
spacing:5
orientation: 'horizontal'
pos_hint: {'center_y': 1, 'center_x': 1}
halign: 'right'
pos_hint: {'left': 0}
pos_hint: {'x':.8}
height: dp(50) + self.minimum_height
MDFillRoundFlatButton:
text: app.tr._("First message")
opposite_colors: True
pos_hint: {'center_x':0.8,'center_y':0.7}
BoxLayout:
height: 50
orientation: 'horizontal'
padding: 0
size_hint: (1, None)
MDTextField:
id:'id_message_body'
hint_text: 'Empty field'
icon_left: "message"
hint_text: "please enter your text"
mode: "fill"
fill_color: 1/255, 144/255, 254/255, 0.1
multiline: True
font_color_normal: 0, 0, 0, .4
icon_right: 'grease-pencil'
icon_right_color: app.theme_cls.primary_light
pos_hint: {'center_x':0.2,'center_y':0.7}
MDIconButton:
id: file_manager
icon: "attachment"
opposite_colors: True
on_release: app.file_manager_open()
theme_text_color: "Custom"
text_color: app.theme_cls.primary_color
MDIconButton:
icon: 'camera'
opposite_colors: True
theme_text_color: "Custom"
text_color: app.theme_cls.primary_color
MDIconButton:
id: send_message
icon: "send"
# x: root.parent.x + dp(10)
# pos_hint: {"top": 1, 'left': 1}
color: [1,0,0,1]
on_release: app.rest_default_avatar_img()
theme_text_color: "Custom"
text_color: app.theme_cls.primary_color

View File

@ -160,6 +160,16 @@
on_release: root.parent.set_state()
on_press: app.load_screen(self)
NavigationDrawerDivider:
NavigationDrawerSubheader:
text: app.tr._('Chat')
NavigationItem:
id: draft_cnt
text: app.tr._('Chat')
icon: 'chat'
divider: None
on_release: app.root.ids.scr_mngr.current = 'chat'
on_release: root.parent.set_state()
NavigationDrawerDivider:
NavigationDrawerSubheader:
text: app.tr._("All labels")
NavigationItem:
@ -248,6 +258,8 @@ MDNavigationLayout:
id:id_addressbook
ShowQRCode:
id:id_showqrcode
Chat:
id: id_chat
MDNavigationDrawer:
id: nav_drawer

View File

@ -74,6 +74,10 @@
"Qrcode": {
"kv_string": "qrcode",
"Import": "from pybitmessage.bitmessagekivy.baseclass.qrcode import ShowQRCode"
},
"Chat": {
"kv_string": "chat",
"Import": "from pybitmessage.bitmessagekivy.baseclass.chat import Chat"
}
}

View File

@ -0,0 +1,26 @@
from .telenium_process import TeleniumTestProcess
from .common import ordered
class ChatScreen(TeleniumTestProcess):
"""Chat Screen Functionality Testing"""
@ordered
def test_open_chat_screen(self):
"""Opening Chat screen"""
# Checking current Screen(Inbox screen)
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox')
# Method to open side navbar
self.open_side_navbar()
# this is for scrolling Nav drawer
self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
# assert for checking scroll function
self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=10)
# Checking Chat screen label on side nav bar
self.assertExists('//NavigationItem[@text=\"Chat\"]', timeout=5)
# this is for opening Chat screen
self.cli.wait_click('//NavigationItem[@text=\"Chat\"]', timeout=5)
# Checking navigation bar state
self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
# Checking current screen
self.assertExists("//Chat[@name~=\"chat\"]", timeout=5)