Add addressbook and update id name

This commit is contained in:
shekhar-cis 2022-08-22 21:44:12 +05:30
parent 95b0d1838a
commit d9a9e4e6d5
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
2 changed files with 75 additions and 7 deletions

View File

@ -79,7 +79,7 @@
if root.is_camara_attached(): app.set_screen('scanscreen') if root.is_camara_attached(): app.set_screen('scanscreen')
else: root.camera_alert() else: root.camera_alert()
on_press: on_press:
app.root.ids.is_scanscreen.get_screen('composer') app.root.ids.id_scanscreen.get_screen('composer')
MyMDTextField: MyMDTextField:
id: subject id: subject

View File

@ -18,10 +18,11 @@ from kivy.uix.boxlayout import BoxLayout
from kivymd.app import MDApp from kivymd.app import MDApp
from kivymd.uix.label import MDLabel from kivymd.uix.label import MDLabel
from kivymd.uix.dialog import MDDialog
from kivymd.uix.list import ( from kivymd.uix.list import (
IRightBodyTouch IRightBodyTouch
) )
from kivymd.uix.button import MDRaisedButton
from kivymd.uix.bottomsheet import MDCustomBottomSheet from kivymd.uix.bottomsheet import MDCustomBottomSheet
from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables from pybitmessage.bitmessagekivy.kivy_state import KivyStateVariables
@ -32,6 +33,9 @@ from pybitmessage.bitmessagekivy.base_navigation import (
) )
from pybitmessage.bmconfigparser import config from pybitmessage.bmconfigparser import config
from pybitmessage.bitmessagekivy.get_platform import platform
from pybitmessage.bitmessagekivy.baseclass.common import toast
from pybitmessage.bitmessagekivy.baseclass.popup import AddAddressPopup
logger = logging.getLogger('default') logger = logging.getLogger('default')
@ -100,16 +104,16 @@ class IdentitySpinner(BaseIdentitySpinner):
class NavigateApp(MDApp): class NavigateApp(MDApp):
"""Navigation Layout of class""" """Navigation Layout of class"""
def __init__(self):
super(NavigateApp, self).__init__()
self.data_screens, self.all_data, response = load_screen_json()
self.kivy_state_obj = KivyStateVariables()
title = "PyBitmessage" title = "PyBitmessage"
identity_list = get_identity_list() identity_list = get_identity_list()
image_path = KivyStateVariables().image_dir image_path = KivyStateVariables().image_dir
tr = Lang("en") # for changing in franch replace en with fr tr = Lang("en") # for changing in franch replace en with fr
def __init__(self):
super(NavigateApp, self).__init__()
self.data_screens, self.all_data, response = load_screen_json()
self.kivy_state_obj = KivyStateVariables()
def build(self): def build(self):
"""Method builds the widget""" """Method builds the widget"""
for kv in self.data_screens: for kv in self.data_screens:
@ -131,6 +135,70 @@ class NavigateApp(MDApp):
self.kivy_state_obj.kivyui_ready.set() self.kivy_state_obj.kivyui_ready.set()
super(NavigateApp, self).run() super(NavigateApp, self).run()
def addingtoaddressbook(self):
"""Dialog for saving address"""
width = .85 if platform == 'android' else .8
self.add_popup = MDDialog(
title='Add contact',
type="custom",
size_hint=(width, .23),
content_cls=AddAddressPopup(),
buttons=[
MDRaisedButton(
text="Save",
on_release=self.savecontact,
),
MDRaisedButton(
text="Cancel",
on_release=self.close_pop,
),
MDRaisedButton(
text="Scan QR code",
on_release=self.scan_qr_code,
),
],
)
self.add_popup.auto_dismiss = False
self.add_popup.open()
def scan_qr_code(self, instance):
"""this method is used for showing QR code scanner"""
if self.is_camara_attached():
self.add_popup.dismiss()
self.root.ids.id_scanscreen.get_screen(self.root.ids.scr_mngr.current, self.add_popup)
self.root.ids.scr_mngr.current = 'scanscreen'
else:
alert_text = (
'Currently this feature is not avaialbe!' if platform == 'android' else 'Camera is not available!')
self.add_popup.dismiss()
toast(alert_text)
def is_camara_attached(self):
"""This method is for checking the camera is available or not"""
self.root.ids.id_scanscreen.check_camera()
is_available = self.root.ids.id_scanscreen.camera_available
return is_available
def savecontact(self, instance):
"""Method is used for saving contacts"""
pupup_obj = self.add_popup.content_cls
label = pupup_obj.ids.label.text.strip()
address = pupup_obj.ids.address.text.strip()
if label == '' and address == '':
pupup_obj.ids.label.focus = True
pupup_obj.ids.address.focus = True
elif address == '':
pupup_obj.ids.address.focus = True
elif label == '':
pupup_obj.ids.label.focus = True
else:
pupup_obj.ids.address.focus = True
def close_pop(self, instance):
"""Close the popup"""
self.add_popup.dismiss()
toast('Canceled')
def loadMyAddressScreen(self, action): def loadMyAddressScreen(self, action):
"""loadMyAddressScreen method spin the loader""" """loadMyAddressScreen method spin the loader"""
if len(self.root.ids.id_myaddress.children) <= 2: if len(self.root.ids.id_myaddress.children) <= 2: