Improved dropdown behaviour and widget allocation

This commit is contained in:
Mark Qvist 2022-10-08 19:23:51 +02:00
parent bfd96a98ac
commit c54422d771
5 changed files with 47 additions and 33 deletions

View File

@ -480,7 +480,6 @@ class SidebandApp(MDApp):
self.root.ids.messages_scrollview.effect_cls = ScrollEffect self.root.ids.messages_scrollview.effect_cls = ScrollEffect
for child in self.root.ids.messages_scrollview.children: for child in self.root.ids.messages_scrollview.children:
self.root.ids.messages_scrollview.remove_widget(child) self.root.ids.messages_scrollview.remove_widget(child)
RNS.log("Removed "+str(child))
list_widget = self.messages_view.get_widget() list_widget = self.messages_view.get_widget()

View File

@ -201,6 +201,8 @@ class Announces():
width_mult=4, width_mult=4,
elevation=1, elevation=1,
radius=dp(3), radius=dp(3),
opening_transition="linear",
opening_time=0.0,
) )
def callback_factory(ref): def callback_factory(ref):

View File

@ -32,6 +32,7 @@ class Conversations():
self.context_dests = [] self.context_dests = []
self.added_item_dests = [] self.added_item_dests = []
self.list = None self.list = None
self.conversation_dropdown = None
self.update() self.update()
def reload(self): def reload(self):
@ -85,6 +86,7 @@ class Conversations():
def gen_edit(dest, item): def gen_edit(dest, item):
def x(): def x():
dest = self.conversation_dropdown.context_dest
try: try:
disp_name = self.app.sideband.raw_display_name(dest) disp_name = self.app.sideband.raw_display_name(dest)
is_trusted = self.app.sideband.is_trusted(dest) is_trusted = self.app.sideband.is_trusted(dest)
@ -140,6 +142,7 @@ class Conversations():
def gen_clear(dest, item): def gen_clear(dest, item):
def x(): def x():
dest = self.conversation_dropdown.context_dest
yes_button = MDFlatButton( yes_button = MDFlatButton(
text="Yes", text="Yes",
) )
@ -178,7 +181,7 @@ class Conversations():
) )
def dl_yes(s): def dl_yes(s):
dialog.dismiss() dialog.dismiss()
self.app.sideband.delete_conversation(dest) self.app.sideband.delete_conversation(self.conversation_dropdown.context_dest)
self.reload() self.reload()
def dl_no(s): def dl_no(s):
dialog.dismiss() dialog.dismiss()
@ -189,44 +192,51 @@ class Conversations():
dialog.open() dialog.open()
return x return x
if self.conversation_dropdown == None:
dmi_h = 40
dm_items = [ dm_items = [
{ {
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"text": "Edit", "text": "Edit",
"height": dp(40), "height": dp(dmi_h),
"on_release": gen_edit(context_dest, item) "on_release": gen_edit(context_dest, item)
}, },
{ {
"text": "Clear Messages", "text": "Clear Messages",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"height": dp(40), "height": dp(dmi_h),
"on_release": gen_clear(context_dest, item) "on_release": gen_clear(context_dest, item)
}, },
{ {
"text": "Delete Conversation", "text": "Delete Conversation",
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"height": dp(40), "height": dp(dmi_h),
"on_release": gen_del(context_dest, item) "on_release": gen_del(context_dest, item)
} }
] ]
item.iconr = IconRightWidget(icon="dots-vertical"); self.conversation_dropdown = MDDropdownMenu(
caller=None,
item.dmenu = MDDropdownMenu(
caller=item.iconr,
items=dm_items, items=dm_items,
position="auto", position="auto",
width_mult=4, width_mult=4,
elevation=1, elevation=1,
radius=dp(3), radius=dp(3),
opening_transition="linear",
opening_time=0.0,
) )
def callback_factory(ref): item.iconr = IconRightWidget(icon="dots-vertical");
item.dmenu = self.conversation_dropdown
def callback_factory(ref, dest):
def x(sender): def x(sender):
self.conversation_dropdown.context_dest = dest
ref.dmenu.caller = ref.iconr
ref.dmenu.open() ref.dmenu.open()
return x return x
item.iconr.bind(on_release=callback_factory(item)) item.iconr.bind(on_release=callback_factory(item, context_dest))
item.add_widget(item.iconr) item.add_widget(item.iconr)

View File

@ -925,6 +925,7 @@ MDNavigationLayout:
ContentNavigationDrawer: ContentNavigationDrawer:
ScrollView: ScrollView:
id: nav_scrollview
DrawerList: DrawerList:
id: md_list id: md_list

View File

@ -214,6 +214,8 @@ class Messages():
width_mult=4, width_mult=4,
elevation=1, elevation=1,
radius=dp(3), radius=dp(3),
opening_transition="linear",
opening_time=0.0,
) )
def callback_factory(ref): def callback_factory(ref):