Merge pull request #8 from Arduinum/mvp_1_pomodoro

feat: added navigation_panel, new buttons for edit and delete timer
This commit was merged in pull request #8.
This commit is contained in:
Eugene
2025-10-23 19:52:12 +03:00
committed by GitHub
3 changed files with 90 additions and 21 deletions

View File

@@ -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

44
kv/navigation_panel.kv Normal file
View 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)

View File

@@ -1,4 +1,5 @@
#:kivy 2.3.1
#:include kv/navigation_panel.kv
# Кастомная панель для каждого таймера
<ExpansionPanelItem>:
@@ -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: "Удалить"
# Основной экран
<TimersScreen>:
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] # [слева, сверху, справа, снизу]
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] # [слева, сверху, справа, снизу]