diff --git a/kawai_focus/main.py b/kawai_focus/main.py index 5f34c6d..1f18bbf 100644 --- a/kawai_focus/main.py +++ b/kawai_focus/main.py @@ -6,6 +6,7 @@ from kivy.animation import Animation from kivy.metrics import dp from kivy.uix.behaviors import ButtonBehavior from kivy.logger import Logger +from kivy.properties import StringProperty import logging @@ -14,6 +15,7 @@ from kivymd.uix.screenmanager import MDScreenManager from kivymd.uix.expansionpanel import MDExpansionPanel from kivymd.uix.behaviors import RotateBehavior from kivymd.uix.list import MDListItemTrailingIcon +from kivymd.uix.navigationrail import MDNavigationRailItem from kawai_focus.menu_app import MenuApp from kawai_focus.screens.timers_screen import TimersScreen @@ -29,6 +31,13 @@ class TrailingPressedIconButton( ... +class CommonNavigationRailItem(MDNavigationRailItem): + """Класс панель навигации""" + + text = StringProperty() + icon = StringProperty() + + class KawaiFocusApp(MDApp, MenuApp): """Главный класс приложения""" @@ -40,8 +49,7 @@ class KawaiFocusApp(MDApp, MenuApp): Builder.load_file('kv/timers_screen.kv') self.screen_manager = MDScreenManager() - self.timers_screen = TimersScreen(name='timers_screen') - self.screen_manager.add_widget(self.timers_screen) + self.screen_manager.add_widget(TimersScreen(name='timers_screen')) return self.screen_manager diff --git a/kv/navigation_panel.kv b/kv/navigation_panel.kv new file mode 100644 index 0000000..eaa5874 --- /dev/null +++ b/kv/navigation_panel.kv @@ -0,0 +1,44 @@ +#:kivy 2.3.1 + +: + icon: "" + text: "" + orientation: "vertical" + spacing: "4dp" + size_hint_y: None + height: "72dp" + + MDNavigationRailItemIcon: + icon: root.icon + + MDNavigationRailItemLabel: + text: root.text + +: + orientation: "horizontal" + + MDNavigationRail: + id: rail + + MDNavigationRailFabButton: + icon: "clock-outline" + + CommonNavigationRailItem: + icon: "timer-outline" + text: "Таймеры" + + CommonNavigationRailItem: + icon: "compass-outline" + text: "Гид" + + CommonNavigationRailItem: + icon: "information-outline" + text: "Инфо" + + MDScreen: + pos_hint: {"bottom": .98} + y: "12dp" + + MDNavigationRailMenuButton: + icon: "menu" + on_release: app.open_menu(self) diff --git a/kv/timers_screen.kv b/kv/timers_screen.kv index cfc5514..b72e304 100644 --- a/kv/timers_screen.kv +++ b/kv/timers_screen.kv @@ -1,4 +1,5 @@ #:kivy 2.3.1 +#:include kv/navigation_panel.kv # Кастомная панель для каждого таймера : @@ -25,14 +26,14 @@ MDLabel: text: "Информация о таймере" adaptive_height: True - padding_x: "16dp" - padding_y: "12dp" + padding: "16dp", "12dp" MDListItem: theme_bg_color: "Custom" md_bg_color: self.theme_cls.surfaceContainerLowColor ripple_effect: False on_release: None + MDListItemLeadingIcon: icon: "information-outline" MDListItemHeadlineText: @@ -40,33 +41,49 @@ MDBoxLayout: padding: [8, 8, 0, 0] + spacing: 8 size_hint_y: None height: self.minimum_height MDButton: + timer_id: root.timer_id + style: "outlined" + size_hint_x: 1 + on_release: app.root.get_screen("timers_screen").switch_timer(self) + + MDButtonText: + text: "Открыть" + + MDButton: + timer_id: root.id style: "outlined" size_hint_x: 1 MDButtonText: - text: "Открыть" + text: "Редактировать" + + MDButton: + timer_id: root.id + style: "outlined" + size_hint_x: 1 + + MDButtonText: + text: "Удалить" # Основной экран : - md_bg_color: self.theme_cls.backgroundColor - - MDIconButton: - on_release: app.open_menu(self) - pos_hint: {"top": .98} - x: "12dp" - icon: "menu" + NavigationPanel: - ScrollView: - size_hint_x: .9 - pos_hint: {"center_x": .5, "center_y": .5} - do_scroll_x: False - do_scroll_y: True + MDScreen: + md_bg_color: self.theme_cls.secondaryContainerColor - MDList: - id: container - spacing: "8dp" - padding: [56, 8, 56, 0] # [слева, сверху, справа, снизу] \ No newline at end of file + ScrollView: + size_hint_x: .9 + pos_hint: {"center_x": .5, "center_y": .5} + do_scroll_x: False + do_scroll_y: True + + MDList: + id: container + spacing: "8dp" + padding: [56, 8, 56, 0] # [слева, сверху, справа, снизу] \ No newline at end of file