|
| 1 | +from kivy.lang import Builder |
| 2 | +import os |
| 3 | +import kivymd |
| 4 | +from kivymd.app import MDApp |
| 5 | +from kivy.uix.screenmanager import ScreenManager |
| 6 | +from kivymd.uix.screen import MDScreen |
| 7 | +from kivymd.uix.transition import MDSharedAxisTransition |
| 8 | +from examples.common_app import CommonApp |
| 9 | + |
| 10 | +KV = """ |
| 11 | +<Check@MDCheckbox>: |
| 12 | + group: 'group' |
| 13 | + size_hint: None, 1 |
| 14 | + width:self.height |
| 15 | +
|
| 16 | +<SettingsItem@ButtonBehavior+BoxLayout>: |
| 17 | + icon:"wifi" |
| 18 | + text:"Network & Internet" |
| 19 | + subtext:"Network settings" |
| 20 | + size_hint_y:None |
| 21 | + height:dp(70) |
| 22 | + padding:dp(10) |
| 23 | + spacing:dp(10) |
| 24 | + on_release: |
| 25 | + app.root.get_screen("battery").ids.main_icon.icon = self.icon |
| 26 | + app.root.get_screen("battery").ids.main_text.text = self.text |
| 27 | + app.root.transition.opposite = False |
| 28 | + app.root.current = "battery" |
| 29 | + MDIconButton: |
| 30 | + style: "tonal" |
| 31 | + size_hint:None, 1 |
| 32 | + width:self.height |
| 33 | + icon:root.icon |
| 34 | + BoxLayout: |
| 35 | + orientation:"vertical" |
| 36 | + MDLabel: |
| 37 | + text:root.text |
| 38 | + font_style:"Title" |
| 39 | + role:"medium" |
| 40 | + MDLabel: |
| 41 | + text:root.subtext |
| 42 | + font_style:"Label" |
| 43 | + role:"large" |
| 44 | + theme_text_color:"Custom" |
| 45 | + text_color:app.theme_cls.surfaceContainerLowestColor[:-1] + [0.5] |
| 46 | + |
| 47 | +<SettingsScreen@MDScreen>: |
| 48 | + name:"main" |
| 49 | + md_bg_color:app.theme_cls.surfaceContainerLowColor |
| 50 | + MDBoxLayout: |
| 51 | + padding:[dp(10), 0] |
| 52 | + orientation:"vertical" |
| 53 | + BoxLayout: |
| 54 | + size_hint_y:None |
| 55 | + height:dp(70) |
| 56 | + padding:[0, dp(10)] |
| 57 | + MDIconButton: |
| 58 | + size_hint:None, None |
| 59 | + size:[dp(50)] * 2 |
| 60 | + on_release: app.open_menu(self) |
| 61 | + icon: "menu" |
| 62 | + Widget: |
| 63 | + MDIconButton: |
| 64 | + size_hint:None, None |
| 65 | + size:[dp(50)] * 2 |
| 66 | + on_release: app.open_menu(self) |
| 67 | + icon: "magnify" |
| 68 | + MDIconButton: |
| 69 | + size_hint:None, None |
| 70 | + size:[dp(50)] * 2 |
| 71 | + on_release: app.open_menu(self) |
| 72 | + icon: "dots-vertical" |
| 73 | + MDLabel: |
| 74 | + text:"Settings" |
| 75 | + halign:"center" |
| 76 | + theme_font_size:"Custom" |
| 77 | + font_size:"30sp" |
| 78 | + style:"bold" |
| 79 | + size_hint_y:None |
| 80 | + height:dp(70) |
| 81 | + MDBoxLayout: |
| 82 | + md_bg_color:app.theme_cls.surfaceContainerHighColor |
| 83 | + padding:[dp(10), 0] |
| 84 | + radius:[self.height / 2]*4 |
| 85 | + size_hint_y:None |
| 86 | + height:dp(60) |
| 87 | + padding:[dp(10), dp(10)] |
| 88 | + spacing:dp(10) |
| 89 | + MDIconButton: |
| 90 | + size_hint_y:1 |
| 91 | + icon:"magnify" |
| 92 | + size_hint_x:None |
| 93 | + width:self.height |
| 94 | + MDLabel: |
| 95 | + text:"Search in settings" |
| 96 | + font_style:"Body" |
| 97 | + role:"large" |
| 98 | + theme_text_color:"Custom" |
| 99 | + text_color:app.theme_cls.surfaceContainerLowestColor[:-1] + [0.5] |
| 100 | + Image: |
| 101 | + size_hint_y:1 |
| 102 | + source:app.image_path |
| 103 | + size_hint_x:None |
| 104 | + width:self.height |
| 105 | + BoxLayout: |
| 106 | + size_hint_y:None |
| 107 | + height:dp(20) |
| 108 | + MDBoxLayout: |
| 109 | + md_bg_color:app.theme_cls.surfaceContainerHighColor |
| 110 | + radius:[dp(25)] * 4 |
| 111 | + size_hint_y:None |
| 112 | + height:self.minimum_height |
| 113 | + orientation:"vertical" |
| 114 | + SettingsItem: |
| 115 | + icon:"wifi" |
| 116 | + SettingsItem: |
| 117 | + icon:"battery-90" |
| 118 | + text:"Battery & Power" |
| 119 | + subtext:"42% - About 14hr left" |
| 120 | + SettingsItem: |
| 121 | + icon:"palette-outline" |
| 122 | + text:"Wallpaper & Style" |
| 123 | + subtext:"Colors, theme style" |
| 124 | + SettingsItem: |
| 125 | + icon:"android" |
| 126 | + text:"System Info" |
| 127 | + subtext:"About system" |
| 128 | + BoxLayout: |
| 129 | + size_hint_y:None |
| 130 | + height:dp(70) |
| 131 | + padding:[(self.width - dp(50)*6), dp(25)] |
| 132 | + spacing:dp(10) |
| 133 | + Check: |
| 134 | + active:True |
| 135 | + on_active: |
| 136 | + setattr(app.transition, "transition_axis", "x") if self.active else app |
| 137 | + MDLabel: |
| 138 | + size_hint_x:None |
| 139 | + width:dp(50) |
| 140 | + text:"X" |
| 141 | + Check: |
| 142 | + on_active: |
| 143 | + setattr(app.transition, "transition_axis", "y") if self.active else app |
| 144 | + MDLabel: |
| 145 | + size_hint_x:None |
| 146 | + width:dp(50) |
| 147 | + text:"Y" |
| 148 | + Check: |
| 149 | + on_active: |
| 150 | + setattr(app.transition, "transition_axis", "z") if self.active else app |
| 151 | + MDLabel: |
| 152 | + size_hint_x:None |
| 153 | + width:dp(50) |
| 154 | + text:"Z" |
| 155 | + BoxLayout: |
| 156 | + size_hint_y:None |
| 157 | + height:dp(100) |
| 158 | + orientation:"vertical" |
| 159 | + MDLabel: |
| 160 | + id:duration |
| 161 | + text:"Duration: 0.2" |
| 162 | + adaptive_height:True |
| 163 | + halign:"center" |
| 164 | + MDSlider: |
| 165 | + size_hint_y:None |
| 166 | + height:dp(50) |
| 167 | + step: 10 |
| 168 | + value: 10 |
| 169 | + on_value: |
| 170 | + duration.text = "Duration: " + str(self.value / 50) |
| 171 | + app.transition.duration = self.value/50 |
| 172 | + MDSliderHandle: |
| 173 | + Widget: |
| 174 | +
|
| 175 | +<BatteryScreen@MDScreen>: |
| 176 | + name:"battery" |
| 177 | + md_bg_color:app.theme_cls.surfaceContainerLowColor |
| 178 | + MDLabel: |
| 179 | + id:main_text |
| 180 | + text:"Battery" |
| 181 | + halign:"center" |
| 182 | + theme_font_size:"Custom" |
| 183 | + font_size:"30sp" |
| 184 | + style:"bold" |
| 185 | + size_hint_y:None |
| 186 | + height:dp(100) |
| 187 | + pos_hint:{"center_y":0.8} |
| 188 | + MDIconButton: |
| 189 | + id:main_icon |
| 190 | + icon:"wifi" |
| 191 | + style:"tonal" |
| 192 | + pos_hint:{"center_y":0.7, "center_x":0.5} |
| 193 | + MDButton: |
| 194 | + pos_hint:{"center_x":0.5, "center_y":0.5} |
| 195 | + style: "filled" |
| 196 | + on_release: |
| 197 | + app.root.transition.opposite = True |
| 198 | + app.root.current = "main" |
| 199 | + MDButtonText: |
| 200 | + text: "Go Back" |
| 201 | +
|
| 202 | +MDScreenManager: |
| 203 | + id:s_m |
| 204 | + md_bg_color:app.theme_cls.surfaceContainerLowColor |
| 205 | + transition:app.transition |
| 206 | + SettingsScreen: |
| 207 | + BatteryScreen: |
| 208 | +""" |
| 209 | + |
| 210 | + |
| 211 | +class ExampleApp(MDApp, CommonApp): |
| 212 | + image_path = os.path.join( |
| 213 | + kivymd.__path__[0], "images", "logo", "kivymd-icon-256.png" |
| 214 | + ) |
| 215 | + |
| 216 | + def build(self): |
| 217 | + self.transition = MDSharedAxisTransition() |
| 218 | + return Builder.load_string(KV) |
| 219 | + |
| 220 | + |
| 221 | +ExampleApp().run() |
0 commit comments