summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
Diffstat (limited to 'wasp')
-rw-r--r--wasp/apps/pager.py17
-rw-r--r--wasp/widgets.py76
2 files changed, 19 insertions, 74 deletions
diff --git a/wasp/apps/pager.py b/wasp/apps/pager.py
index 2f74d0e..4f518eb 100644
--- a/wasp/apps/pager.py
+++ b/wasp/apps/pager.py
@@ -106,28 +106,19 @@ class NotificationApp(PagerApp):
return
else:
if event[0] == wasp.EventType.DOWN and self._page == 0:
- self.confirmation_view.active = True
- self._draw()
+ self.confirmation_view.draw('Clear notifications?')
return
super().swipe(event)
- def _draw(self):
- if self.confirmation_view.active:
- self.confirmation_view.draw('Clear notifications?')
- else:
- super()._draw()
-
def touch(self, event):
- if self.confirmation_view.active:
- is_confirmed = self.confirmation_view.touch(event)
- if is_confirmed:
+ if self.confirmation_view.touch(event):
+ if self.confirmation_view.value:
wasp.system.notifications = {}
wasp.system.navigate(wasp.EventType.BACK)
- elif is_confirmed != None:
+ else:
self._draw()
-
class CrashApp():
"""Crash handler application.
diff --git a/wasp/widgets.py b/wasp/widgets.py
index bed9be5..40523ce 100644
--- a/wasp/widgets.py
+++ b/wasp/widgets.py
@@ -378,76 +378,30 @@ class Spinner():
return False
-_message_string_x_coord = const(0)
-_message_string_y_coord = const(60)
-_yes_button_x_coord = const(20)
-_yes_button_y_coord = const(100)
-_no_button_x_coord = const(120)
-_no_button_y_coord = const(100)
-
class ConfirmationView:
"""Confirmation widget allowing user confirmation of a setting."""
def __init__(self):
self.active = False
-
- self.yes_button_bounds = (
- (_yes_button_x_coord, _yes_button_y_coord),
- (
- icons.yes_button[0] + _yes_button_x_coord,
- icons.yes_button[1] + _yes_button_y_coord,
- ),
- )
- self.no_button_bounds = (
- (_no_button_x_coord, _no_button_y_coord),
- (
- icons.no_button[0] + _no_button_x_coord,
- icons.no_button[1] + _no_button_y_coord,
- )
- )
+ self.value = False
def draw(self, message):
- wasp.watch.drawable.fill(1)
- wasp.watch.drawable.string(
- message,
- _message_string_x_coord,
- _message_string_y_coord
- )
- wasp.watch.drawable.blit(
- icons.yes_button,
- _yes_button_x_coord,
- _yes_button_y_coord,
- )
- wasp.watch.drawable.blit(
- icons.no_button,
- _no_button_x_coord,
- _no_button_y_coord,
- )
self.active = True
-
+ wasp.watch.drawable.fill(1)
+ wasp.watch.drawable.string(message, 0, 60)
+ wasp.watch.drawable.blit(icons.yes_button, 20, 100)
+ wasp.watch.drawable.blit(icons.no_button, 120, 100)
def touch(self, event):
- x_coord = event[1]
- y_coord = event[2]
- is_yes_button_press = (
- x_coord > self.yes_button_bounds[0][0]
- and y_coord > self.yes_button_bounds[0][1]
- and x_coord < self.yes_button_bounds[1][0]
- and y_coord < self.yes_button_bounds[1][1]
- )
-
- is_no_button_press = (
- x_coord > self.no_button_bounds[0][0]
- and y_coord > self.no_button_bounds[0][1]
- and x_coord < self.no_button_bounds[1][0]
- and y_coord < self.no_button_bounds[1][1]
- )
-
- if is_yes_button_press:
+ if not self.active:
+ return False
+
+ x = event[1]
+ y = event[2]
+
+ if y >= 80 and y < 180:
self.active = False
+ self.value = x < 120
return True
- elif is_no_button_press:
- self.active = False
- return False
- else:
- return None
+
+ return False