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
for child in self.root.ids.messages_scrollview.children:
self.root.ids.messages_scrollview.remove_widget(child)
RNS.log("Removed "+str(child))
list_widget = self.messages_view.get_widget()

View File

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

View File

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

View File

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

View File

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