1+ from kivy .lang .builder import Builder
2+ from kivymd .app import MDApp
3+ from kivymd .uix .card import MDCard #
4+ from kivymd .uix .toolbar import MDTopAppBar
5+ from kivymd .uix .behaviors import RoundedRectangularElevationBehavior
6+
7+ KV = '''
8+ #:import SliverToolbar __main__.SliverToolbar
9+
10+
11+ <CardItem>
12+ size_hint_y: None
13+ height: "86dp"
14+ padding: "4dp"
15+ radius: 12
16+ elevation: 4
17+
18+ FitImage:
19+ source: "avatar.jpg"
20+ radius: root.radius
21+ size_hint_x: None
22+ width: root.height
23+
24+ MDBoxLayout:
25+ orientation: "vertical"
26+ adaptive_height: True
27+ spacing: "6dp"
28+ padding: "12dp", 0, 0, 0
29+ pos_hint: {"center_y": .5}
30+
31+ MDLabel:
32+ text: "Title text"
33+ font_style: "H5"
34+ bold: True
35+ adaptive_height: True
36+
37+ MDLabel:
38+ text: "Subtitle text"
39+ theme_text_color: "Hint"
40+ adaptive_height: True
41+
42+
43+ MDScreen:
44+
45+ MDSliverAppbar:
46+ background_color: "2d4a50"
47+ toolbar_cls: SliverToolbar()
48+
49+ MDSliverAppbarHeader:
50+
51+ MDRelativeLayout:
52+
53+ FitImage:
54+ source: "avatar.jpg"
55+
56+ MDSliverAppbarContent:
57+ id: content
58+ orientation: "vertical"
59+ padding: "12dp"
60+ spacing: "12dp"
61+ adaptive_height: True
62+ '''
63+
64+
65+ class CardItem (MDCard , RoundedRectangularElevationBehavior ):
66+ pass
67+
68+
69+ class SliverToolbar (MDTopAppBar ):
70+ def __init__ (self , ** kwargs ):
71+ super ().__init__ (** kwargs )
72+ self .type_height = "medium"
73+ self .headline_text = "Headline medium"
74+ self .left_action_items = [["arrow-left" , lambda x : x ]]
75+ self .right_action_items = [
76+ ["attachment" , lambda x : x ],
77+ ["calendar" , lambda x : x ],
78+ ["dots-vertical" , lambda x : x ],
79+ ]
80+
81+
82+ class Example (MDApp ):
83+ def build (self ):
84+ self .theme_cls .material_style = "M3"
85+ return Builder .load_string (KV )
86+
87+ def on_start (self ):
88+ for x in range (10 ):
89+ self .root .ids .content .add_widget (CardItem ())
90+
91+ if __name__ == '__main__' :
92+ Example ().run ()
93+
94+
95+ a = 1661480862
96+ import time
97+ time .time ()
0 commit comments