From 9ac5bcddddee3d107706d3c135e9705becdad041 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Fri, 31 Mar 2023 15:54:05 +0200 Subject: [PATCH 01/12] Update KivyMD to latest version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 64421f0..fc6b756 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ smartcard~=0.3 Kivy~=2.1.0 requests==2.28.2 -kivymd~=0.104.2 \ No newline at end of file +kivymd~=1.1.1 \ No newline at end of file From a1b9615be455bc8c375596b7f5ffb2c27bc3880a Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Fri, 31 Mar 2023 15:54:18 +0200 Subject: [PATCH 02/12] Rename MDToolbar to MDTopAppBar --- kvs/ProductScreen.kv | 2 +- kvs/ProfileScreen.kv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kvs/ProductScreen.kv b/kvs/ProductScreen.kv index 8075a66..d96d3f4 100644 --- a/kvs/ProductScreen.kv +++ b/kvs/ProductScreen.kv @@ -2,7 +2,7 @@ BoxLayout: orientation: "vertical" - MDToolbar: + MDTopAppBar: id: toolbar title: 'Stella Pay' font_name: 'fonts/orbitron/Orbitron-Bold.ttf' diff --git a/kvs/ProfileScreen.kv b/kvs/ProfileScreen.kv index 45305de..bcfea9c 100644 --- a/kvs/ProfileScreen.kv +++ b/kvs/ProfileScreen.kv @@ -3,7 +3,7 @@ anchor_x: 'center' anchor_y: 'top' - MDToolbar: + MDTopAppBar: title: 'STELLA PAY' font_name: 'fonts/orbitron/Orbitron-Bold.ttf' # md_bg_color: 0.078, 0.537, 0.882, 1 From 41c1ea2e2f8a124bc39e193b71da54873a7feb6a Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Fri, 31 Mar 2023 16:00:38 +0200 Subject: [PATCH 03/12] Use new icon_size and font_size attributes --- kvs/DefaultScreen.kv | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kvs/DefaultScreen.kv b/kvs/DefaultScreen.kv index 71316dc..b93f878 100644 --- a/kvs/DefaultScreen.kv +++ b/kvs/DefaultScreen.kv @@ -4,7 +4,7 @@ MDIconButton: icon: 'img/STEmediumnobg.png' - user_font_size: "450sp" + icon_size: "450sp" size_hint: None, None pos_hint: {"center_x":0.27,"center_y":0.63} on_release: root.to_credits() @@ -19,7 +19,7 @@ MDIconButton: id: connection_state - user_font_size: "25sp" + icon_size: "25sp" md_bg_color: app.theme_cls.purple_button icon: "wifi-off" pos_hint: {"center_x": 0.13,"center_y":0.79} @@ -74,7 +74,7 @@ MDIconButton: icon: "account-clock" text: "test" - user_font_size: "64sp" + icon_size: "64sp" pos_hint: {"center_x":0.58,"center_y":0.24} on_press: root.on_select_guest() @@ -86,7 +86,7 @@ MDIconButton: icon: "tools" - user_font_size: "64sp" + icon_size: "64sp" pos_hint: {"center_x":0.7,"center_y":0.24} on_press: root.on_select_onderhoud() @@ -98,7 +98,7 @@ MDIconButton: icon: "account-supervisor-circle" - user_font_size: "64sp" + icon_size: "64sp" pos_hint: {"center_x":0.82,"center_y":0.24} on_press: root.on_select_beheer() From 4a78e905401163eb0fd09219e7eb3afdfc91bdb5 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Fri, 31 Mar 2023 16:08:03 +0200 Subject: [PATCH 04/12] Use title attribute instead of text of tab in Product screen --- scrs/ProductScreen.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scrs/ProductScreen.py b/scrs/ProductScreen.py index c1f8c7b..11cf3b9 100644 --- a/scrs/ProductScreen.py +++ b/scrs/ProductScreen.py @@ -108,7 +108,7 @@ def show_products(self, products: Dict[str, List[Product]]): Logger.debug(f"StellaPayUI: ({threading.current_thread().name}) Drawing tabs for the first time.") self.tabs = [] for tab_name in products.keys(): - tab = TabDisplay(text=tab_name) + tab = TabDisplay(title=tab_name) self.ids.android_tabs.add_widget(tab) self.tabs.append(tab) else: @@ -117,7 +117,7 @@ def show_products(self, products: Dict[str, List[Product]]): start_time = time.time() for tab in self.tabs: - for product in products[tab.text]: + for product in products[tab.title]: # Get fun fact description of database product_description = App.get_running_app().database_manager.get_random_fun_fact(product.get_name()) @@ -143,7 +143,7 @@ def show_products(self, products: Dict[str, List[Product]]): ) ) - Logger.debug(f"Loaded products of category {tab.text} (no skipping) in {time.time() - start_time} seconds") + Logger.debug(f"Loaded products of category {tab.title} (no skipping) in {time.time() - start_time} seconds") Logger.debug(f"Loaded all products (no skipping) in {time.time() - start_time} seconds") @@ -294,10 +294,7 @@ async def submit_payment(self): def show_thanks_dialog(self): self.timeout_event.cancel() - self.final_dialog = MDDialog( - text="Gelukt! Je aankoop is geregistreerd!", - on_dismiss=self.on_thanks - ) + self.final_dialog = MDDialog(text="Gelukt! Je aankoop is geregistreerd!", on_dismiss=self.on_thanks) self.timeout_event = Clock.schedule_once(self.on_thanks, 5) self.final_dialog.open() From ef4b3c57b921b249f6e057b5732034b08bb23137 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Fri, 31 Mar 2023 17:42:15 +0200 Subject: [PATCH 05/12] Show a spinner when trying to send transaction to the server. --- scrs/ProductScreen.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scrs/ProductScreen.py b/scrs/ProductScreen.py index 11cf3b9..89f2257 100644 --- a/scrs/ProductScreen.py +++ b/scrs/ProductScreen.py @@ -10,8 +10,10 @@ from kivy.clock import Clock, mainthread from kivy.lang import Builder from kivy.uix.screenmanager import Screen, SlideTransition +from kivymd.material_resources import dp from kivymd.uix.button import MDFlatButton, MDRaisedButton from kivymd.uix.dialog import MDDialog +from kivymd.uix.spinner import MDSpinner from ds.Product import Product from ds.Purchase import Purchase @@ -245,7 +247,6 @@ def show_shopping_cart(self): MDRaisedButton(text="Ja", on_release=self.on_confirm_payment), ], ) - # Open the dialog to display the shopping cart self.shopping_cart_dialog.open() @@ -270,6 +271,17 @@ def on_cancel_payment(self, dt): def on_confirm_payment(self, dt=None): Logger.info(f"StellaPayUI: Payment was confirmed by the user.") + spinner = MDSpinner( + size_hint=(None, None), + size=(dp(32), dp(32)), + active=True + ) + + # Show a spinner when user confirms the payment and hide the other buttons + self.shopping_cart_dialog.ids.button_box.add_widget(spinner) + self.shopping_cart_dialog.ids.button_box.children[1].opacity = 0.0 + self.shopping_cart_dialog.ids.button_box.children[2].opacity = 0.0 + asyncio.run_coroutine_threadsafe(self.submit_payment(), loop=App.get_running_app().loop) async def submit_payment(self): @@ -279,13 +291,17 @@ async def submit_payment(self): self.shopping_cart ) + self.update_ui_after_payment(successfully_created_transactions) + + @mainthread + def update_ui_after_payment(self, transaction_successful: bool): # Reset instance variables self.end_user_session() if self.shopping_cart_dialog is not None: self.shopping_cart_dialog.dismiss() - if successfully_created_transactions: + if transaction_successful: self.show_thanks_dialog() else: self.show_failure_dialog() From 834a24078dca526a9b0ed4e9e845db02a76337c0 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 14:38:39 +0200 Subject: [PATCH 06/12] Try new alignment for boxes on default screen --- kvs/DefaultScreen.kv | 158 +++++++++++++++++++++++++++++++++---------- 1 file changed, 121 insertions(+), 37 deletions(-) diff --git a/kvs/DefaultScreen.kv b/kvs/DefaultScreen.kv index b93f878..44adcec 100644 --- a/kvs/DefaultScreen.kv +++ b/kvs/DefaultScreen.kv @@ -4,7 +4,7 @@ MDIconButton: icon: 'img/STEmediumnobg.png' - icon_size: "450sp" + icon_size: "450dp" size_hint: None, None pos_hint: {"center_x":0.27,"center_y":0.63} on_release: root.to_credits() @@ -19,7 +19,7 @@ MDIconButton: id: connection_state - icon_size: "25sp" + icon_size: "25dp" md_bg_color: app.theme_cls.purple_button icon: "wifi-off" pos_hint: {"center_x": 0.13,"center_y":0.79} @@ -71,42 +71,126 @@ on_press: root.select_recent_user(recent_user_two.text) halign: "center" - MDIconButton: - icon: "account-clock" - text: "test" - icon_size: "64sp" - pos_hint: {"center_x":0.58,"center_y":0.24} - on_press: root.on_select_guest() - - MDLabel: - text: "Gasten" - pos_hint: {"x":0.55,"center_y":0.165} - font_style: "H6" - theme_text_color: "Primary" - - MDIconButton: - icon: "tools" - icon_size: "64sp" - pos_hint: {"center_x":0.7,"center_y":0.24} - on_press: root.on_select_onderhoud() - MDLabel: - text: "Onderhoud" - pos_hint: {"x":0.665,"center_y":0.165} - font_style: "H6" - theme_text_color: "Primary" - - MDIconButton: - icon: "account-supervisor-circle" - icon_size: "64sp" - pos_hint: {"center_x":0.82,"center_y":0.24} - on_press: root.on_select_beheer() - - MDLabel: - text: "Beheer" - pos_hint: {"x":0.795,"center_y":0.165} - font_style: "H6" - theme_text_color: "Primary" + BoxLayout: + canvas.before: + Color: + rgba: 0, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + orientation: "vertical" + pos_hint: {"x": 0.55, "y": 0.1} + size_hint_y: 0.2 + size_hint_x: 0.08 + + MDIconButton: + canvas.before: + Color: + rgba: 0, 1, 1, 1 + Rectangle: + pos: self.pos + size: self.size + icon: "account-clock" + icon_size: "64dp" + pos_hint: {"center_x": .5} + on_press: root.on_select_guest() + + MDLabel: + canvas.before: + Color: + rgba: 1, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + text: "Gasten" + font_style: "H6" + halign: "center" + theme_text_color: "Primary" + + + BoxLayout: + canvas.before: + Color: + rgba: 0, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + orientation: "vertical" + pos_hint: {"x": 0.65, "y": 0.1} + size_hint_y: 0.2 + size_hint_x: 0.08 + MDIconButton: + canvas.before: + Color: + rgba: 0, 1, 1, 1 + Rectangle: + pos: self.pos + size: self.size + icon: "tools" + icon_size: "64dp" + pos_hint: {"center_x": .5} + on_press: root.on_select_onderhoud() + + MDLabel: + canvas.before: + Color: + rgba: 1, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + text: "Onderhoud" + font_style: "H6" + halign: "center" + theme_text_color: "Primary" + + BoxLayout: + canvas.before: + Color: + rgba: 0, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + orientation: "vertical" + pos_hint: {"x": 0.75, "y": 0.1} + size_hint_y: 0.2 + size_hint_x: 0.08 + + MDIconButton: + canvas.before: + Color: + rgba: 0, 1, 1, 1 + Rectangle: + pos: self.pos + size: self.size + icon: "account-supervisor-circle" + icon_size: "64dp" + pos_hint: {"center_x": .5} + on_press: root.on_select_beheer() + + MDLabel: + canvas.before: + Color: + rgba: 1, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + text: "Beheer" + font_style: "H6" + halign: "center" + theme_text_color: "Primary" + +# MDIconButton: +# icon: "account-supervisor-circle" +# icon_size: "64dp" +# pos_hint: {"center_x":0.82,"center_y":0.24} +# on_press: root.on_select_beheer() +# +# MDLabel: +# text: "Beheer" +# pos_hint: {"x":0.795,"center_y":0.165} +# font_style: "H6" +# theme_text_color: "Primary" MDSpinner: id: spinner From f18bcfb21cf25e026fdf5935ae79774da45e4d28 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 15:29:55 +0200 Subject: [PATCH 07/12] Add new VerticalButtonWithIcon class to prevent code duplication --- StellaPay.py | 1 + kvs/DefaultScreen.kv | 218 ++++++++++++++++++---------------- kvs/VerticalButtonWithIcon.kv | 42 +++++++ 3 files changed, 160 insertions(+), 101 deletions(-) create mode 100644 kvs/VerticalButtonWithIcon.kv diff --git a/StellaPay.py b/StellaPay.py index 49ea9fc..3866d6c 100644 --- a/StellaPay.py +++ b/StellaPay.py @@ -135,6 +135,7 @@ def build(self): Window.show_cursor = self.get_config_option(config.ConfigurationOption.DEVICE_SHOW_CURSOR) == "True" # Load .kv file + Builder.load_file("kvs/VerticalButtonWithIcon.kv") Builder.load_file("kvs/DefaultScreen.kv") Logger.debug("StellaPayUI: Starting event loop") diff --git a/kvs/DefaultScreen.kv b/kvs/DefaultScreen.kv index 44adcec..a8f1a2b 100644 --- a/kvs/DefaultScreen.kv +++ b/kvs/DefaultScreen.kv @@ -25,6 +25,7 @@ pos_hint: {"center_x": 0.13,"center_y":0.79} MDFillRoundFlatButton: + id: button_select_user text: "Selecteer gebruiker" font_size: '32sp' pos_hint: {"center_x":0.7,"center_y":0.78} @@ -73,112 +74,127 @@ BoxLayout: - canvas.before: - Color: - rgba: 0, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - orientation: "vertical" - pos_hint: {"x": 0.55, "y": 0.1} - size_hint_y: 0.2 - size_hint_x: 0.08 - - MDIconButton: - canvas.before: - Color: - rgba: 0, 1, 1, 1 - Rectangle: - pos: self.pos - size: self.size + orientation: "horizontal" + size_hint_x: 0.4 + pos_hint: {"center_x": (button_select_user.center_x / root.width), "y": 0.1} + VerticalButtonWithIcon: icon: "account-clock" - icon_size: "64dp" - pos_hint: {"center_x": .5} - on_press: root.on_select_guest() - - MDLabel: - canvas.before: - Color: - rgba: 1, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - text: "Gasten" - font_style: "H6" - halign: "center" - theme_text_color: "Primary" + label_text: "Gasten" - - BoxLayout: - canvas.before: - Color: - rgba: 0, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - orientation: "vertical" - pos_hint: {"x": 0.65, "y": 0.1} - size_hint_y: 0.2 - size_hint_x: 0.08 - MDIconButton: - canvas.before: - Color: - rgba: 0, 1, 1, 1 - Rectangle: - pos: self.pos - size: self.size + VerticalButtonWithIcon: icon: "tools" - icon_size: "64dp" - pos_hint: {"center_x": .5} - on_press: root.on_select_onderhoud() - - MDLabel: - canvas.before: - Color: - rgba: 1, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - text: "Onderhoud" - font_style: "H6" - halign: "center" - theme_text_color: "Primary" + label_text: "Onderhoud" - BoxLayout: - canvas.before: - Color: - rgba: 0, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - orientation: "vertical" - pos_hint: {"x": 0.75, "y": 0.1} - size_hint_y: 0.2 - size_hint_x: 0.08 - - MDIconButton: - canvas.before: - Color: - rgba: 0, 1, 1, 1 - Rectangle: - pos: self.pos - size: self.size + VerticalButtonWithIcon: icon: "account-supervisor-circle" - icon_size: "64dp" - pos_hint: {"center_x": .5} - on_press: root.on_select_beheer() - - MDLabel: - canvas.before: - Color: - rgba: 1, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - text: "Beheer" - font_style: "H6" - halign: "center" - theme_text_color: "Primary" + label_text: "Beheer" +# BoxLayout: +# canvas.before: +# Color: +# rgba: 0, 1, 0, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# orientation: "vertical" +# pos_hint: {"x": 0.55, "y": 0.1} +# size_hint_y: 0.2 +# size_hint_x: 0.08 +# +# MDIconButton: +# canvas.before: +# Color: +# rgba: 0, 1, 1, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# icon: "account-clock" +# icon_size: "64dp" +# pos_hint: {"center_x": .5} +# on_press: root.on_select_guest() +# +# MDLabel: +# canvas.before: +# Color: +# rgba: 1, 1, 0, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# text: "Gasten" +# font_style: "H6" +# halign: "center" +# theme_text_color: "Primary" + +# BoxLayout: +# canvas.before: +# Color: +# rgba: 0, 1, 0, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# orientation: "vertical" +# pos_hint: {"x": 0.65, "y": 0.1} +# size_hint_y: 0.2 +# size_hint_x: 0.08 +# +# MDIconButton: +# canvas.before: +# Color: +# rgba: 0, 1, 1, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# icon: "tools" +# icon_size: "64dp" +# pos_hint: {"center_x": .5} +# on_press: root.on_select_onderhoud() +# +# MDLabel: +# canvas.before: +# Color: +# rgba: 1, 1, 0, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# text: "Onderhoud" +# font_style: "H6" +# halign: "center" +# theme_text_color: "Primary" +# +# BoxLayout: +# canvas.before: +# Color: +# rgba: 0, 1, 0, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# orientation: "vertical" +# pos_hint: {"x": 0.75, "y": 0.1} +# size_hint_y: 0.2 +# size_hint_x: 0.08 +# +# MDIconButton: +# canvas.before: +# Color: +# rgba: 0, 1, 1, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# icon: "account-supervisor-circle" +# icon_size: "64dp" +# pos_hint: {"center_x": .5} +# on_press: root.on_select_beheer() +# +# MDLabel: +# canvas.before: +# Color: +# rgba: 1, 1, 0, 1 +# Rectangle: +# pos: self.pos +# size: self.size +# text: "Beheer" +# font_style: "H6" +# halign: "center" +# theme_text_color: "Primary" # MDIconButton: # icon: "account-supervisor-circle" diff --git a/kvs/VerticalButtonWithIcon.kv b/kvs/VerticalButtonWithIcon.kv new file mode 100644 index 0000000..bf6b6fc --- /dev/null +++ b/kvs/VerticalButtonWithIcon.kv @@ -0,0 +1,42 @@ +: + # Custom variables + icon: "" + label_text: "" + pos_x: 0.0 + pos_y: 0.0 + + canvas.before: + Color: + rgba: 0, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + + orientation: "vertical" + pos_hint: {"x": root.pos_x, "y": root.pos_y} + size_hint_y: 0.2 + size_hint_x: 0.1 + + MDIconButton: + canvas.before: + Color: + rgba: 0, 1, 1, 1 + Rectangle: + pos: self.pos + size: self.size + icon: root.icon + icon_size: "64dp" + pos_hint: {"center_x": .5} + on_press: root.on_select_guest() + + MDLabel: + canvas.before: + Color: + rgba: 1, 1, 0, 1 + Rectangle: + pos: self.pos + size: self.size + text: root.label_text + font_style: "H6" + halign: "center" + theme_text_color: "Primary" \ No newline at end of file From d1fa2077f41e1d86266aedd176836eead86f1c52 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 15:42:24 +0200 Subject: [PATCH 08/12] Bind to on_press for newly defined buttons --- kvs/DefaultScreen.kv | 4 ++++ kvs/VerticalButtonWithIcon.kv | 2 +- scrs/DefaultScreen.py | 17 +++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/kvs/DefaultScreen.kv b/kvs/DefaultScreen.kv index a8f1a2b..d84d246 100644 --- a/kvs/DefaultScreen.kv +++ b/kvs/DefaultScreen.kv @@ -77,15 +77,19 @@ orientation: "horizontal" size_hint_x: 0.4 pos_hint: {"center_x": (button_select_user.center_x / root.width), "y": 0.1} + VerticalButtonWithIcon: + id: guest_button icon: "account-clock" label_text: "Gasten" VerticalButtonWithIcon: + id: maintenance_button icon: "tools" label_text: "Onderhoud" VerticalButtonWithIcon: + id: admin_button icon: "account-supervisor-circle" label_text: "Beheer" # BoxLayout: diff --git a/kvs/VerticalButtonWithIcon.kv b/kvs/VerticalButtonWithIcon.kv index bf6b6fc..9651f2e 100644 --- a/kvs/VerticalButtonWithIcon.kv +++ b/kvs/VerticalButtonWithIcon.kv @@ -24,10 +24,10 @@ Rectangle: pos: self.pos size: self.size + id: icon_of_button icon: root.icon icon_size: "64dp" pos_hint: {"center_x": .5} - on_press: root.on_select_guest() MDLabel: canvas.before: diff --git a/scrs/DefaultScreen.py b/scrs/DefaultScreen.py index a86c314..b688876 100644 --- a/scrs/DefaultScreen.py +++ b/scrs/DefaultScreen.py @@ -101,6 +101,11 @@ def __init__(self, **kwargs): # Register listener App.get_running_app().data_controller.register_connection_listener(self.connection_change_listener) + # Listen to a user pressing the icon of a button + self.ids.admin_button.ids.icon_of_button.bind(on_press=self.on_select_beheer) + self.ids.guest_button.ids.icon_of_button.bind(on_press=self.on_select_guest) + self.ids.maintenance_button.ids.icon_of_button.bind(on_press=self.on_select_onderhoud) + def register_card_listener(self, card_connection_manager: "CardConnectionManager"): card_connection_manager.register_listener(self.nfc_listener) @@ -283,14 +288,14 @@ def move_to_register_card_screen(self, uid: str): self.manager.get_screen(Screens.REGISTER_UID_SCREEN.value).nfc_id = uid self.manager.current = Screens.REGISTER_UID_SCREEN.value - def on_select_guest(self): - self.select_special_user("Gast Account") + def on_select_guest(self, _): + self.select_special_user("Gast Account") - def on_select_beheer(self): - self.select_special_user("Beheer Algemeen") + def on_select_beheer(self, _): + self.select_special_user("Beheer Algemeen") - def on_select_onderhoud(self): - self.select_special_user("Beheer Onderhoud") + def on_select_onderhoud(self, _): + self.select_special_user("Beheer Onderhoud") def select_special_user(self, user: str): # Close the user dialog From 1ecc20c622ba508c392d46a36d85420053ad749d Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 15:43:11 +0200 Subject: [PATCH 09/12] Fix formatting issue --- scrs/DefaultScreen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scrs/DefaultScreen.py b/scrs/DefaultScreen.py index b688876..e142274 100644 --- a/scrs/DefaultScreen.py +++ b/scrs/DefaultScreen.py @@ -289,13 +289,13 @@ def move_to_register_card_screen(self, uid: str): self.manager.current = Screens.REGISTER_UID_SCREEN.value def on_select_guest(self, _): - self.select_special_user("Gast Account") + self.select_special_user("Gast Account") def on_select_beheer(self, _): - self.select_special_user("Beheer Algemeen") + self.select_special_user("Beheer Algemeen") def on_select_onderhoud(self, _): - self.select_special_user("Beheer Onderhoud") + self.select_special_user("Beheer Onderhoud") def select_special_user(self, user: str): # Close the user dialog From be50e677e2cda26edccc7c1d06555466efd3fdd2 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 15:46:10 +0200 Subject: [PATCH 10/12] Remove debugging background --- kvs/DefaultScreen.kv | 120 ---------------------------------- kvs/VerticalButtonWithIcon.kv | 19 ------ 2 files changed, 139 deletions(-) diff --git a/kvs/DefaultScreen.kv b/kvs/DefaultScreen.kv index d84d246..fd08f8b 100644 --- a/kvs/DefaultScreen.kv +++ b/kvs/DefaultScreen.kv @@ -72,7 +72,6 @@ on_press: root.select_recent_user(recent_user_two.text) halign: "center" - BoxLayout: orientation: "horizontal" size_hint_x: 0.4 @@ -92,125 +91,6 @@ id: admin_button icon: "account-supervisor-circle" label_text: "Beheer" -# BoxLayout: -# canvas.before: -# Color: -# rgba: 0, 1, 0, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# orientation: "vertical" -# pos_hint: {"x": 0.55, "y": 0.1} -# size_hint_y: 0.2 -# size_hint_x: 0.08 -# -# MDIconButton: -# canvas.before: -# Color: -# rgba: 0, 1, 1, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# icon: "account-clock" -# icon_size: "64dp" -# pos_hint: {"center_x": .5} -# on_press: root.on_select_guest() -# -# MDLabel: -# canvas.before: -# Color: -# rgba: 1, 1, 0, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# text: "Gasten" -# font_style: "H6" -# halign: "center" -# theme_text_color: "Primary" - -# BoxLayout: -# canvas.before: -# Color: -# rgba: 0, 1, 0, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# orientation: "vertical" -# pos_hint: {"x": 0.65, "y": 0.1} -# size_hint_y: 0.2 -# size_hint_x: 0.08 -# -# MDIconButton: -# canvas.before: -# Color: -# rgba: 0, 1, 1, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# icon: "tools" -# icon_size: "64dp" -# pos_hint: {"center_x": .5} -# on_press: root.on_select_onderhoud() -# -# MDLabel: -# canvas.before: -# Color: -# rgba: 1, 1, 0, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# text: "Onderhoud" -# font_style: "H6" -# halign: "center" -# theme_text_color: "Primary" -# -# BoxLayout: -# canvas.before: -# Color: -# rgba: 0, 1, 0, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# orientation: "vertical" -# pos_hint: {"x": 0.75, "y": 0.1} -# size_hint_y: 0.2 -# size_hint_x: 0.08 -# -# MDIconButton: -# canvas.before: -# Color: -# rgba: 0, 1, 1, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# icon: "account-supervisor-circle" -# icon_size: "64dp" -# pos_hint: {"center_x": .5} -# on_press: root.on_select_beheer() -# -# MDLabel: -# canvas.before: -# Color: -# rgba: 1, 1, 0, 1 -# Rectangle: -# pos: self.pos -# size: self.size -# text: "Beheer" -# font_style: "H6" -# halign: "center" -# theme_text_color: "Primary" - -# MDIconButton: -# icon: "account-supervisor-circle" -# icon_size: "64dp" -# pos_hint: {"center_x":0.82,"center_y":0.24} -# on_press: root.on_select_beheer() -# -# MDLabel: -# text: "Beheer" -# pos_hint: {"x":0.795,"center_y":0.165} -# font_style: "H6" -# theme_text_color: "Primary" MDSpinner: id: spinner diff --git a/kvs/VerticalButtonWithIcon.kv b/kvs/VerticalButtonWithIcon.kv index 9651f2e..8e62c5b 100644 --- a/kvs/VerticalButtonWithIcon.kv +++ b/kvs/VerticalButtonWithIcon.kv @@ -5,37 +5,18 @@ pos_x: 0.0 pos_y: 0.0 - canvas.before: - Color: - rgba: 0, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size - orientation: "vertical" pos_hint: {"x": root.pos_x, "y": root.pos_y} size_hint_y: 0.2 size_hint_x: 0.1 MDIconButton: - canvas.before: - Color: - rgba: 0, 1, 1, 1 - Rectangle: - pos: self.pos - size: self.size id: icon_of_button icon: root.icon icon_size: "64dp" pos_hint: {"center_x": .5} MDLabel: - canvas.before: - Color: - rgba: 1, 1, 0, 1 - Rectangle: - pos: self.pos - size: self.size text: root.label_text font_style: "H6" halign: "center" From 355ee9806a48f2a83e22e531301026eed64a4739 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 16:09:26 +0200 Subject: [PATCH 11/12] Align buttons with StellaPay text --- kvs/DefaultScreen.kv | 8 +++++++- kvs/VerticalButtonWithIcon.kv | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kvs/DefaultScreen.kv b/kvs/DefaultScreen.kv index fd08f8b..47ff051 100644 --- a/kvs/DefaultScreen.kv +++ b/kvs/DefaultScreen.kv @@ -14,6 +14,8 @@ text: "[b]STELLA PAY[/b]" font_size: '53sp' pos_hint: {"center_x":0.27,"center_y":0.2} + size_hint_x: 0.4 + size_hint_y: 0.2 font_name: 'fonts/orbitron/Orbitron-Bold.ttf' markup: True @@ -75,20 +77,24 @@ BoxLayout: orientation: "horizontal" size_hint_x: 0.4 - pos_hint: {"center_x": (button_select_user.center_x / root.width), "y": 0.1} + size_hint_y: 0.25 + pos_hint: {"center_x": (button_select_user.center_x / root.width), "center_y": (stella_pay.center_y / root.height)} VerticalButtonWithIcon: id: guest_button + pos_hint: {"center_y": 0.5} icon: "account-clock" label_text: "Gasten" VerticalButtonWithIcon: id: maintenance_button + pos_hint: {"center_y": 0.5} icon: "tools" label_text: "Onderhoud" VerticalButtonWithIcon: id: admin_button + pos_hint: {"center_y": 0.5} icon: "account-supervisor-circle" label_text: "Beheer" diff --git a/kvs/VerticalButtonWithIcon.kv b/kvs/VerticalButtonWithIcon.kv index 8e62c5b..17d0f54 100644 --- a/kvs/VerticalButtonWithIcon.kv +++ b/kvs/VerticalButtonWithIcon.kv @@ -7,7 +7,7 @@ orientation: "vertical" pos_hint: {"x": root.pos_x, "y": root.pos_y} - size_hint_y: 0.2 + size_hint_y: 0.15 size_hint_x: 0.1 MDIconButton: From 623b4b251b4caa5909ca43f57389aa385e2541b9 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Sun, 2 Apr 2023 16:48:48 +0200 Subject: [PATCH 12/12] Make dialog disappear as soon as leaving animation is started --- kvs/ProductScreen.kv | 1 - scrs/ProductScreen.py | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kvs/ProductScreen.kv b/kvs/ProductScreen.kv index d96d3f4..ef11592 100644 --- a/kvs/ProductScreen.kv +++ b/kvs/ProductScreen.kv @@ -14,7 +14,6 @@ id: android_tabs tab_bar_height: '50dp' lock_swiping: True -# anim_duration: 0.0 text_color_normal: (0,0,0,1) text_color_active: (1,1,1,1) color_indicator: (0,0,0,1) diff --git a/scrs/ProductScreen.py b/scrs/ProductScreen.py index 89f2257..94f4ab2 100644 --- a/scrs/ProductScreen.py +++ b/scrs/ProductScreen.py @@ -193,7 +193,7 @@ def on_timeout(self, dt): # # upon leaving the screen, cancel the timeout event # - def on_leave(self, *args): + def on_pre_leave(self, *args): self.timeout_event.cancel() if self.final_dialog is not None: @@ -271,11 +271,7 @@ def on_cancel_payment(self, dt): def on_confirm_payment(self, dt=None): Logger.info(f"StellaPayUI: Payment was confirmed by the user.") - spinner = MDSpinner( - size_hint=(None, None), - size=(dp(32), dp(32)), - active=True - ) + spinner = MDSpinner(size_hint=(None, None), size=(dp(32), dp(32)), active=True) # Show a spinner when user confirms the payment and hide the other buttons self.shopping_cart_dialog.ids.button_box.add_widget(spinner) @@ -310,7 +306,10 @@ def update_ui_after_payment(self, transaction_successful: bool): def show_thanks_dialog(self): self.timeout_event.cancel() - self.final_dialog = MDDialog(text="Gelukt! Je aankoop is geregistreerd!", on_dismiss=self.on_thanks) + self.final_dialog = MDDialog( + text="Gelukt! Je aankoop is geregistreerd!", + on_dismiss=self.on_thanks, + ) self.timeout_event = Clock.schedule_once(self.on_thanks, 5) self.final_dialog.open()