Skip to content

Commit 255cffd

Browse files
committed
Add Chat screen
1 parent 7ee2217 commit 255cffd

File tree

5 files changed

+135
-0
lines changed

5 files changed

+135
-0
lines changed

src/bitmessagekivy/baseclass/chat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# pylint: disable=import-error, no-name-in-module, too-few-public-methods, too-many-ancestors
2+
3+
'''
4+
Chats are managed in this screen
5+
'''
6+
7+
from kivy.uix.screenmanager import Screen
8+
9+
10+
class Chat(Screen):
11+
"""Chat Screen class for kivy Ui"""

src/bitmessagekivy/kv/chat.kv

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#:import C kivy.utils.get_color_from_hex
2+
#:import MDTextField kivymd.uix.textfield.MDTextField
3+
<Chat>:
4+
name: 'chat'
5+
BoxLayout:
6+
orientation: 'vertical'
7+
canvas.before:
8+
Color:
9+
rgba: 1,1,1,1
10+
Rectangle:
11+
pos: self.pos
12+
size: self.size
13+
ScrollView:
14+
Label:
15+
id: chat_logs
16+
text: ''
17+
color: C('#101010')
18+
text_size: (self.width, None)
19+
halign: 'left'
20+
valign: 'top'
21+
padding: (0, 0) # fixed in Kivy 1.8.1
22+
size_hint: (1, None)
23+
height: self.texture_size[1]
24+
markup: True
25+
font_size: sp(20)
26+
MDBoxLayout:
27+
size_hint_y: None
28+
spacing:5
29+
orientation: 'horizontal'
30+
pos_hint: {'center_y': 1, 'center_x': 1}
31+
halign: 'right'
32+
pos_hint: {'left': 0}
33+
pos_hint: {'x':.8}
34+
height: dp(50) + self.minimum_height
35+
MDFillRoundFlatButton:
36+
text: app.tr._("First message")
37+
opposite_colors: True
38+
pos_hint: {'center_x':0.8,'center_y':0.7}
39+
40+
41+
42+
BoxLayout:
43+
height: 50
44+
orientation: 'horizontal'
45+
padding: 0
46+
size_hint: (1, None)
47+
48+
MDTextField:
49+
id:'id_message_body'
50+
hint_text: 'Empty field'
51+
icon_left: "message"
52+
hint_text: "please enter your text"
53+
mode: "fill"
54+
fill_color: 1/255, 144/255, 254/255, 0.1
55+
multiline: True
56+
font_color_normal: 0, 0, 0, .4
57+
icon_right: 'grease-pencil'
58+
icon_right_color: app.theme_cls.primary_light
59+
pos_hint: {'center_x':0.2,'center_y':0.7}
60+
61+
MDIconButton:
62+
id: file_manager
63+
icon: "attachment"
64+
opposite_colors: True
65+
on_release: app.file_manager_open()
66+
theme_text_color: "Custom"
67+
text_color: app.theme_cls.primary_color
68+
69+
MDIconButton:
70+
icon: 'camera'
71+
opposite_colors: True
72+
theme_text_color: "Custom"
73+
text_color: app.theme_cls.primary_color
74+
MDIconButton:
75+
id: send_message
76+
icon: "send"
77+
# x: root.parent.x + dp(10)
78+
# pos_hint: {"top": 1, 'left': 1}
79+
color: [1,0,0,1]
80+
on_release: app.rest_default_avatar_img()
81+
theme_text_color: "Custom"
82+
text_color: app.theme_cls.primary_color

src/bitmessagekivy/main.kv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@
160160
on_release: root.parent.set_state()
161161
on_press: app.load_screen(self)
162162
NavigationDrawerDivider:
163+
NavigationDrawerSubheader:
164+
text: app.tr._('Chat')
165+
NavigationItem:
166+
id: draft_cnt
167+
text: app.tr._('Chat')
168+
icon: 'chat'
169+
divider: None
170+
on_release: app.root.ids.scr_mngr.current = 'chat'
171+
on_release: root.parent.set_state()
172+
NavigationDrawerDivider:
163173
NavigationDrawerSubheader:
164174
text: app.tr._("All labels")
165175
NavigationItem:
@@ -248,6 +258,8 @@ MDNavigationLayout:
248258
id:id_addressbook
249259
ShowQRCode:
250260
id:id_showqrcode
261+
Chat:
262+
id: id_chat
251263

252264
MDNavigationDrawer:
253265
id: nav_drawer

src/bitmessagekivy/screens_data.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
"Qrcode": {
7575
"kv_string": "qrcode",
7676
"Import": "from pybitmessage.bitmessagekivy.baseclass.qrcode import ShowQRCode"
77+
},
78+
"Chat": {
79+
"kv_string": "chat",
80+
"Import": "from pybitmessage.bitmessagekivy.baseclass.chat import Chat"
7781
}
7882

7983
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from .telenium_process import TeleniumTestProcess
2+
from .common import ordered
3+
4+
5+
class ChatScreen(TeleniumTestProcess):
6+
"""Chat Screen Functionality Testing"""
7+
8+
@ordered
9+
def test_open_chat_screen(self):
10+
"""Opening Chat screen"""
11+
# Checking current Screen(Inbox screen)
12+
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox')
13+
# Method to open side navbar
14+
self.open_side_navbar()
15+
# this is for scrolling Nav drawer
16+
self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
17+
# assert for checking scroll function
18+
self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=10)
19+
# Checking Chat screen label on side nav bar
20+
self.assertExists('//NavigationItem[@text=\"Chat\"]', timeout=5)
21+
# this is for opening Chat screen
22+
self.cli.wait_click('//NavigationItem[@text=\"Chat\"]', timeout=5)
23+
# Checking navigation bar state
24+
self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
25+
# Checking current screen
26+
self.assertExists("//Chat[@name~=\"chat\"]", timeout=5)

0 commit comments

Comments
 (0)