worked on auto validation issue or toast implementation

This commit is contained in:
navjot 2020-03-30 23:32:51 +05:30
parent 4b77b22266
commit 48c31b41c8
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
3 changed files with 67 additions and 53 deletions

View File

@ -68,7 +68,9 @@
<Random>:
name: 'random'
ScrollView:
BoxLayout:
id: add_random_bx
<RandomBoxlayout>:
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
@ -87,21 +89,23 @@
text: "Here you may generate as many addresses as you like, Indeed creating and abandoning addresses is encouraged"
halign: 'center'
color:app.theme_cls.primary_dark
MDTextField:
id: label
multiline: False
hint_text: "Label"
required: True
helper_text_mode: "on_error"
on_text: root.add_validation(self)
on_text: app.root.ids.sc7.add_validation(self)
canvas.before:
Color:
rgba: (0,0,0,1)
BoxLayout:
AnchorLayout:
MDRaisedButton:
height: dp(40)
on_release: root.generateaddress(app)
on_release: app.root.ids.sc7.generateaddress(app)
opposite_colors: True
MDLabel:
font_style: 'H6'

View File

@ -188,6 +188,7 @@
divider: None
on_release: app.root.ids.scr_mngr.current = 'login'
on_release: root.parent.set_state()
on_press: app.reset_login_screen()
NavigationItem:
text: 'Network status'
icon: 'server-network'

View File

@ -979,13 +979,12 @@ class Random(Screen):
def generateaddress(self, navApp):
"""Method for Address Generator"""
entered_label = str(self.ids.label.text).strip()
entered_label = str(self.ids.add_random_bx.children[0].ids.label.text).strip()
if not entered_label:
self.ids.label.focus = True
self.ids.add_random_bx.children[0].ids.label.focus = True
# self.ids.label.error = True
# self.ids.label.helper_text = 'This field is required'
streamNumberForAddress = 1
label = self.ids.label.text
eighteenByteRipe = False
nonceTrialsPerByte = 1000
payloadLengthExtraBytes = 1000
@ -994,10 +993,9 @@ class Random(Screen):
if entered_label and entered_label not in lables:
toast('Address Creating...')
queues.addressGeneratorQueue.put((
'createRandomAddress', 4, streamNumberForAddress, label, 1,
'createRandomAddress', 4, streamNumberForAddress, entered_label, 1,
"", eighteenByteRipe, nonceTrialsPerByte,
payloadLengthExtraBytes))
self.ids.label.text = ''
self.parent.parent.ids.toolbar.opacity = 1
self.parent.parent.ids.toolbar.disabled = False
state.kivyapp.loadMyAddressScreen(True)
@ -1019,19 +1017,20 @@ class Random(Screen):
lables = [BMConfigParser().get(obj, 'label')
for obj in BMConfigParser().addresses()]
if entered_label in lables:
self.ids.label.error = True
self.ids.label.helper_text = 'Label name is already exist you'\
instance.error = True
instance.helper_text = 'Label name is already exist you'\
' can try this Ex. ( {0}_1, {0}_2 )'.format(
entered_label)
elif entered_label:
self.ids.label.error = False
instance.error = False
else:
self.ids.label.error = False
self.ids.label.helper_text = 'This field is required'
instance.error = False
instance.helper_text = 'This field is required'
def reset_address_label(self):
"""Resetting address labels"""
self.ids.label.text = ''
if not self.ids.add_random_bx.children:
self.ids.add_random_bx.add_widget(RandomBoxlayout())
class Sent(Screen):
@ -1995,6 +1994,10 @@ class NavigateApp(MDApp):
Clipboard.copy(text)
toast('Copied')
def reset_login_screen(self):
if self.root.ids.sc7.ids.add_random_bx.children:
self.root.ids.sc7.ids.add_random_bx.clear_widgets()
class GrashofPopup(Popup):
"""Moule for save contacts and error messages"""
@ -2040,9 +2043,9 @@ class GrashofPopup(Popup):
def checkAddress_valid(self, instance):
"""Checking address is valid or not"""
# my_addresses = (
# self.parent.children[1].children[2].children[0].ids.btn.values)
# self.parent.children[1].children[0].children[0].ids.btn.values)
my_addresses = (
self.parent.children[1].children[0].children[0].ids.btn.values)
state.kivyapp.root.children[0].children[0].ids.btn.values)
add_book = [addr[1] for addr in kivy_helper_search.search_sql(
folder="addressbook")]
entered_text = str(instance.text).strip()
@ -2798,6 +2801,7 @@ class Allmails(Screen):
nav_lay_obj.sc5.clear_widgets()
nav_lay_obj.sc5.add_widget(Trash())
nav_lay_obj.sc17.remove_widget(instance.parent.parent)
toast('Deleted')
def refresh_callback(self, *args):
"""Method updates the state of application,
@ -3006,3 +3010,8 @@ class ToAddrBoxlayout(BoxLayout):
def set_toAddress(self, to_addr):
"""This method is use to set to address"""
self.to_addr = to_addr
class RandomBoxlayout(BoxLayout):
"""class for BoxLayout behaviour"""
pass