kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.22k stars 671 forks source link

MDTabs lock_swiping improvement. #561

Closed BananaMasterz closed 1 year ago

BananaMasterz commented 4 years ago

Description of the Feature

I seem to be unable to create a pull request (I'm a noob when it comes to git hub and updating forks) so I'll just post this here hoping someone will add it:

I propose to add scroll_timeout: 0 if root.lock_swiping else 200 here:

MDTabsCarousel:
    id: carousel
    lock_swiping: root.lock_swiping
    ignore_perpendicular_swipes: True
    anim_move_duration: root.anim_duration
    on_index: root.on_carousel_index(*args)
    on__offset: tab_bar.android_animation(*args)
    on_slides: self.index = root.default_tab
    on_slides: root.on_carousel_index(self, 0)
    scroll_timeout: 0 if root.lock_swiping else 200

This would make a scrollview inside of a tab more responsive to touch. Otherwise you have to touch the screen and wait 200 milliseconds before scrolling which I think is unnecessary if lock_swiping is set to true.

dwmoffatt commented 4 years ago

@BananaMasterz Do you have sample code that I can test this against?

If it works, I will happily create a PR for after I test it.

BananaMasterz commented 4 years ago

@dwmoffatt

from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout

from kivymd.app import MDApp
from kivymd.uix.tab import MDTabsBase
from kivymd.icon_definitions import md_icons

KV = '''
BoxLayout:

    BoxLayout:
        orientation: "vertical"

        MDToolbar:
            title: "Normal Tabs"

        MDTabs:
            id: tabs

            Tab:
                text: 'one'

            Tab:
                text: 'two'

    BoxLayout:
        orientation: "vertical"

        MDToolbar:
            title: "Tabs With locked swiping"

        MDTabs:
            id: tabs
            lock_swiping: True

            Tab:
                text: 'one'

            Tab:
                text: 'two'

<Tab>:
    ScrollView:

        BoxLayout:
            size_hint: None,None
            width: dp(2000)
            height: dp(1000)
            padding: [dp(100),]
            MDIconButton:
                icon: 'email'
                user_font_size: "48sp"
                pos_hint: {"center_x": 1, "center_y": .8}
'''

class Tab(FloatLayout, MDTabsBase):
    '''Class implementing content for a tab.'''

class Example(MDApp):

    def build(self):
        return Builder.load_string(KV)

Example().run()

Try holding down the mouse and moving around on the left and then on the right. You'll see that on the right it takes some time to respond. Then go to the tabs.py library and add the line I mentioned above and test it again.

dwmoffatt commented 4 years ago

I will try this out today!

podraco commented 3 years ago

Is there any update on this?

HeaTTheatR commented 1 year ago

Deprecated. The API of the MDTabs widget in 1.3.0 version has been break.