feat: added hiding and revealing the stop button
This commit is contained in:
@@ -38,6 +38,7 @@ class TimerConstructorScreen(Screen):
|
||||
time_culc = calculate_time(mm_user=timer.pomodoro_time)
|
||||
screen_timer.timer_start_time = time_culc
|
||||
screen_timer.ids.time_label.text = time_culc
|
||||
screen_timer.ids.title_label.text = timer.title
|
||||
screen_timer.source_timer_names = gen_types_timers(count_pomodoro=timer.count_pomodoro)
|
||||
|
||||
self.manager.state_machine = screen_timer.source_timer_names.copy()
|
||||
|
||||
@@ -32,12 +32,18 @@ class TimerScreen(Screen):
|
||||
if current_timer_name == 'pomodoro':
|
||||
self.timer_generator = custom_timer(mm_user=self.timer.pomodoro_time)
|
||||
self.ids.time_label.text = calculate_time(mm_user=self.timer.pomodoro_time)
|
||||
self.ids.type_timer_label.text = 'Помидор'
|
||||
elif current_timer_name == 'break':
|
||||
self.timer_generator = custom_timer(mm_user=self.timer.break_time)
|
||||
self.ids.time_label.text = calculate_time(mm_user=self.timer.break_time)
|
||||
self.ids.type_timer_label.text = 'Перерыв'
|
||||
else:
|
||||
self.timer_generator = custom_timer(mm_user=self.timer.break_long_time)
|
||||
self.ids.time_label.text = calculate_time(mm_user=self.timer.break_long_time)
|
||||
self.ids.type_timer_label.text = 'Перерывище'
|
||||
|
||||
self.ids.stop_button.opacity = 0
|
||||
self.ids.stop_button.disabled = True
|
||||
|
||||
def start_timer(self, instance) -> None:
|
||||
"""Метод для запуска таймера"""
|
||||
@@ -49,6 +55,9 @@ class TimerScreen(Screen):
|
||||
if len(self.manager.state_machine) and self.timer_generator is None:
|
||||
self.check_timer()
|
||||
|
||||
self.ids.stop_button.opacity = 1
|
||||
self.ids.stop_button.disabled = False
|
||||
|
||||
self.remaining_time = next(self.timer_generator, self.zero_time)
|
||||
|
||||
# Запуск обновления времени каждую секунду
|
||||
@@ -76,10 +85,9 @@ class TimerScreen(Screen):
|
||||
Clock.unschedule(self.sound_stop_event)
|
||||
self.sound_stop_event = None
|
||||
|
||||
if len(self.manager.state_machine):
|
||||
self.check_timer()
|
||||
else:
|
||||
if not len(self.manager.state_machine):
|
||||
self.manager.state_machine = self.source_timer_names.copy()
|
||||
|
||||
self.check_timer()
|
||||
|
||||
def play_sound(self, dt) -> None:
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
<TimerScreen>:
|
||||
FloatLayout:
|
||||
# Label для названия таймера
|
||||
Label:
|
||||
id: title_label
|
||||
size_hint: None, None
|
||||
pos_hint: {'center_x': 0.3, 'center_y': 0.7}
|
||||
|
||||
# Label для типа таймера
|
||||
Label:
|
||||
id: type_timer_label
|
||||
text: 'Помидор'
|
||||
size_hint: None, None
|
||||
pos_hint: {'center_x': 0.7, 'center_y': 0.7}
|
||||
|
||||
# Кнопка "Старт"
|
||||
Button:
|
||||
text: 'Старт'
|
||||
@@ -22,7 +35,10 @@
|
||||
|
||||
# Кнопка "Стоп"
|
||||
Button:
|
||||
id: stop_button
|
||||
text: 'Стоп'
|
||||
opacity: 0
|
||||
disabled: True
|
||||
size_hint: None, None
|
||||
height: 40
|
||||
width: 100
|
||||
@@ -32,6 +48,5 @@
|
||||
# Label для отображения времени
|
||||
Label:
|
||||
id: time_label
|
||||
# text: root.get_init_time(self)
|
||||
size_hint: None, None
|
||||
pos_hint: {'center_x': 0.5, 'center_y': 0.6}
|
||||
Reference in New Issue
Block a user