optimized CutsomSwipeToDeleteItem

This commit is contained in:
navjot 2021-04-22 22:53:28 +05:30
parent 73f600c24c
commit 89cef2cf8c
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
9 changed files with 120 additions and 52 deletions

View File

@ -18,8 +18,8 @@ import state
from bitmessagekivy.baseclass.common import (
showLimitedCnt, toast, ThemeClsColor,
chipTag, avatarImageFirstLetter, AddTimeWidget,
AvatarSampleWidget, SwipeToDeleteItem
avatarImageFirstLetter,CutsomSwipeToDeleteItem,
ShowTimeHistoy
)
from bitmessagekivy.baseclass.maildetail import MailDetail
from bitmessagekivy.baseclass.trash import Trash
@ -95,9 +95,10 @@ class Allmails(Screen):
for item in self.all_mails:
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
message_row = SwipeToDeleteItem(
message_row = CutsomSwipeToDeleteItem(
text = item[1],
)
listItem = message_row.ids.content
secondary_text = (subject[:50] + '........' if len(
subject) >= 50 else (
@ -105,16 +106,34 @@ class Allmails(Screen):
listItem.secondary_text = secondary_text
listItem.theme_text_color = "Custom"
listItem.text_color = ThemeClsColor
listItem.add_widget(AvatarSampleWidget(
source=state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(body.strip()))))
img_latter = state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(body.strip()))
message_row.ids.avater_img.source = img_latter
listItem.bind(on_release=partial(
self.mail_detail, item[5], item[4], message_row))
listItem.add_widget(AddTimeWidget(item[7]))
listItem.add_widget(chipTag(item[4]))
message_row.ids.time_tag.text = str(ShowTimeHistoy(item[7]))
message_row.ids.chip_tag.text = item[4]
# listItem = message_row.ids.content
# secondary_text = (subject[:50] + '........' if len(
# subject) >= 50 else (
# subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', '')
# listItem.secondary_text = secondary_text
# listItem.theme_text_color = "Custom"
# listItem.text_color = ThemeClsColor
# listItem.add_widget(AvatarSampleWidget(
# source=state.imageDir + '/text_images/{}.png'.format(
# avatarImageFirstLetter(body.strip()))))
# listItem.bind(on_release=partial(
# self.mail_detail, item[5], item[4], message_row))
# listItem.add_widget(AddTimeWidget(item[7]))
# listItem.add_widget(chipTag(item[4]))
message_row.ids.delete_msg.bind(on_press=partial(
self.swipe_delete, item[5], item[4]))
self.ids.ml.add_widget(message_row)
updated_data = len(self.ids.ml.children)
self.has_refreshed = True if data_exist != updated_data else False

View File

@ -1,5 +1,6 @@
import os
from datetime import datetime
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.metrics import dp
from kivymd.uix.list import (
@ -135,7 +136,14 @@ class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
class SwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
# cla = Window.size[0]/2
cla = 800
cla = Window.size[0]/2
# cla = 800
swipe_distance = NumericProperty(cla)
opening_time = NumericProperty(0.5)
class CutsomSwipeToDeleteItem(MDCardSwipe):
text = StringProperty()
cla = Window.size[0]/2
swipe_distance = NumericProperty(cla)
opening_time = NumericProperty(0.5)

View File

@ -21,8 +21,7 @@ import state
from bitmessagekivy.baseclass.common import (
showLimitedCnt, toast, ThemeClsColor,
AddTimeWidget, AvatarSampleWidget,
SwipeToDeleteItem
SwipeToDeleteItem, ShowTimeHistoy
)
from bitmessagekivy.baseclass.maildetail import MailDetail
@ -110,11 +109,10 @@ class Draft(Screen):
listItem.theme_text_color = "Custom"
listItem.text_color = ThemeClsColor
# meny._txt_right_pad = dp(70)
listItem.add_widget(AvatarSampleWidget(
source=state.imageDir + '/avatar.png'))
message_row.ids.avater_img.source = state.imageDir + '/avatar.png'
listItem.bind(on_release=partial(
self.draft_detail, item['ackdata'], message_row))
listItem.add_widget(AddTimeWidget(item['senttime']))
message_row.ids.time_tag.text = str(ShowTimeHistoy(item['senttime']))
message_row.ids.delete_msg.bind(on_press=partial(self.delete_draft, item['ackdata']))
self.ids.ml.add_widget(message_row)
updated_msg = len(self.ids.ml.children)

View File

@ -20,8 +20,8 @@ import state
from bitmessagekivy.baseclass.common import (
showLimitedCnt, avatarImageFirstLetter,
AddTimeWidget, ThemeClsColor, AvatarSampleWidget,
toast, SwipeToDeleteItem
ThemeClsColor, toast, SwipeToDeleteItem,
ShowTimeHistoy
)
from bitmessagekivy.baseclass.maildetail import MailDetail
from bitmessagekivy.baseclass.trash import Trash
@ -131,15 +131,11 @@ class Inbox(Screen):
listItem.theme_text_color = "Custom"
listItem.text_color = ThemeClsColor
listItem._txt_right_pad = dp(70)
listItem.add_widget(
AvatarSampleWidget(
source=state.imageDir + "/text_images/{}.png".format(
avatarImageFirstLetter(item["secondary_text"].strip())
)
)
)
image = state.imageDir + "/text_images/{}.png".format(
avatarImageFirstLetter(item["secondary_text"].strip()))
message_row.ids.avater_img.source = image
listItem.bind(on_release=partial(self.inbox_detail, item["msgid"], message_row))
listItem.add_widget(AddTimeWidget(item["received"]))
message_row.ids.time_tag.text = str(ShowTimeHistoy(item["received"]))
message_row.ids.delete_msg.bind(on_press=partial(self.delete, item["msgid"]))
self.ids.ml.add_widget(message_row)
update_message = len(self.ids.ml.children)

View File

@ -19,7 +19,8 @@ import state
from bitmessagekivy.baseclass.common import (
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
AddTimeWidget, AvatarSampleWidget, toast, SwipeToDeleteItem
AddTimeWidget, AvatarSampleWidget, toast, SwipeToDeleteItem,
ShowTimeHistoy
)
from bitmessagekivy.baseclass.maildetail import MailDetail
@ -103,12 +104,11 @@ class Sent(Screen):
listItem.secondary_text = item["secondary_text"]
listItem.theme_text_color = "Custom"
listItem.text_color = ThemeClsColor
listItem.add_widget(AvatarSampleWidget(
source=state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip()))))
image = state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip()))
message_row.ids.avater_img.source = image
listItem.bind(on_release=partial(self.sent_detail, item['ackdata'], message_row))
listItem.add_widget(AddTimeWidget(item['senttime']))
message_row.ids.time_tag.text = str(ShowTimeHistoy(item['senttime']))
message_row.ids.delete_msg.bind(on_press=partial(self.delete, item["ackdata"]))
self.ids.ml.add_widget(message_row, index=set_index)

