When I run app and click button that do:
def show_example_custom_bottom_sheet(self):
self.custom_sheet = MDCustomBottomSheet(screen=Factory.ContentCustomSheet(),
radius_from="top",
radius=25,
animation=True
)
self.custom_sheet.open()
BottomSheet opens after about 1 second or less. The main question is: Can i do something to prevent that or I just need to wait until KivyMD 1.2 will be released and maybe it will be changed? Below is my code in a shorter form.
from kivy.lang import Builder
from kivy.factory import Factory
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition, SwapTransition, SlideTransition, \
CardTransition, WipeTransition, RiseInTransition
from kivymd.uix.bottomsheet import MDCustomBottomSheet
from kivymd.app import MDApp
from kivymd.uix.button import MDRoundFlatIconButton
KV = '''
#=================================================================================================
#Renamed & Set
<NovaButton@OneLineAvatarIconListItem>:
#radius: 20
#_no_ripple_effect: True
<BackButton>:
pos_hint: {"left": 1}
font_size: "18dp"
icon: "chevron-left"
_no_ripple_effect: True
line_color: 0, 0, 0, 0
<CenterLabel@MDLabel>:
font_size: "24dp"
halign: "center"
size_hint: 0.5, 1
#=================================================================================================
#ScreenManger inside BottomSheet (Content of BottomSheet below that)
<MenuScreenManager>:
id: id_screen_manager
ScreenMain:
id: id_screen_main
name: "screen_main"
ScrollView:
MDGridLayout:
adaptive_height: True
cols: 1
NovaButton:
text: "Language"
on_release: id_screen_manager.screen_change("go", "language")
IconLeftWidgetWithoutTouch:
icon: "earth"
IconRightWidgetWithoutTouch:
icon: "chevron-right"
NovaButton:
text: "Record"
on_release: id_screen_manager.screen_change("go", "record")
IconLeftWidgetWithoutTouch:
icon: "video-image"
IconRightWidgetWithoutTouch:
icon: "chevron-right"
ScreenLanguage:
id: id_screen_language
name: "screen_language"
BoxLayout:
orientation: "vertical"
GridLayout:
size_hint: 1, None
height: "50dp"
cols: 3
#Menu on top (BackButton & CenterLabel & free space)
BoxLayout:
size_hint: 0.25, 1
BackButton:
text: "Settings"
on_release: id_screen_manager.screen_change("back", "main")
CenterLabel
text: "Language"
BoxLayout:
size_hint: 0.25, 1
ScrollView:
MDGridLayout:
adaptive_height: True
cols: 1
TwoLineRightIconListItem:
text: "Polski"
secondary_text: "Polish"
secondary_font_style: "Body2"
radius: 20, 20, 20, 20
TwoLineRightIconListItem:
text: "English"
secondary_text: "English"
secondary_font_style: "Body2"
IconRightWidgetWithoutTouch:
icon: "check"
TwoLineRightIconListItem:
text: "Deutsch"
secondary_text: "German"
secondary_font_style: "Body2"
ScreenRecord:
id: id_screen_record
name: "screen_record"
BoxLayout:
orientation: "vertical"
GridLayout:
size_hint: 1, None
height: "50dp"
cols: 3
#Menu on top (BackButton & CenterLabel & free space)
BoxLayout:
size_hint: 0.25, 1
BackButton:
text: "Settings"
on_release: id_screen_manager.screen_change("back", "main")
CenterLabel:
text: "Record"
BoxLayout:
size_hint: 0.25, 1
ScrollView:
MDGridLayout:
adaptive_height: True
cols: 1
NovaButton:
text: "Record"
on_release: id_screen_record.screen_change("back_to_menu")
IconLeftWidgetWithoutTouch:
icon: "video-outline"
IconRightWidgetWithoutTouch:
icon: "chevron-right"
#=================================================================================================
#Content of BottomSheet
<ContentCustomSheet>:
orientation: "vertical"
size_hint_y: None
height: Window.size[1]/2
md_bg_color: 1, 1, 1, 0
MDAnchorLayout:
size_hint: 1, None
height: "50dp"
MDIcon:
icon: "minus"
font_size: "40dp"
color: 0.8, 0.8, 0.8
# icon_size: "40dp"
# theme_icon_color: "Custom"
# icon_color: 0.8, 0.8, 0.8
size_hint: 1, 1
pos_hint: {"center_x": .5, "center_y": 1}
#on_release: app.custom_sheet.dismiss()
MenuScreenManager:
#=================================================================================================
#Screen at beginning
MDScreen:
MDIconButton: #<-- MenuButton
icon: "menu"
size_hint: 0.1, 0.1
icon_size: "50dp"
pos_hint: {"center_x": .5, "bottom": 1}
on_release: app.show_example_custom_bottom_sheet()
'''
class ContentCustomSheet(BoxLayout):
pass
class BackButton(MDRoundFlatIconButton):
pass
class MenuScreenManager(ScreenManager):
def screen_change(self, direct, to):
match direct:
case "go":
self.transition.direction = "left"
case "back":
self.transition.direction = "right"
self.current = f"screen_{to}"
class ScreenMain(Screen):
pass
class ScreenLanguage(Screen):
pass
class ScreenRecord(Screen):
pass
class Example(MDApp):
custom_sheet = None
sm = ScreenManager(transition=SwapTransition())
sm.add_widget(ScreenMain(name="screen_main"))
sm.add_widget(ScreenLanguage(name="screen_language"))
sm.add_widget(ScreenRecord(name="screen_record"))
def build(self):
self.theme_cls.theme_style = "Dark"
return Builder.load_string(KV)
def show_example_custom_bottom_sheet(self):
self.custom_sheet = MDCustomBottomSheet(screen=Factory.ContentCustomSheet(),
radius_from="top",
radius=25,
animation=True
)
self.custom_sheet.open()
Example().run()
I know that it can occur, because of creating every time self.custom_sheet (like it should I guess), but after trying to solve that I checked example code in kivymd documentation and it lags there a bit too. I tried to seperate Screens from "Content" to make the program have a bit less to load, but It did nothing. Maybe it just cannot be changed.