KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

MDTabs lock_swiping improvement.

Open BananaMasterz opened this issue 3 years ago • 4 comments

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.

BananaMasterz avatar Oct 02 '20 10:10 BananaMasterz

@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.

dwmoffatt avatar Oct 02 '20 21:10 dwmoffatt

@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.

BananaMasterz avatar Oct 03 '20 06:10 BananaMasterz

I will try this out today!

dwmoffatt avatar Oct 03 '20 15:10 dwmoffatt

Is there any update on this?

podraco avatar Feb 19 '21 02:02 podraco

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

HeaTTheatR avatar Aug 27 '23 14:08 HeaTTheatR