diff --git a/README.md b/README.md index b176d39..4a58865 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ A fully Independent Application for cross platform + +[![wakatime](https://wakatime.com/badge/user/198abec6-27b2-419b-87cf-60c4107b01be/project/018ef6c9-2350-4cfa-a556-ccadc51e0aa9.svg)](https://wakatime.com/badge/user/198abec6-27b2-419b-87cf-60c4107b01be/project/018ef6c9-2350-4cfa-a556-ccadc51e0aa9) + ## 🎯 Purpose for BillPay It has been difficult for me to manage my bills by having multiple apps installed on my mobile device, and I am sure many other people do too. There are many services here that provide all in one bill pay but they are so locked out we have to login to pay, and to pay we have to communicate with a third party bank account to send it credit so we can process our payments. If those services go down there is no possibility that we can further process our bills through those platforms. So what could be better than having a fully independent App where YOU control YOUR bills and payments without having to rely on a thirdparty service. @@ -44,7 +47,20 @@ So what could be better than having a fully independent App where YOU control YO ### Developed with ❤️: - -drawing -drawing -drawing + + penpot + + + + python + + + drawing + + + drawing + diff --git a/apps/apps.py b/apps/apps.py index a83a714..111ab2d 100644 --- a/apps/apps.py +++ b/apps/apps.py @@ -226,7 +226,7 @@ def Apps(page: ft.Page): border_radius=10, ink=True, on_click=lambda _: page.go( - '/apps/dhiraagu', + '/apps/ooredoo', ), ), ft.Container( @@ -255,7 +255,7 @@ def Apps(page: ft.Page): border_radius=10, ink=True, on_click=lambda _: page.go( - '/apps/dhiraagu', + '/apps/ooredoo', ), ), ft.Container( @@ -284,7 +284,7 @@ def Apps(page: ft.Page): border_radius=10, ink=True, on_click=lambda _: page.go( - '/apps/dhiraagu', + '/apps/ooredoo', ), ), ft.Container( @@ -313,7 +313,7 @@ def Apps(page: ft.Page): border_radius=10, ink=True, on_click=lambda _: page.go( - '/apps/dhiraagu', + '/apps/ooredoo', ), ), ft.Container( diff --git a/main.py b/main.py index ebf46ab..d7a1561 100644 --- a/main.py +++ b/main.py @@ -1,21 +1,49 @@ import flet as ft from utils import views_handler from modules.settings.functions import config +from utils import checkInternet def main(page: ft.Page): page.title = 'BillPay' print('Initial route:', page.route) + config.save('general', 'ignore_network', '0') - def route_change(e): + def route_change(e: ft.ControlEvent): print('Route change:', e.route) page.views.clear() page.views.append( views_handler(page)[page.route], ) page.update() + if not config.getint('general', 'ignore_network') and not checkInternet(): + dlg = ft.CupertinoActionSheet( + title=ft.Text('No Internet'), + message=ft.Text( + 'Please check your network connectivity and try again', + ), + cancel=ft.CupertinoActionSheetAction( + content=ft.Text('Okay'), + on_click=lambda _: ( + page.close_bottom_sheet() if checkInternet( + ) else None, page.update(), None if e.route == '/' else page.go('/'), + ), + ), + actions=[ + ft.CupertinoActionSheetAction( + content=ft.Text('Ignore Completely'), + is_destructive_action=True, + on_click=lambda e: ( + page.close_bottom_sheet(), config.save( + 'general', 'ignore_network', '1', + ), + ), + ), + ], + ) + page.show_bottom_sheet(ft.CupertinoBottomSheet(dlg)) - def view_pop(e): + def view_pop(e: ft.ControlEvent): print('View pop:', e.view) page.views.pop() top_view = page.views[-1] diff --git a/modules/settings/appSettings/dhiraagu_settings.py b/modules/settings/appSettings/dhiraagu_settings.py index 588f4ae..6d2ba08 100644 --- a/modules/settings/appSettings/dhiraagu_settings.py +++ b/modules/settings/appSettings/dhiraagu_settings.py @@ -9,8 +9,7 @@ def Settings(page: ft.Page): ) settingsContainer.controls.append(ft.Text('General')) - def _on_enable_change(e): - print(config.getint('apps', 'dhiraagu')) + def _on_enable_change(e: ft.ControlEvent): if config.getint('apps', 'dhiraagu'): config.save('apps', 'dhiraagu', '0') else: @@ -41,6 +40,67 @@ def Settings(page: ft.Page): settingsContainer.controls.append( generalSettings, ) + settingsContainer.controls.append( + ft.Divider(), + ) + + # main settings + settingsContainer.controls.append(ft.Text('Account')) + loginForm = ft.Column() + phoneInput = ft.Container( + content=ft.TextField( + config.get('dhiraagu', 'phone'), + label='Phone', + adaptive=True, + ), + padding=10, + ) + loginForm.controls.append(phoneInput) + + otpInput = ft.Container( + content=ft.TextField( + config.get('dhiraagu', 'otp'), + label='OTP', + adaptive=True, + ), + padding=10, + ) + loginForm.controls.append(otpInput) + sendOTP = ft.CupertinoButton( + content=ft.Text('SEND OTP'), + opacity_on_click=0.3, + on_click=lambda e: print('clicked!'), + ) + + if config.get('dhiraagu', 'token'): + phoneInput.disabled = True + otpInput.disabled = True + sendOTP.disabled = True + log = ft.CupertinoButton( + content=ft.Text('LOG OUT'), + opacity_on_click=0.3, + on_click=lambda e: print('clicked!'), + ) + else: + log = ft.CupertinoButton( + content=ft.Text('LOG IN'), + opacity_on_click=0.3, + on_click=lambda e: print('clicked!'), + ) + buttons = ft.Row( + controls=[ + sendOTP, + ], + ) + buttons.controls.append( + log, + ) + loginForm.controls.append( + buttons, + ) + settingsContainer.controls.append( + loginForm, + ) return AppView( '/settings/dhiraagu', [ diff --git a/modules/settings/appSettings/medianet_settings.py b/modules/settings/appSettings/medianet_settings.py index d52e451..1c58214 100644 --- a/modules/settings/appSettings/medianet_settings.py +++ b/modules/settings/appSettings/medianet_settings.py @@ -9,8 +9,7 @@ def Settings(page: ft.Page): ) settingsContainer.controls.append(ft.Text('General')) - def _on_enable_change(e): - print(config.getint('apps', 'medianet')) + def _on_enable_change(e: ft.ControlEvent): if config.getint('apps', 'medianet'): config.save('apps', 'medianet', '0') else: diff --git a/modules/settings/appSettings/mwsc_settings.py b/modules/settings/appSettings/mwsc_settings.py index b576a82..0d97c73 100644 --- a/modules/settings/appSettings/mwsc_settings.py +++ b/modules/settings/appSettings/mwsc_settings.py @@ -2,6 +2,8 @@ import flet as ft from utils import AppView, Title from ..functions import config +ft.Control + def Settings(page: ft.Page): settingsContainer = ft.ListView( @@ -9,8 +11,7 @@ def Settings(page: ft.Page): ) settingsContainer.controls.append(ft.Text('General')) - def _on_enable_change(e): - print(config.getint('apps', 'mwsc')) + def _on_enable_change(e: ft.ControlEvent): if config.getint('apps', 'mwsc'): config.save('apps', 'mwsc', '0') else: diff --git a/modules/settings/appSettings/ooredoo_settings.py b/modules/settings/appSettings/ooredoo_settings.py index 3c0f624..4503633 100644 --- a/modules/settings/appSettings/ooredoo_settings.py +++ b/modules/settings/appSettings/ooredoo_settings.py @@ -9,8 +9,7 @@ def Settings(page: ft.Page): ) settingsContainer.controls.append(ft.Text('General')) - def _on_enable_change(e): - print(config.getint('apps', 'ooredoo')) + def _on_enable_change(e: ft.ControlEvent): if config.getint('apps', 'ooredoo'): config.save('apps', 'ooredoo', '0') else: diff --git a/modules/settings/appSettings/stelco_settings.py b/modules/settings/appSettings/stelco_settings.py index 8bd7f5b..3a0d87d 100644 --- a/modules/settings/appSettings/stelco_settings.py +++ b/modules/settings/appSettings/stelco_settings.py @@ -9,8 +9,7 @@ def Settings(page: ft.Page): ) settingsContainer.controls.append(ft.Text('General')) - def _on_enable_change(e): - print(config.getint('apps', 'stelco')) + def _on_enable_change(e: ft.ControlEvent): if config.getint('apps', 'stelco'): config.save('apps', 'stelco', '0') else: diff --git a/modules/settings/functions/theme.py b/modules/settings/functions/theme.py index f2bfc33..28edf8a 100644 --- a/modules/settings/functions/theme.py +++ b/modules/settings/functions/theme.py @@ -1,5 +1,4 @@ import flet as ft -from .config import config class Theme: @@ -9,5 +8,4 @@ class Theme: def change(self, theme: ft.ThemeMode = None): if theme: self.page.theme_mode = theme - print(theme) self.page.update() diff --git a/modules/settings/settings.py b/modules/settings/settings.py index 131f700..b2165ab 100644 --- a/modules/settings/settings.py +++ b/modules/settings/settings.py @@ -9,7 +9,7 @@ def Settings(page: ft.Page): ) settingsContainer.controls.append(ft.Text('General')) - def _on_name_change(e): + def _on_name_change(e: ft.ControlEvent): newName = ft.CupertinoTextField(value=config.get('general', 'name')) dlg = ft.CupertinoAlertDialog( modal=True, @@ -45,7 +45,7 @@ def Settings(page: ft.Page): dlg.open = True page.update() - def _on_phone_change(e): + def _on_phone_change(e: ft.ControlEvent): newPhone = ft.CupertinoTextField(value=config.get('general', 'phone')) dlg = ft.CupertinoAlertDialog( modal=True, @@ -81,7 +81,7 @@ def Settings(page: ft.Page): dlg.open = True page.update() - def _on_email_change(e): + def _on_email_change(e: ft.ControlEvent): newEmail = ft.CupertinoTextField(value=config.get('general', 'email')) dlg = ft.CupertinoAlertDialog( modal=True, @@ -117,7 +117,7 @@ def Settings(page: ft.Page): dlg.open = True page.update() - def _on_nid_change(e): + def _on_nid_change(e: ft.ControlEvent): newNID = ft.CupertinoTextField(value=config.get('general', 'nid')) dlg = ft.CupertinoAlertDialog( modal=True, @@ -385,7 +385,7 @@ def Settings(page: ft.Page): settingsContainer.controls.append(ft.Divider()) settingsContainer.controls.append(ft.Text('Theme')) - def _on_theme_change(e): + def _on_theme_change(e: ft.ControlEvent): if page.theme_mode == ft.ThemeMode.LIGHT: e.value = False config.save('general', 'theme', 'dark') diff --git a/utils/__init__.py b/utils/__init__.py index aff5c80..654f156 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,9 +1,11 @@ from .view import AppView from .title import Title from .views import views_handler +from .network import checkInternet __all__ = [ 'AppView', 'Title', 'views_handler', + 'checkInternet', ] diff --git a/utils/network.py b/utils/network.py new file mode 100644 index 0000000..9f28ce6 --- /dev/null +++ b/utils/network.py @@ -0,0 +1,10 @@ +import requests + +def checkInternet(): + try: + requests.get( + "https://rest.ensembl.org/info/ping?content-type=application/json", + ) + return True + except requests.ConnectionError: + return False \ No newline at end of file