optimized CutsomSwipeToDeleteItem
This commit is contained in:
parent
73f600c24c
commit
89cef2cf8c
|
@ -18,8 +18,8 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, toast, ThemeClsColor,
|
showLimitedCnt, toast, ThemeClsColor,
|
||||||
chipTag, avatarImageFirstLetter, AddTimeWidget,
|
avatarImageFirstLetter,CutsomSwipeToDeleteItem,
|
||||||
AvatarSampleWidget, SwipeToDeleteItem
|
ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
from bitmessagekivy.baseclass.trash import Trash
|
from bitmessagekivy.baseclass.trash import Trash
|
||||||
|
@ -95,9 +95,10 @@ class Allmails(Screen):
|
||||||
for item in self.all_mails:
|
for item in self.all_mails:
|
||||||
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
||||||
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
||||||
message_row = SwipeToDeleteItem(
|
message_row = CutsomSwipeToDeleteItem(
|
||||||
text = item[1],
|
text = item[1],
|
||||||
)
|
)
|
||||||
|
|
||||||
listItem = message_row.ids.content
|
listItem = message_row.ids.content
|
||||||
secondary_text = (subject[:50] + '........' if len(
|
secondary_text = (subject[:50] + '........' if len(
|
||||||
subject) >= 50 else (
|
subject) >= 50 else (
|
||||||
|
@ -105,16 +106,34 @@ class Allmails(Screen):
|
||||||
listItem.secondary_text = secondary_text
|
listItem.secondary_text = secondary_text
|
||||||
listItem.theme_text_color = "Custom"
|
listItem.theme_text_color = "Custom"
|
||||||
listItem.text_color = ThemeClsColor
|
listItem.text_color = ThemeClsColor
|
||||||
|
img_latter = state.imageDir + '/text_images/{}.png'.format(
|
||||||
listItem.add_widget(AvatarSampleWidget(
|
avatarImageFirstLetter(body.strip()))
|
||||||
source=state.imageDir + '/text_images/{}.png'.format(
|
message_row.ids.avater_img.source = img_latter
|
||||||
avatarImageFirstLetter(body.strip()))))
|
|
||||||
listItem.bind(on_release=partial(
|
listItem.bind(on_release=partial(
|
||||||
self.mail_detail, item[5], item[4], message_row))
|
self.mail_detail, item[5], item[4], message_row))
|
||||||
listItem.add_widget(AddTimeWidget(item[7]))
|
message_row.ids.time_tag.text = str(ShowTimeHistoy(item[7]))
|
||||||
listItem.add_widget(chipTag(item[4]))
|
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(
|
message_row.ids.delete_msg.bind(on_press=partial(
|
||||||
self.swipe_delete, item[5], item[4]))
|
self.swipe_delete, item[5], item[4]))
|
||||||
|
|
||||||
|
|
||||||
self.ids.ml.add_widget(message_row)
|
self.ids.ml.add_widget(message_row)
|
||||||
updated_data = len(self.ids.ml.children)
|
updated_data = len(self.ids.ml.children)
|
||||||
self.has_refreshed = True if data_exist != updated_data else False
|
self.has_refreshed = True if data_exist != updated_data else False
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from kivy.core.window import Window
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
from kivy.metrics import dp
|
from kivy.metrics import dp
|
||||||
from kivymd.uix.list import (
|
from kivymd.uix.list import (
|
||||||
|
@ -135,7 +136,14 @@ class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
|
||||||
|
|
||||||
class SwipeToDeleteItem(MDCardSwipe):
|
class SwipeToDeleteItem(MDCardSwipe):
|
||||||
text = StringProperty()
|
text = StringProperty()
|
||||||
# cla = Window.size[0]/2
|
cla = Window.size[0]/2
|
||||||
cla = 800
|
# 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)
|
swipe_distance = NumericProperty(cla)
|
||||||
opening_time = NumericProperty(0.5)
|
opening_time = NumericProperty(0.5)
|
|
@ -21,8 +21,7 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, toast, ThemeClsColor,
|
showLimitedCnt, toast, ThemeClsColor,
|
||||||
AddTimeWidget, AvatarSampleWidget,
|
SwipeToDeleteItem, ShowTimeHistoy
|
||||||
SwipeToDeleteItem
|
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
|
|
||||||
|
@ -110,11 +109,10 @@ class Draft(Screen):
|
||||||
listItem.theme_text_color = "Custom"
|
listItem.theme_text_color = "Custom"
|
||||||
listItem.text_color = ThemeClsColor
|
listItem.text_color = ThemeClsColor
|
||||||
# meny._txt_right_pad = dp(70)
|
# meny._txt_right_pad = dp(70)
|
||||||
listItem.add_widget(AvatarSampleWidget(
|
message_row.ids.avater_img.source = state.imageDir + '/avatar.png'
|
||||||
source=state.imageDir + '/avatar.png'))
|
|
||||||
listItem.bind(on_release=partial(
|
listItem.bind(on_release=partial(
|
||||||
self.draft_detail, item['ackdata'], message_row))
|
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']))
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete_draft, item['ackdata']))
|
||||||
self.ids.ml.add_widget(message_row)
|
self.ids.ml.add_widget(message_row)
|
||||||
updated_msg = len(self.ids.ml.children)
|
updated_msg = len(self.ids.ml.children)
|
||||||
|
|
|
@ -20,8 +20,8 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, avatarImageFirstLetter,
|
showLimitedCnt, avatarImageFirstLetter,
|
||||||
AddTimeWidget, ThemeClsColor, AvatarSampleWidget,
|
ThemeClsColor, toast, SwipeToDeleteItem,
|
||||||
toast, SwipeToDeleteItem
|
ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
from bitmessagekivy.baseclass.trash import Trash
|
from bitmessagekivy.baseclass.trash import Trash
|
||||||
|
@ -131,15 +131,11 @@ class Inbox(Screen):
|
||||||
listItem.theme_text_color = "Custom"
|
listItem.theme_text_color = "Custom"
|
||||||
listItem.text_color = ThemeClsColor
|
listItem.text_color = ThemeClsColor
|
||||||
listItem._txt_right_pad = dp(70)
|
listItem._txt_right_pad = dp(70)
|
||||||
listItem.add_widget(
|
image = state.imageDir + "/text_images/{}.png".format(
|
||||||
AvatarSampleWidget(
|
avatarImageFirstLetter(item["secondary_text"].strip()))
|
||||||
source=state.imageDir + "/text_images/{}.png".format(
|
message_row.ids.avater_img.source = image
|
||||||
avatarImageFirstLetter(item["secondary_text"].strip())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
listItem.bind(on_release=partial(self.inbox_detail, item["msgid"], message_row))
|
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"]))
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete, item["msgid"]))
|
||||||
self.ids.ml.add_widget(message_row)
|
self.ids.ml.add_widget(message_row)
|
||||||
update_message = len(self.ids.ml.children)
|
update_message = len(self.ids.ml.children)
|
||||||
|
|
|
@ -19,7 +19,8 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
|
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
|
||||||
AddTimeWidget, AvatarSampleWidget, toast, SwipeToDeleteItem
|
AddTimeWidget, AvatarSampleWidget, toast, SwipeToDeleteItem,
|
||||||
|
ShowTimeHistoy
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
|
|
||||||
|
@ -103,12 +104,11 @@ class Sent(Screen):
|
||||||
listItem.secondary_text = item["secondary_text"]
|
listItem.secondary_text = item["secondary_text"]
|
||||||
listItem.theme_text_color = "Custom"
|
listItem.theme_text_color = "Custom"
|
||||||
listItem.text_color = ThemeClsColor
|
listItem.text_color = ThemeClsColor
|
||||||
listItem.add_widget(AvatarSampleWidget(
|
image = state.imageDir + '/text_images/{}.png'.format(
|
||||||
source=state.imageDir + '/text_images/{}.png'.format(
|
avatarImageFirstLetter(item['secondary_text'].strip()))
|
||||||
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.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"]))
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete, item["ackdata"]))
|
||||||
self.ids.ml.add_widget(message_row, index=set_index)
|
self.ids.ml.add_widget(message_row, index=set_index)
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,9 @@ from kivy.uix.screenmanager import Screen
|
||||||
import state
|
import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, avatarImageFirstLetter,
|
toast, showLimitedCnt, ThemeClsColor,
|
||||||
AddTimeWidget, ThemeClsColor, AvatarSampleWidget
|
CutsomSwipeToDeleteItem, ShowTimeHistoy,
|
||||||
)
|
avatarImageFirstLetter
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
|
||||||
toast, showLimitedCnt, ThemeClsColor, chipTag,
|
|
||||||
AddTimeWidget, AvatarSampleWidget, SwipeToDeleteItem
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,14 +40,12 @@ class Trash(Screen):
|
||||||
|
|
||||||
def init_ui(self, dt=0):
|
def init_ui(self, dt=0):
|
||||||
"""Clock Schdule for method trash screen"""
|
"""Clock Schdule for method trash screen"""
|
||||||
print('clearing data....................................', len(self.ids.ml.children))
|
|
||||||
if state.association == '':
|
if state.association == '':
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
state.association = BMConfigParser().addresses()[0]
|
state.association = BMConfigParser().addresses()[0]
|
||||||
self.ids.tag_label.text = ''
|
self.ids.tag_label.text = ''
|
||||||
self.trashDataQuery(0, 20)
|
self.trashDataQuery(0, 20)
|
||||||
print('count messages.....................', len(self.trash_messages))
|
if len(self.trash_messages):
|
||||||
if len(self.trash_messages) and len(self.trash_messages) != len(self.ids.ml.children):
|
|
||||||
self.ids.ml.clear_widgets()
|
self.ids.ml.clear_widgets()
|
||||||
self.ids.tag_label.text = 'Trash'
|
self.ids.tag_label.text = 'Trash'
|
||||||
# src_mng_obj = state.kivyapp.root.children[2].children[0].ids
|
# 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_TrashCnt(state.trash_count)
|
||||||
self.set_mdList()
|
self.set_mdList()
|
||||||
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
|
||||||
elif len(self.trash_messages):
|
|
||||||
self.ids.tag_label.text = 'Trash'
|
|
||||||
else:
|
else:
|
||||||
self.set_TrashCnt('0')
|
self.set_TrashCnt('0')
|
||||||
content = MDLabel(
|
content = MDLabel(
|
||||||
|
@ -97,7 +89,7 @@ class Trash(Screen):
|
||||||
for item in self.trash_messages:
|
for item in self.trash_messages:
|
||||||
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
||||||
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
||||||
message_row = SwipeToDeleteItem(
|
message_row = CutsomSwipeToDeleteItem(
|
||||||
text = item[1],
|
text = item[1],
|
||||||
)
|
)
|
||||||
message_row.bind(on_swipe_complete=partial(self.on_swipe_complete, message_row))
|
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(' ', '')
|
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', '')
|
||||||
listItem.theme_text_color = "Custom"
|
listItem.theme_text_color = "Custom"
|
||||||
listItem.text_color = ThemeClsColor
|
listItem.text_color = ThemeClsColor
|
||||||
# meny._txt_right_pad = dp(70)
|
|
||||||
img_latter = state.imageDir + '/text_images/{}.png'.format(
|
img_latter = state.imageDir + '/text_images/{}.png'.format(
|
||||||
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
|
avatarImageFirstLetter(subject[0].strip()))
|
||||||
listItem.add_widget(AvatarSampleWidget(source=img_latter))
|
message_row.ids.avater_img.source = img_latter
|
||||||
listItem.add_widget(AddTimeWidget(item[7]))
|
message_row.ids.time_tag.text = str(ShowTimeHistoy(item[7]))
|
||||||
listItem.add_widget(chipTag('inbox 'if 'inbox' in item[4] else 'sent'))
|
message_row.ids.chip_tag.text = 'inbox 'if 'inbox' in item[4] else 'sent'
|
||||||
message_row.ids.delete_msg.bind(on_press=partial(
|
message_row.ids.delete_msg.bind(on_press=partial(
|
||||||
self.delete_permanently, item[5], item[4]))
|
self.delete_permanently, item[5], item[4]))
|
||||||
self.ids.ml.add_widget(message_row)
|
self.ids.ml.add_widget(message_row)
|
||||||
|
|
|
@ -364,3 +364,59 @@ MDNavigationLayout:
|
||||||
id: content
|
id: content
|
||||||
text: root.text
|
text: root.text
|
||||||
_no_ripple_effect: True
|
_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]
|
||||||
|
|
|
@ -48,7 +48,7 @@ requirements =
|
||||||
pillow,
|
pillow,
|
||||||
#bitmsghash,
|
#bitmsghash,
|
||||||
#git+https://github.com/navjotcis/KivyMD#egg=kivymd,
|
#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,
|
#kivymd,
|
||||||
kivy-garden,
|
kivy-garden,
|
||||||
qrcode,
|
qrcode,
|
||||||
|
|
Reference in New Issue
Block a user