View File

@ -19,13 +19,9 @@ from kivy.uix.screenmanager import Screen
import state
from bitmessagekivy.baseclass.common import (
showLimitedCnt, avatarImageFirstLetter,
AddTimeWidget, ThemeClsColor, AvatarSampleWidget
)
from bitmessagekivy.baseclass.common import (
toast, showLimitedCnt, ThemeClsColor, chipTag,
AddTimeWidget, AvatarSampleWidget, SwipeToDeleteItem
toast, showLimitedCnt, ThemeClsColor,
CutsomSwipeToDeleteItem, ShowTimeHistoy,
avatarImageFirstLetter
)
@ -44,14 +40,12 @@ class Trash(Screen):
def init_ui(self, dt=0):
"""Clock Schdule for method trash screen"""
print('clearing data....................................', len(self.ids.ml.children))
if state.association == '':
if BMConfigParser().addresses():
state.association = BMConfigParser().addresses()[0]
self.ids.tag_label.text = ''
self.trashDataQuery(0, 20)
print('count messages.....................', len(self.trash_messages))
if len(self.trash_messages) and len(self.trash_messages) != len(self.ids.ml.children):
if len(self.trash_messages):
self.ids.ml.clear_widgets()
self.ids.tag_label.text = 'Trash'
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids
@ -59,8 +53,6 @@ class Trash(Screen):
self.set_TrashCnt(state.trash_count)
self.set_mdList()
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
elif len(self.trash_messages):
self.ids.tag_label.text = 'Trash'
else:
self.set_TrashCnt('0')
content = MDLabel(
@ -97,7 +89,7 @@ class Trash(Screen):
for item in self.trash_messages:
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
message_row = SwipeToDeleteItem(
message_row = CutsomSwipeToDeleteItem(
text = item[1],
)
message_row.bind(on_swipe_complete=partial(self.on_swipe_complete, message_row))
@ -106,12 +98,11 @@ class Trash(Screen):
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', '')
listItem.theme_text_color = "Custom"
listItem.text_color = ThemeClsColor
# meny._txt_right_pad = dp(70)
img_latter = state.imageDir + '/text_images/{}.png'.format(
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
listItem.add_widget(AvatarSampleWidget(source=img_latter))
listItem.add_widget(AddTimeWidget(item[7]))
listItem.add_widget(chipTag('inbox 'if 'inbox' in item[4] else 'sent'))
avatarImageFirstLetter(subject[0].strip()))
message_row.ids.avater_img.source = img_latter
message_row.ids.time_tag.text = str(ShowTimeHistoy(item[7]))
message_row.ids.chip_tag.text = 'inbox 'if 'inbox' in item[4] else 'sent'
message_row.ids.delete_msg.bind(on_press=partial(
self.delete_permanently, item[5], item[4]))
self.ids.ml.add_widget(message_row)

View File

@ -22,4 +22,4 @@
MDList:
id: ml
Loader:
ComposerButton:
ComposerButton:

View File

@ -364,3 +364,59 @@ MDNavigationLayout:
id: content
text: root.text
_no_ripple_effect: True
AvatarSampleWidget:
id: avater_img
# source: './images/kivy/avatar.png'
source: None
TimeTagRightSampleWidget:
id: time_tag
text: ''
font_size: "11sp"
font_style: "Caption"
size: [120, 140] if app.app_platform == "android" else [64, 80]
<CutsomSwipeToDeleteItem>:
size_hint_y: None
height: content.height
MDCardSwipeLayerBox:
padding: "8dp"
MDIconButton:
id: delete_msg
icon: "trash-can"
pos_hint: {"center_y": .5}
md_bg_color: (1, 0, 0, 1)
disabled: True
MDCardSwipeFrontBox:
TwoLineAvatarIconListItem:
id: content
text: root.text
_no_ripple_effect: True
AvatarSampleWidget:
id: avater_img
# source: './images/kivy/avatar.png'
source: None
TimeTagRightSampleWidget:
id: time_tag
text: 'time'
font_size: "11sp"
font_style: "Caption"
size: [120, 140] if app.app_platform == "android" else [64, 80]
MDChip:
id: chip_tag
size_hint: (0.16 if app.app_platform == "android" else 0.08, None)
text: 'test'
icon: ""
pos_hint: {"center_x": 0.91 if app.app_platform == "android" else 0.94, "center_y": 0.3}
# height: dp(18)
height: '18dp'
text_color: (1,1,1,1)
radius: [8]

View File

@ -48,7 +48,7 @@ requirements =
pillow,
#bitmsghash,
#git+https://github.com/navjotcis/KivyMD#egg=kivymd,
#git+https://github.com/kivymd/KivyMD#egg=kivymd,
git+https://github.com/kivymd/KivyMD#egg=kivymd,
#kivymd,
kivy-garden,
qrcode,