feat: added navigation_panel, new buttons for edit and delete timer
This commit is contained in:
@@ -6,6 +6,7 @@ from kivy.animation import Animation
|
|||||||
from kivy.metrics import dp
|
from kivy.metrics import dp
|
||||||
from kivy.uix.behaviors import ButtonBehavior
|
from kivy.uix.behaviors import ButtonBehavior
|
||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
|
from kivy.properties import StringProperty
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ from kivymd.uix.screenmanager import MDScreenManager
|
|||||||
from kivymd.uix.expansionpanel import MDExpansionPanel
|
from kivymd.uix.expansionpanel import MDExpansionPanel
|
||||||
from kivymd.uix.behaviors import RotateBehavior
|
from kivymd.uix.behaviors import RotateBehavior
|
||||||
from kivymd.uix.list import MDListItemTrailingIcon
|
from kivymd.uix.list import MDListItemTrailingIcon
|
||||||
|
from kivymd.uix.navigationrail import MDNavigationRailItem
|
||||||
|
|
||||||
from kawai_focus.menu_app import MenuApp
|
from kawai_focus.menu_app import MenuApp
|
||||||
from kawai_focus.screens.timers_screen import TimersScreen
|
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):
|
class KawaiFocusApp(MDApp, MenuApp):
|
||||||
"""Главный класс приложения"""
|
"""Главный класс приложения"""
|
||||||
|
|
||||||
@@ -40,8 +49,7 @@ class KawaiFocusApp(MDApp, MenuApp):
|
|||||||
Builder.load_file('kv/timers_screen.kv')
|
Builder.load_file('kv/timers_screen.kv')
|
||||||
|
|
||||||
self.screen_manager = MDScreenManager()
|
self.screen_manager = MDScreenManager()
|
||||||
self.timers_screen = TimersScreen(name='timers_screen')
|
self.screen_manager.add_widget(TimersScreen(name='timers_screen'))
|
||||||
self.screen_manager.add_widget(self.timers_screen)
|
|
||||||
|
|
||||||
return self.screen_manager
|
return self.screen_manager
|
||||||
|
|
||||||
|
|||||||
44
kv/navigation_panel.kv
Normal file
44
kv/navigation_panel.kv
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#:kivy 2.3.1
|
||||||
|
|
||||||
|
<CommonNavigationRailItem@MDBoxLayout>:
|
||||||
|
icon: ""
|
||||||
|
text: ""
|
||||||
|
orientation: "vertical"
|
||||||
|
spacing: "4dp"
|
||||||
|
size_hint_y: None
|
||||||
|
height: "72dp"
|
||||||
|
|
||||||
|
MDNavigationRailItemIcon:
|
||||||
|
icon: root.icon
|
||||||
|
|
||||||
|
MDNavigationRailItemLabel:
|
||||||
|
text: root.text
|
||||||
|
|
||||||
|
<NavigationPanel@MDBoxLayout>:
|
||||||
|
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)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#:kivy 2.3.1
|
#:kivy 2.3.1
|
||||||
|
#:include kv/navigation_panel.kv
|
||||||
|
|
||||||
# Кастомная панель для каждого таймера
|
# Кастомная панель для каждого таймера
|
||||||
<ExpansionPanelItem>:
|
<ExpansionPanelItem>:
|
||||||
@@ -25,14 +26,14 @@
|
|||||||
MDLabel:
|
MDLabel:
|
||||||
text: "Информация о таймере"
|
text: "Информация о таймере"
|
||||||
adaptive_height: True
|
adaptive_height: True
|
||||||
padding_x: "16dp"
|
padding: "16dp", "12dp"
|
||||||
padding_y: "12dp"
|
|
||||||
|
|
||||||
MDListItem:
|
MDListItem:
|
||||||
theme_bg_color: "Custom"
|
theme_bg_color: "Custom"
|
||||||
md_bg_color: self.theme_cls.surfaceContainerLowColor
|
md_bg_color: self.theme_cls.surfaceContainerLowColor
|
||||||
ripple_effect: False
|
ripple_effect: False
|
||||||
on_release: None
|
on_release: None
|
||||||
|
|
||||||
MDListItemLeadingIcon:
|
MDListItemLeadingIcon:
|
||||||
icon: "information-outline"
|
icon: "information-outline"
|
||||||
MDListItemHeadlineText:
|
MDListItemHeadlineText:
|
||||||
@@ -40,33 +41,49 @@
|
|||||||
|
|
||||||
MDBoxLayout:
|
MDBoxLayout:
|
||||||
padding: [8, 8, 0, 0]
|
padding: [8, 8, 0, 0]
|
||||||
|
spacing: 8
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
|
|
||||||
MDButton:
|
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"
|
style: "outlined"
|
||||||
size_hint_x: 1
|
size_hint_x: 1
|
||||||
|
|
||||||
MDButtonText:
|
MDButtonText:
|
||||||
text: "Открыть"
|
text: "Редактировать"
|
||||||
|
|
||||||
|
MDButton:
|
||||||
|
timer_id: root.id
|
||||||
|
style: "outlined"
|
||||||
|
size_hint_x: 1
|
||||||
|
|
||||||
|
MDButtonText:
|
||||||
|
text: "Удалить"
|
||||||
|
|
||||||
# Основной экран
|
# Основной экран
|
||||||
<TimersScreen>:
|
<TimersScreen>:
|
||||||
md_bg_color: self.theme_cls.backgroundColor
|
NavigationPanel:
|
||||||
|
|
||||||
MDIconButton:
|
|
||||||
on_release: app.open_menu(self)
|
|
||||||
pos_hint: {"top": .98}
|
|
||||||
x: "12dp"
|
|
||||||
icon: "menu"
|
|
||||||
|
|
||||||
ScrollView:
|
MDScreen:
|
||||||
size_hint_x: .9
|
md_bg_color: self.theme_cls.secondaryContainerColor
|
||||||
pos_hint: {"center_x": .5, "center_y": .5}
|
|
||||||
do_scroll_x: False
|
|
||||||
do_scroll_y: True
|
|
||||||
|
|
||||||
MDList:
|
ScrollView:
|
||||||
id: container
|
size_hint_x: .9
|
||||||
spacing: "8dp"
|
pos_hint: {"center_x": .5, "center_y": .5}
|
||||||
padding: [56, 8, 56, 0] # [слева, сверху, справа, снизу]
|
do_scroll_x: False
|
||||||
|
do_scroll_y: True
|
||||||
|
|
||||||
|
MDList:
|
||||||
|
id: container
|
||||||
|
spacing: "8dp"
|
||||||
|
padding: [56, 8, 56, 0] # [слева, сверху, справа, снизу]
|
||||||
Reference in New Issue
Block a user