Skip to content

Commit

Permalink
day 2 progress
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Dynamos committed Jan 16, 2025
1 parent 20f7a0b commit 19576d4
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 113 deletions.
36 changes: 28 additions & 8 deletions examples/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,38 @@
MDScreen:
md_bg_color:app.theme_cls.backgroundColor
BoxLayout:
padding:[dp(10), dp(10)]
padding:[dp(10), dp(50)]
orientation:"vertical"
MDSearchBar:
id:bar
id: search_bar
supporting_text: "Search in text"
# if you want it to be of fixed size
# adaptive_width:True
MDSearchTrailingIcon:
icon:"microphone"
MDSearchTrailingAvatar:
source:f"{images_path}/logo/kivymd-icon-128.png"
view_root: root
# Search Bar
MDSearchBarLeadingContainer:
MDSearchLeadingIcon:
icon:"magnify"
MDSearchBarTrailingContainer:
MDSearchTrailingIcon:
icon:"microphone"
MDSearchTrailingAvatar:
source:f"{images_path}/logo/kivymd-icon-128.png"
# Search View
MDSearchViewLeadingContainer:
MDSearchLeadingIcon:
icon:"arrow-left"
on_release: search_bar.close_view()
MDSearchViewTrailingContainer:
MDSearchTrailingIcon:
icon:"window-close"
MDSearchViewContainer:
MDLabel:
text:"Hello World!"
Widget:
MDSwitch:
Expand Down
7 changes: 6 additions & 1 deletion kivymd/factory_registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
register("MDHeroFrom", module="kivymd.uix.hero")
register("MDHeroTo", module="kivymd.uix.hero")
register("MDSearchBar", module="kivymd.uix.search")
register("MDSearchView", module="kivymd.uix.search")
register("MDSearchTrailingAvatar", module="kivymd.uix.search")
register("MDSearchTrailingIcon", module="kivymd.uix.search")
register("MDSearchLeadingIcon", module="kivymd.uix.search")
register("MDSearchViewContainer", module="kivymd.uix.search")
register("MDSearchBarLeadingContainer", module="kivymd.uix.search")
register("MDSearchBarTrailingContainer", module="kivymd.uix.search")
register("MDSearchViewLeadingContainer", module="kivymd.uix.search")
register("MDSearchViewTrailingContainer", module="kivymd.uix.search")
7 changes: 1 addition & 6 deletions kivymd/uix/search/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
from .search import (
MDSearchBar,
MDSearchTrailingAvatar,
MDSearchTrailingIcon,
MDSearchView,
)
from .search import *
121 changes: 59 additions & 62 deletions kivymd/uix/search/search.kv
Original file line number Diff line number Diff line change
@@ -1,76 +1,73 @@
#: import images_path kivymd.images_path

<MDSearchTrailingAvatar>:
size_hint_x: None
width: dp(30)

<MDSearchTrailingIcon>:
size_hint: [None, 1]
width: dp(24)
theme_icon_color: "Custom"
icon_color: app.theme_cls.onSurfaceColor

<MDSearchView>:
overlay_color: [0] * 4
background: f"{images_path}/transparent.png"
boder: [0] * 4
_anim_duration: 0
FloatLayout
MDBoxLayout:
id: root_container
orientation: 'vertical'
md_bg_color: app.theme_cls.surfaceContainerHighColor
adaptive_height: True
size_hint_x: None
canvas:
Color:
rgba: app.theme_cls.outlineColor
Line:
points:
[[self.x,self.y-root._header_height+self.height],
[self.x+self.width, self.y-root._header_height+self.height]]
BoxLayout:
size_hint_y: None
height: root._header_height
spacing: dp(16)
padding: [dp(16), 0]
MDIconButton:
icon: "arrow-left"
size_hint: [None, 1]
width: dp(24)
on_release: root.close_view()
theme_icon_color: "Custom"
icon_color: app.theme_cls.onSurfaceColor
<MDSearchLeadingIcon>:
size_hint: [None, 1]
width: dp(24)
icon_color: app.theme_cls.onSurfaceColor

BoxLayout:
size_hint: [None, None]
size:[ dp(360), dp(240)]
<MDSearchBarTrailingContainer>:
size_hint_x: None
width: self.minimum_width
spacing: dp(16)

<MDSearchBarLeadingContainer>:
size_hint_x: None
width: self.minimum_width
spacing: dp(16)

<MDSearchViewTrailingContainer>:
size_hint_x: None
width: self.minimum_width
spacing: dp(16)

<MDSearchViewLeadingContainer>:
size_hint_x: None
width: self.minimum_width
spacing: dp(16)

<MDSearchViewContainer>:
size_hint_y:None
height:dp(55)
canvas:
Color:
rgba: app.theme_cls.outlineColor
Line:
points:
[[self.x,self.y+self.height],
[self.x+self.width, self.y+self.height]]

<MDSearchWidget>:
MDBoxLayout:
id: root_container
orientation: 'vertical'
md_bg_color: app.theme_cls.surfaceContainerHighColor
size_hint: [None, None]
orientation: 'vertical'
# header
BoxLayout:
id: header
padding: [dp(16), 0]
spacing: dp(16)
size_hint_y: None
height: dp(56)
TextInput:
id: text_input
background_color:[0,0,0,0]
foreground_color: app.theme_cls.onSurfaceColor
cursor_color:app.theme_cls.outlineColor
hint_text_color: app.theme_cls.onSurfaceVariantColor
padding: [0, (self.parent.height - self.font_size - dp(3)) / 2]
multiline: False
font_size: root._font_style["font-size"]
on_focus: if args[-1]: root.switch_state("open")
Widget:
<MDSearchBar>:
size_hint_y: None
height: dp(56)
md_bg_color: app.theme_cls.surfaceContainerHighColor
radius: dp(28)
spacing: dp(16)
padding: [dp(16), 0]
adaptive_width: False
on_release: self._search_view.open_view()
MDIconButton:
icon: root.leading_icon
size_hint: [None, 1]
width: dp(24)
on_release: root.on_leading_icon_release()
on_press: root.on_leading_icon_press()
theme_icon_color: "Custom"
icon_color: app.theme_cls.onSurfaceColor
MDLabel:
text: root.supporting_text
theme_text_color: "Custom"
text_color: app.theme_cls.onSurfaceVariantColor
theme_font_size: "Custom"
font_style: "Title"
role: "medium"
size_hint_x: None
padding: root._supporting_text_padding if root.adaptive_width else 0
adaptive_width:root.adaptive_width
size_hint_x: 1 if not root.adaptive_width else None
Loading

0 comments on commit 19576d4

Please sign in to comment.