Skip to content

Commit fe5eca6

Browse files
committed
dock test
1 parent 19576d4 commit fe5eca6

File tree

6 files changed

+191
-84
lines changed

6 files changed

+191
-84
lines changed

Diff for: examples/search.py

+61-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
from kivy.lang import Builder
22
from kivymd.app import MDApp
3+
from kivymd.uix.list import MDListItem
34
from examples.common_app import CommonApp
4-
from faker import Faker
5+
from kivy.properties import StringProperty
6+
from kivymd.icon_definitions import md_icons
7+
8+
class IconItem(MDListItem):
9+
icon = StringProperty()
10+
text = StringProperty()
511

612
MAIN_KV = """
713
#: import images_path kivymd.images_path
814
15+
<IconItem>
16+
divider: True
17+
MDListItemLeadingIcon:
18+
icon: root.icon
19+
20+
MDListItemSupportingText:
21+
text: root.text
22+
923
MDScreen:
1024
md_bg_color:app.theme_cls.backgroundColor
1125
BoxLayout:
12-
padding:[dp(10), dp(50)]
26+
padding:[dp(10), dp(30), dp(10), dp(10)]
1327
orientation:"vertical"
1428
1529
MDSearchBar:
@@ -20,7 +34,8 @@
2034
# Search Bar
2135
MDSearchBarLeadingContainer:
2236
MDSearchLeadingIcon:
23-
icon:"magnify"
37+
icon: "menu"
38+
on_release: app.open_menu(self)
2439
2540
MDSearchBarTrailingContainer:
2641
MDSearchTrailingIcon:
@@ -39,20 +54,56 @@
3954
icon:"window-close"
4055
4156
MDSearchViewContainer:
42-
MDLabel:
43-
text:"Hello World!"
57+
RecycleView:
58+
id: rv
59+
key_viewclass: 'viewclass'
60+
key_size: 'height'
4461
62+
RecycleBoxLayout:
63+
default_size: None, dp(48)
64+
default_size_hint: 1, None
65+
size_hint_y: None
66+
height: self.minimum_height
67+
orientation: 'vertical'
4568
Widget:
46-
MDSwitch:
47-
on_active:app.theme_cls.theme_style = "Dark" if app.theme_cls.theme_style == "Light" else "Light"
48-
Widget:
49-
5069
70+
BoxLayout:
71+
size_hint_y:None
72+
height:dp(30)
73+
padding:[dp(50), 0]
74+
spacing:dp(10)
75+
MDLabel:
76+
text:"Bar dock"
77+
halign:"right"
78+
MDSwitch:
79+
on_active:search_bar.docked = args[-1]
5180
"""
5281

5382
class Example(MDApp, CommonApp):
54-
fake = Faker()
83+
5584
def build(self):
5685
return Builder.load_string(MAIN_KV)
5786

87+
def on_start(self):
88+
self.set_list_md_icons()
89+
90+
def set_list_md_icons(self, text="", search=False):
91+
def add_icon_item(name_icon):
92+
self.root.ids.rv.data.append(
93+
{
94+
"viewclass": "IconItem",
95+
"icon": name_icon,
96+
"text": name_icon,
97+
"callback": lambda x: x,
98+
}
99+
)
100+
101+
self.root.ids.rv.data = []
102+
for name_icon in md_icons.keys():
103+
if search:
104+
if text in name_icon:
105+
add_icon_item(name_icon)
106+
else:
107+
add_icon_item(name_icon)
108+
58109
Example().run()

Diff for: kivymd/uix/list/list.kv

+1-12
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@
88
# Divider.
99
canvas.after:
1010
Color:
11-
rgba:
12-
( \
13-
( \
14-
self.theme_cls.surfaceVariantColor \
15-
if not self.disabled else \
16-
self.theme_cls.onSurfaceColor \
17-
) \
18-
if self.theme_divider_color == "Primary" else \
19-
self.divider_color
20-
) \
21-
22-
if self.divider else self.theme_cls.transparentColor
11+
rgba:self.theme_cls.transparentColor
2312
Line:
2413
width: 1
2514
points: self.x ,self.y, self.x + self.width, self.y

Diff for: kivymd/uix/list/list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def __init__(self, *args, **kwargs):
397397

398398
class BaseListItem(
399399
DeclarativeBehavior,
400-
BackgroundColorBehavior,
400+
# BackgroundColorBehavior,
401401
RectangularRippleBehavior,
402402
ButtonBehavior,
403403
ThemableBehavior,

Diff for: kivymd/uix/search/search.kv

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
[self.x+self.width, self.y+self.height]]
4545

4646
<MDSearchWidget>:
47+
size_hint:[1,1]
4748
MDBoxLayout:
4849
id: root_container
4950
orientation: 'vertical'
@@ -67,7 +68,6 @@
6768
multiline: False
6869
font_size: root._font_style["font-size"]
6970
on_focus: if args[-1]: root.switch_state("open")
70-
Widget:
7171
<MDSearchBar>:
7272
size_hint_y: None
7373
height: dp(56)

0 commit comments

Comments
 (0)