From 255cffd06190faaf7628bb50e5b74fc49da202ef Mon Sep 17 00:00:00 2001 From: osamacis Date: Thu, 15 Dec 2022 20:01:41 +0530 Subject: [PATCH] Add Chat screen --- src/bitmessagekivy/baseclass/chat.py | 11 +++ src/bitmessagekivy/kv/chat.kv | 82 ++++++++++++++++++++ src/bitmessagekivy/main.kv | 12 +++ src/bitmessagekivy/screens_data.json | 4 + src/bitmessagekivy/tests/test_chat_screen.py | 26 +++++++ 5 files changed, 135 insertions(+) create mode 100644 src/bitmessagekivy/baseclass/chat.py create mode 100644 src/bitmessagekivy/kv/chat.kv create mode 100644 src/bitmessagekivy/tests/test_chat_screen.py diff --git a/src/bitmessagekivy/baseclass/chat.py b/src/bitmessagekivy/baseclass/chat.py new file mode 100644 index 00000000..c5f94b8a --- /dev/null +++ b/src/bitmessagekivy/baseclass/chat.py @@ -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""" diff --git a/src/bitmessagekivy/kv/chat.kv b/src/bitmessagekivy/kv/chat.kv new file mode 100644 index 00000000..e21ed503 --- /dev/null +++ b/src/bitmessagekivy/kv/chat.kv @@ -0,0 +1,82 @@ +#:import C kivy.utils.get_color_from_hex +#:import MDTextField kivymd.uix.textfield.MDTextField +: + 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 diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index 5d7717a9..caa2c7cd 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -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 diff --git a/src/bitmessagekivy/screens_data.json b/src/bitmessagekivy/screens_data.json index 5325151f..86ddea19 100644 --- a/src/bitmessagekivy/screens_data.json +++ b/src/bitmessagekivy/screens_data.json @@ -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" } } diff --git a/src/bitmessagekivy/tests/test_chat_screen.py b/src/bitmessagekivy/tests/test_chat_screen.py new file mode 100644 index 00000000..98464bf3 --- /dev/null +++ b/src/bitmessagekivy/tests/test_chat_screen.py @@ -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)