implemented MDCardSwipe for message swipe delete operation
This commit is contained in:
parent
148d4a1333
commit
4f495961b0
|
@ -19,7 +19,7 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
AvatarSampleWidget, avatarImageFirstLetter, toast,
|
AvatarSampleWidget, avatarImageFirstLetter, toast,
|
||||||
ThemeClsColor,
|
ThemeClsColor, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
from bitmessagekivy.baseclass.popup import AddbookDetailPopup
|
||||||
|
|
||||||
|
@ -72,28 +72,20 @@ class AddressBook(Screen):
|
||||||
def set_mdList(self, start_index, end_index):
|
def set_mdList(self, start_index, end_index):
|
||||||
"""Creating the mdList"""
|
"""Creating the mdList"""
|
||||||
for item in self.queryreturn[start_index:end_index]:
|
for item in self.queryreturn[start_index:end_index]:
|
||||||
meny = TwoLineAvatarIconListItem(
|
message_row = SwipeToDeleteItem(
|
||||||
text=item[0], secondary_text=item[1], theme_text_color='Custom',
|
text = item[0],
|
||||||
text_color=ThemeClsColor)
|
)
|
||||||
meny.add_widget(AvatarSampleWidget(
|
listItem = message_row.ids.content
|
||||||
source=state.imageDir + '/text_images/{}.png'.format(
|
listItem.secondary_text = item[1]
|
||||||
|
listItem.theme_text_color = "Custom"
|
||||||
|
listItem.text_color = ThemeClsColor
|
||||||
|
listItem.add_widget(AvatarSampleWidget(
|
||||||
|
source=state.imageDir + '/text_images/{}.png'.format(
|
||||||
avatarImageFirstLetter(item[0].strip()))))
|
avatarImageFirstLetter(item[0].strip()))))
|
||||||
meny.bind(on_press=partial(
|
listItem.bind(on_release=partial(
|
||||||
self.addBook_detail, item[1], item[0]))
|
self.addBook_detail, item[1], item[0], message_row))
|
||||||
carousel = Carousel(direction='right')
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete_address, item[1]))
|
||||||
carousel.height = meny.height
|
self.ids.ml.add_widget(message_row)
|
||||||
carousel.size_hint_y = None
|
|
||||||
carousel.ignore_perpendicular_swipes = True
|
|
||||||
carousel.data_index = 0
|
|
||||||
carousel.min_move = 0.2
|
|
||||||
del_btn = Button(text='Delete')
|
|
||||||
del_btn.background_normal = ''
|
|
||||||
del_btn.background_color = (1, 0, 0, 1)
|
|
||||||
del_btn.bind(on_press=partial(self.delete_address, item[1]))
|
|
||||||
carousel.add_widget(del_btn)
|
|
||||||
carousel.add_widget(meny)
|
|
||||||
carousel.index = 1
|
|
||||||
self.ids.ml.add_widget(carousel)
|
|
||||||
|
|
||||||
def check_scroll_y(self, instance, somethingelse):
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
"""Load data on scroll"""
|
"""Load data on scroll"""
|
||||||
|
@ -117,34 +109,39 @@ class AddressBook(Screen):
|
||||||
# state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
|
# state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
|
||||||
|
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
def addBook_detail(self, address, label, *args):
|
def addBook_detail(self, address, label, instance, *args):
|
||||||
"""Addressbook details"""
|
"""Addressbook details"""
|
||||||
obj = AddbookDetailPopup()
|
if instance.state == 'closed':
|
||||||
self.address_label = obj.address_label = label
|
instance.ids.delete_msg.disabled = True
|
||||||
self.address = obj.address = address
|
if instance.open_progress == 0.0:
|
||||||
width = .9 if platform == 'android' else .8
|
obj = AddbookDetailPopup()
|
||||||
self.addbook_popup = MDDialog(
|
self.address_label = obj.address_label = label
|
||||||
type="custom",
|
self.address = obj.address = address
|
||||||
size_hint=(width, .25),
|
width = .9 if platform == 'android' else .8
|
||||||
content_cls=obj,
|
self.addbook_popup = MDDialog(
|
||||||
buttons=[
|
type="custom",
|
||||||
MDRaisedButton(
|
size_hint=(width, .25),
|
||||||
text="Send message to",
|
content_cls=obj,
|
||||||
on_release=self.send_message_to,
|
buttons=[
|
||||||
),
|
MDRaisedButton(
|
||||||
MDRaisedButton(
|
text="Send message to",
|
||||||
text="Save",
|
on_release=self.send_message_to,
|
||||||
on_release=self.update_addbook_label,
|
),
|
||||||
),
|
MDRaisedButton(
|
||||||
MDRaisedButton(
|
text="Save",
|
||||||
text="Cancel",
|
on_release=self.update_addbook_label,
|
||||||
on_release=self.close_pop,
|
),
|
||||||
),
|
MDRaisedButton(
|
||||||
],
|
text="Cancel",
|
||||||
)
|
on_release=self.close_pop,
|
||||||
# self.addbook_popup.set_normal_height()
|
),
|
||||||
self.addbook_popup.auto_dismiss = False
|
],
|
||||||
self.addbook_popup.open()
|
)
|
||||||
|
# self.addbook_popup.set_normal_height()
|
||||||
|
self.addbook_popup.auto_dismiss = False
|
||||||
|
self.addbook_popup.open()
|
||||||
|
else:
|
||||||
|
instance.ids.delete_msg.disabled = False
|
||||||
|
|
||||||
def delete_address(self, address, instance, *args):
|
def delete_address(self, address, instance, *args):
|
||||||
"""Delete inbox mail from inbox listing"""
|
"""Delete inbox mail from inbox listing"""
|
||||||
|
|
|
@ -18,7 +18,8 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, toast, ThemeClsColor,
|
showLimitedCnt, toast, ThemeClsColor,
|
||||||
chipTag, avatarImageFirstLetter, AddTimeWidget, AvatarSampleWidget
|
chipTag, avatarImageFirstLetter, AddTimeWidget,
|
||||||
|
AvatarSampleWidget, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
from bitmessagekivy.baseclass.trash import Trash
|
from bitmessagekivy.baseclass.trash import Trash
|
||||||
|
@ -94,36 +95,27 @@ 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]
|
||||||
meny = TwoLineAvatarIconListItem(
|
message_row = SwipeToDeleteItem(
|
||||||
text=item[1],
|
text = item[1],
|
||||||
secondary_text=(subject[:50] + '........' if len(
|
)
|
||||||
subject) >= 50 else (
|
listItem = message_row.ids.content
|
||||||
subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
secondary_text = (subject[:50] + '........' if len(
|
||||||
theme_text_color='Custom',
|
subject) >= 50 else (
|
||||||
text_color=ThemeClsColor)
|
subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', '')
|
||||||
meny._txt_right_pad = dp(70)
|
listItem.secondary_text = secondary_text
|
||||||
meny.add_widget(AvatarSampleWidget(
|
listItem.theme_text_color = "Custom"
|
||||||
|
listItem.text_color = ThemeClsColor
|
||||||
|
|
||||||
|
listItem.add_widget(AvatarSampleWidget(
|
||||||
source=state.imageDir + '/text_images/{}.png'.format(
|
source=state.imageDir + '/text_images/{}.png'.format(
|
||||||
avatarImageFirstLetter(body.strip()))))
|
avatarImageFirstLetter(body.strip()))))
|
||||||
meny.bind(on_press=partial(
|
listItem.bind(on_release=partial(
|
||||||
self.mail_detail, item[5], item[4]))
|
self.mail_detail, item[5], item[4], message_row))
|
||||||
meny.add_widget(AddTimeWidget(item[7]))
|
listItem.add_widget(AddTimeWidget(item[7]))
|
||||||
meny.add_widget(chipTag(item[4]))
|
listItem.add_widget(chipTag(item[4]))
|
||||||
carousel = Carousel(direction='right')
|
message_row.ids.delete_msg.bind(on_press=partial(
|
||||||
carousel.height = meny.height
|
|
||||||
carousel.size_hint_y = None
|
|
||||||
carousel.ignore_perpendicular_swipes = True
|
|
||||||
carousel.data_index = 0
|
|
||||||
carousel.min_move = 0.2
|
|
||||||
del_btn = Button(text='Delete')
|
|
||||||
del_btn.background_normal = ''
|
|
||||||
del_btn.background_color = (1, 0, 0, 1)
|
|
||||||
del_btn.bind(on_press=partial(
|
|
||||||
self.swipe_delete, item[5], item[4]))
|
self.swipe_delete, item[5], item[4]))
|
||||||
carousel.add_widget(del_btn)
|
self.ids.ml.add_widget(message_row)
|
||||||
carousel.add_widget(meny)
|
|
||||||
carousel.index = 1
|
|
||||||
self.ids.ml.add_widget(carousel)
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -140,18 +132,23 @@ class Allmails(Screen):
|
||||||
self.allMessageQuery(load_more, 5)
|
self.allMessageQuery(load_more, 5)
|
||||||
self.set_mdlist()
|
self.set_mdlist()
|
||||||
|
|
||||||
def mail_detail(self, unique_id, folder, *args):
|
def mail_detail(self, unique_id, folder, instance, *args):
|
||||||
"""Load sent and inbox mail details"""
|
"""Load sent and inbox mail details"""
|
||||||
state.detailPageType = folder
|
if instance.state == 'closed':
|
||||||
state.is_allmail = True
|
instance.ids.delete_msg.disabled = True
|
||||||
state.mail_id = unique_id
|
if instance.open_progress == 0.0:
|
||||||
if self.manager:
|
state.detailPageType = folder
|
||||||
src_mng_obj = self.manager
|
state.is_allmail = True
|
||||||
|
state.mail_id = unique_id
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[11].clear_widgets()
|
||||||
|
src_mng_obj.screens[11].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
else:
|
else:
|
||||||
src_mng_obj = self.parent.parent
|
instance.ids.delete_msg.disabled = False
|
||||||
src_mng_obj.screens[11].clear_widgets()
|
|
||||||
src_mng_obj.screens[11].add_widget(MailDetail())
|
|
||||||
src_mng_obj.current = 'mailDetail'
|
|
||||||
|
|
||||||
def swipe_delete(self, unique_id, folder, instance, *args):
|
def swipe_delete(self, unique_id, folder, instance, *args):
|
||||||
"""Delete inbox mail from all mail listing"""
|
"""Delete inbox mail from all mail listing"""
|
||||||
|
|
|
@ -13,7 +13,12 @@ from kivymd.uix.list import (
|
||||||
from kivy.uix.image import Image
|
from kivy.uix.image import Image
|
||||||
from kivymd.uix.label import MDLabel
|
from kivymd.uix.label import MDLabel
|
||||||
from bitmessagekivy.get_platform import platform
|
from bitmessagekivy.get_platform import platform
|
||||||
|
from kivymd.uix.card import MDCardSwipe
|
||||||
from kivymd.uix.chip import MDChip
|
from kivymd.uix.chip import MDChip
|
||||||
|
from kivy.properties import (
|
||||||
|
NumericProperty,
|
||||||
|
StringProperty
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
ThemeClsColor = [0.12, 0.58, 0.95, 1]
|
ThemeClsColor = [0.12, 0.58, 0.95, 1]
|
||||||
|
@ -127,3 +132,10 @@ class AvatarSampleWidget(ILeftBody, Image):
|
||||||
class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
|
class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
|
||||||
"""TimeTagRightSampleWidget class for Ui"""
|
"""TimeTagRightSampleWidget class for Ui"""
|
||||||
|
|
||||||
|
|
||||||
|
class SwipeToDeleteItem(MDCardSwipe):
|
||||||
|
text = StringProperty()
|
||||||
|
# cla = Window.size[0]/2
|
||||||
|
cla = 800
|
||||||
|
swipe_distance = NumericProperty(cla)
|
||||||
|
opening_time = NumericProperty(0.5)
|
||||||
|
|
|
@ -21,7 +21,8 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, toast, ThemeClsColor,
|
showLimitedCnt, toast, ThemeClsColor,
|
||||||
AddTimeWidget, AvatarSampleWidget
|
AddTimeWidget, AvatarSampleWidget,
|
||||||
|
SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
|
|
||||||
|
@ -101,30 +102,21 @@ class Draft(Screen):
|
||||||
third_text) > 25 else third_text,
|
third_text) > 25 else third_text,
|
||||||
'ackdata': mail[5], 'senttime': mail[6]})
|
'ackdata': mail[5], 'senttime': mail[6]})
|
||||||
for item in data:
|
for item in data:
|
||||||
meny = TwoLineAvatarIconListItem(
|
message_row = SwipeToDeleteItem(
|
||||||
text='Draft', secondary_text=item['text'],
|
text = 'Draft',
|
||||||
theme_text_color='Custom',
|
)
|
||||||
text_color=ThemeClsColor)
|
listItem = message_row.ids.content
|
||||||
meny._txt_right_pad = dp(70)
|
listItem.secondary_text = item["text"]
|
||||||
meny.add_widget(AvatarSampleWidget(
|
listItem.theme_text_color = "Custom"
|
||||||
|
listItem.text_color = ThemeClsColor
|
||||||
|
# meny._txt_right_pad = dp(70)
|
||||||
|
listItem.add_widget(AvatarSampleWidget(
|
||||||
source=state.imageDir + '/avatar.png'))
|
source=state.imageDir + '/avatar.png'))
|
||||||
meny.bind(on_press=partial(
|
listItem.bind(on_release=partial(
|
||||||
self.draft_detail, item['ackdata']))
|
self.draft_detail, item['ackdata'], message_row))
|
||||||
meny.add_widget(AddTimeWidget(item['senttime']))
|
listItem.add_widget(AddTimeWidget(item['senttime']))
|
||||||
carousel = Carousel(direction='right')
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete_draft, item['ackdata']))
|
||||||
carousel.height = meny.height
|
self.ids.ml.add_widget(message_row)
|
||||||
carousel.size_hint_y = None
|
|
||||||
carousel.ignore_perpendicular_swipes = True
|
|
||||||
carousel.data_index = 0
|
|
||||||
carousel.min_move = 0.2
|
|
||||||
del_btn = Button(text='Delete')
|
|
||||||
del_btn.background_normal = ''
|
|
||||||
del_btn.background_color = (1, 0, 0, 1)
|
|
||||||
del_btn.bind(on_press=partial(self.delete_draft, item['ackdata']))
|
|
||||||
carousel.add_widget(del_btn)
|
|
||||||
carousel.add_widget(meny)
|
|
||||||
carousel.index = 1
|
|
||||||
self.ids.ml.add_widget(carousel)
|
|
||||||
updated_msg = len(self.ids.ml.children)
|
updated_msg = len(self.ids.ml.children)
|
||||||
self.has_refreshed = True if total_draft_msg != updated_msg else False
|
self.has_refreshed = True if total_draft_msg != updated_msg else False
|
||||||
|
|
||||||
|
@ -140,17 +132,22 @@ class Draft(Screen):
|
||||||
self.draftDataQuery('fromaddress', where, what, total_draft_msg, 5)
|
self.draftDataQuery('fromaddress', where, what, total_draft_msg, 5)
|
||||||
self.set_mdList()
|
self.set_mdList()
|
||||||
|
|
||||||
def draft_detail(self, ackdata, *args):
|
def draft_detail(self, ackdata, instance, *args):
|
||||||
"""Show draft Details"""
|
"""Show draft Details"""
|
||||||
state.detailPageType = 'draft'
|
if instance.state == 'closed':
|
||||||
state.mail_id = ackdata
|
instance.ids.delete_msg.disabled = True
|
||||||
if self.manager:
|
if instance.open_progress == 0.0:
|
||||||
src_mng_obj = self.manager
|
state.detailPageType = 'draft'
|
||||||
|
state.mail_id = ackdata
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[11].clear_widgets()
|
||||||
|
src_mng_obj.screens[11].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
else:
|
else:
|
||||||
src_mng_obj = self.parent.parent
|
instance.ids.delete_msg.disabled = False
|
||||||
src_mng_obj.screens[11].clear_widgets()
|
|
||||||
src_mng_obj.screens[11].add_widget(MailDetail())
|
|
||||||
src_mng_obj.current = 'mailDetail'
|
|
||||||
|
|
||||||
def delete_draft(self, data_index, instance, *args):
|
def delete_draft(self, data_index, instance, *args):
|
||||||
"""Delete draft message permanently"""
|
"""Delete draft message permanently"""
|
||||||
|
|
|
@ -20,7 +20,8 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, avatarImageFirstLetter,
|
showLimitedCnt, avatarImageFirstLetter,
|
||||||
AddTimeWidget, ThemeClsColor, AvatarSampleWidget, toast
|
AddTimeWidget, ThemeClsColor, AvatarSampleWidget,
|
||||||
|
toast, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
from bitmessagekivy.baseclass.trash import Trash
|
from bitmessagekivy.baseclass.trash import Trash
|
||||||
|
@ -122,40 +123,25 @@ class Inbox(Screen):
|
||||||
"""This method is used to create the mdList"""
|
"""This method is used to create the mdList"""
|
||||||
total_message = len(self.ids.ml.children)
|
total_message = len(self.ids.ml.children)
|
||||||
for item in data:
|
for item in data:
|
||||||
meny = TwoLineAvatarIconListItem(
|
message_row = SwipeToDeleteItem(
|
||||||
text=item["text"],
|
text = item["text"],
|
||||||
secondary_text=item["secondary_text"],
|
|
||||||
theme_text_color="Custom",
|
|
||||||
text_color=ThemeClsColor
|
|
||||||
)
|
)
|
||||||
meny._txt_right_pad = dp(70)
|
listItem = message_row.ids.content
|
||||||
meny.add_widget(
|
listItem.secondary_text = item["secondary_text"]
|
||||||
|
listItem.theme_text_color = "Custom"
|
||||||
|
listItem.text_color = ThemeClsColor
|
||||||
|
listItem._txt_right_pad = dp(70)
|
||||||
|
listItem.add_widget(
|
||||||
AvatarSampleWidget(
|
AvatarSampleWidget(
|
||||||
source=state.imageDir + "/text_images/{}.png".format(
|
source=state.imageDir + "/text_images/{}.png".format(
|
||||||
avatarImageFirstLetter(item["secondary_text"].strip())
|
avatarImageFirstLetter(item["secondary_text"].strip())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
meny.bind(on_press=partial(self.inbox_detail, item["msgid"]))
|
listItem.bind(on_release=partial(self.inbox_detail, item["msgid"], message_row))
|
||||||
meny.add_widget(AddTimeWidget(item["received"]))
|
listItem.add_widget(AddTimeWidget(item["received"]))
|
||||||
carousel = Carousel(direction="right")
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete, item["msgid"]))
|
||||||
carousel.height = meny.height
|
self.ids.ml.add_widget(message_row)
|
||||||
carousel.size_hint_y = None
|
|
||||||
carousel.ignore_perpendicular_swipes = True
|
|
||||||
carousel.data_index = 0
|
|
||||||
carousel.min_move = 0.2
|
|
||||||
del_btn = Button(text="Delete")
|
|
||||||
del_btn.background_normal = ""
|
|
||||||
del_btn.background_color = (1, 0, 0, 1)
|
|
||||||
del_btn.bind(on_press=partial(self.delete, item["msgid"]))
|
|
||||||
carousel.add_widget(del_btn)
|
|
||||||
carousel.add_widget(meny)
|
|
||||||
# ach_btn = Button(text='Achieve')
|
|
||||||
# ach_btn.background_color = (0, 1, 0, 1)
|
|
||||||
# ach_btn.bind(on_press=partial(self.archive, item['msgid']))
|
|
||||||
# carousel.add_widget(ach_btn)
|
|
||||||
carousel.index = 1
|
|
||||||
self.ids.ml.add_widget(carousel)
|
|
||||||
update_message = len(self.ids.ml.children)
|
update_message = len(self.ids.ml.children)
|
||||||
self.has_refreshed = True if total_message != update_message else False
|
self.has_refreshed = True if total_message != update_message else False
|
||||||
|
|
||||||
|
@ -189,17 +175,22 @@ class Inbox(Screen):
|
||||||
)
|
)
|
||||||
self.set_mdList(data)
|
self.set_mdList(data)
|
||||||
|
|
||||||
def inbox_detail(self, msg_id, *args):
|
def inbox_detail(self, msg_id, instance,*args):
|
||||||
"""Load inbox page details"""
|
"""Load inbox page details"""
|
||||||
state.detailPageType = "inbox"
|
if instance.state == 'closed':
|
||||||
state.mail_id = msg_id
|
instance.ids.delete_msg.disabled = True
|
||||||
if self.manager:
|
if instance.open_progress == 0.0:
|
||||||
src_mng_obj = self.manager
|
state.detailPageType = "inbox"
|
||||||
|
state.mail_id = msg_id
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[11].clear_widgets()
|
||||||
|
src_mng_obj.screens[11].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = "mailDetail"
|
||||||
else:
|
else:
|
||||||
src_mng_obj = self.parent.parent
|
instance.ids.delete_msg.disabled = False
|
||||||
src_mng_obj.screens[11].clear_widgets()
|
|
||||||
src_mng_obj.screens[11].add_widget(MailDetail())
|
|
||||||
src_mng_obj.current = "mailDetail"
|
|
||||||
|
|
||||||
def delete(self, data_index, instance, *args):
|
def delete(self, data_index, instance, *args):
|
||||||
"""Delete inbox mail from inbox listing"""
|
"""Delete inbox mail from inbox listing"""
|
||||||
|
|
|
@ -19,7 +19,7 @@ import state
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
|
showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
|
||||||
AddTimeWidget, AvatarSampleWidget, toast
|
AddTimeWidget, AvatarSampleWidget, toast, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
from bitmessagekivy.baseclass.maildetail import MailDetail
|
from bitmessagekivy.baseclass.maildetail import MailDetail
|
||||||
|
|
||||||
|
@ -96,34 +96,22 @@ class Sent(Screen):
|
||||||
"""This method is used to create the mdList"""
|
"""This method is used to create the mdList"""
|
||||||
total_sent_msg = len(self.ids.ml.children)
|
total_sent_msg = len(self.ids.ml.children)
|
||||||
for item in data:
|
for item in data:
|
||||||
meny = TwoLineAvatarIconListItem(
|
message_row = SwipeToDeleteItem(
|
||||||
text=item['text'], secondary_text=item['secondary_text'],
|
text = item["text"],
|
||||||
theme_text_color='Custom',
|
)
|
||||||
text_color=ThemeClsColor)
|
listItem = message_row.ids.content
|
||||||
meny._txt_right_pad = dp(70)
|
listItem.secondary_text = item["secondary_text"]
|
||||||
meny.add_widget(AvatarSampleWidget(
|
listItem.theme_text_color = "Custom"
|
||||||
|
listItem.text_color = ThemeClsColor
|
||||||
|
listItem.add_widget(AvatarSampleWidget(
|
||||||
source=state.imageDir + '/text_images/{}.png'.format(
|
source=state.imageDir + '/text_images/{}.png'.format(
|
||||||
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
||||||
meny.bind(on_press=partial(self.sent_detail, item['ackdata']))
|
|
||||||
meny.add_widget(AddTimeWidget(item['senttime']))
|
listItem.bind(on_release=partial(self.sent_detail, item['ackdata'], message_row))
|
||||||
carousel = Carousel(direction='right')
|
listItem.add_widget(AddTimeWidget(item['senttime']))
|
||||||
carousel.height = meny.height
|
message_row.ids.delete_msg.bind(on_press=partial(self.delete, item["ackdata"]))
|
||||||
carousel.size_hint_y = None
|
self.ids.ml.add_widget(message_row, index=set_index)
|
||||||
carousel.ignore_perpendicular_swipes = True
|
|
||||||
carousel.data_index = 0
|
|
||||||
carousel.min_move = 0.2
|
|
||||||
del_btn = Button(text='Delete')
|
|
||||||
del_btn.background_normal = ''
|
|
||||||
del_btn.background_color = (1, 0, 0, 1)
|
|
||||||
del_btn.bind(on_press=partial(self.delete, item['ackdata']))
|
|
||||||
carousel.add_widget(del_btn)
|
|
||||||
carousel.add_widget(meny)
|
|
||||||
# ach_btn = Button(text='Achieve')
|
|
||||||
# ach_btn.background_color = (0, 1, 0, 1)
|
|
||||||
# ach_btn.bind(on_press=partial(self.archive, item['ackdata']))
|
|
||||||
# carousel.add_widget(ach_btn)
|
|
||||||
carousel.index = 1
|
|
||||||
self.ids.ml.add_widget(carousel, index=set_index)
|
|
||||||
updated_msgs = len(self.ids.ml.children)
|
updated_msgs = len(self.ids.ml.children)
|
||||||
self.has_refreshed = True if total_sent_msg != updated_msgs else False
|
self.has_refreshed = True if total_sent_msg != updated_msgs else False
|
||||||
|
|
||||||
|
@ -195,17 +183,22 @@ class Sent(Screen):
|
||||||
else:
|
else:
|
||||||
src_mng_obj.ids.badge_txt.text = '0'
|
src_mng_obj.ids.badge_txt.text = '0'
|
||||||
|
|
||||||
def sent_detail(self, ackdata, *args):
|
def sent_detail(self, ackdata, instance, *args):
|
||||||
"""Load sent mail details"""
|
"""Load sent mail details"""
|
||||||
state.detailPageType = 'sent'
|
if instance.state == 'closed':
|
||||||
state.mail_id = ackdata
|
instance.ids.delete_msg.disabled = True
|
||||||
if self.manager:
|
if instance.open_progress == 0.0:
|
||||||
src_mng_obj = self.manager
|
state.detailPageType = 'sent'
|
||||||
|
state.mail_id = ackdata
|
||||||
|
if self.manager:
|
||||||
|
src_mng_obj = self.manager
|
||||||
|
else:
|
||||||
|
src_mng_obj = self.parent.parent
|
||||||
|
src_mng_obj.screens[11].clear_widgets()
|
||||||
|
src_mng_obj.screens[11].add_widget(MailDetail())
|
||||||
|
src_mng_obj.current = 'mailDetail'
|
||||||
else:
|
else:
|
||||||
src_mng_obj = self.parent.parent
|
instance.ids.delete_msg.disabled = False
|
||||||
src_mng_obj.screens[11].clear_widgets()
|
|
||||||
src_mng_obj.screens[11].add_widget(MailDetail())
|
|
||||||
src_mng_obj.current = 'mailDetail'
|
|
||||||
|
|
||||||
def delete(self, data_index, instance, *args):
|
def delete(self, data_index, instance, *args):
|
||||||
"""Delete sent mail from sent mail listing"""
|
"""Delete sent mail from sent mail listing"""
|
||||||
|
|
|
@ -25,7 +25,7 @@ from bitmessagekivy.baseclass.common import (
|
||||||
|
|
||||||
from bitmessagekivy.baseclass.common import (
|
from bitmessagekivy.baseclass.common import (
|
||||||
toast, showLimitedCnt, ThemeClsColor, chipTag,
|
toast, showLimitedCnt, ThemeClsColor, chipTag,
|
||||||
AddTimeWidget, AvatarSampleWidget
|
AddTimeWidget, AvatarSampleWidget, SwipeToDeleteItem
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,36 +92,33 @@ 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]
|
||||||
meny = TwoLineAvatarIconListItem(
|
message_row = SwipeToDeleteItem(
|
||||||
text=item[1],
|
text = item[1],
|
||||||
secondary_text=(item[2][:50] + '........' if len(
|
)
|
||||||
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
message_row.bind(on_swipe_complete=partial(self.on_swipe_complete, message_row))
|
||||||
theme_text_color='Custom',
|
listItem = message_row.ids.content
|
||||||
text_color=ThemeClsColor)
|
listItem.secondary_text = (item[2][:50] + '........' if len(
|
||||||
meny._txt_right_pad = dp(70)
|
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(
|
img_latter = state.imageDir + '/text_images/{}.png'.format(
|
||||||
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
|
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
|
||||||
meny.add_widget(AvatarSampleWidget(source=img_latter))
|
listItem.add_widget(AvatarSampleWidget(source=img_latter))
|
||||||
meny.add_widget(AddTimeWidget(item[7]))
|
listItem.add_widget(AddTimeWidget(item[7]))
|
||||||
meny.add_widget(chipTag('inbox 'if 'inbox' in item[4] else 'sent'))
|
listItem.add_widget(chipTag('inbox 'if 'inbox' in item[4] else 'sent'))
|
||||||
carousel = Carousel(direction='right')
|
message_row.ids.delete_msg.bind(on_press=partial(
|
||||||
carousel.height = meny.height
|
self.delete_permanently, item[5], item[4]))
|
||||||
carousel.size_hint_y = None
|
self.ids.ml.add_widget(message_row)
|
||||||
carousel.ignore_perpendicular_swipes = True
|
|
||||||
carousel.data_index = 0
|
|
||||||
carousel.min_move = 0.2
|
|
||||||
del_btn = Button(text='Delete')
|
|
||||||
del_btn.background_normal = ''
|
|
||||||
del_btn.background_color = (1, 0, 0, 1)
|
|
||||||
del_btn.bind(on_press=partial(
|
|
||||||
self.delete_permanently, item[5], item[4]))
|
|
||||||
carousel.add_widget(del_btn)
|
|
||||||
carousel.add_widget(meny)
|
|
||||||
carousel.index = 1
|
|
||||||
self.ids.ml.add_widget(carousel)
|
|
||||||
self.has_refreshed = True if total_trash_msg != len(
|
self.has_refreshed = True if total_trash_msg != len(
|
||||||
self.ids.ml.children) else False
|
self.ids.ml.children) else False
|
||||||
|
|
||||||
|
def on_swipe_complete(self, instance, *args):
|
||||||
|
if instance.state == 'closed':
|
||||||
|
instance.ids.delete_msg.disabled = True
|
||||||
|
else:
|
||||||
|
instance.ids.delete_msg.disabled = False
|
||||||
|
|
||||||
def check_scroll_y(self, instance, somethingelse):
|
def check_scroll_y(self, instance, somethingelse):
|
||||||
"""Load data on scroll"""
|
"""Load data on scroll"""
|
||||||
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
if self.ids.scroll_y.scroll_y <= -0.0 and self.has_refreshed:
|
||||||
|
|
|
@ -342,3 +342,24 @@ MDNavigationLayout:
|
||||||
on_press: app.root.ids.scr_mngr.current = 'create'
|
on_press: app.root.ids.scr_mngr.current = 'create'
|
||||||
on_press: app.clear_composer()
|
on_press: app.clear_composer()
|
||||||
|
|
||||||
|
|
||||||
|
<SwipeToDeleteItem>:
|
||||||
|
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
|
||||||
|
|
Reference in New Issue
Block a user