this commit fixes #2 and adds other improvements to #3

This commit is contained in:
Aman Ahmed Zahir 2024-04-21 11:56:10 +00:00
parent e94762b85c
commit debf0461bb
12 changed files with 139 additions and 27 deletions

View File

@ -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 ❤️:
<img src="https://asset.brandfetch.io/idmUOaSbid/id6mBl43Pj.jpeg" alt="drawing" width="50" height="50"/>
<img src="https://asset.brandfetch.io/idbpOFBgcc/idcTemqrrW.svg" alt="drawing" width="50" height="50"/>
<a href="https://penpot.app">
<img src="https://www.svgrepo.com/download/432263/penpot.svg" alt="penpot" width="50" height="50" class="penpot-color"/>
<style>
.penpot-color{
filter: invert(40%) sepia(0%) saturate(2476%);
}
</style>
</a>
<a href="https://python.org">
<img src="https://asset.brandfetch.io/idbpOFBgcc/idcTemqrrW.svg" alt="python" width="50" height="50"/>
</a>
<a href="https://flutter.dev">
<img src="https://asset.brandfetch.io/idEMZUpQF7/idvArxAqXg.svg" alt="drawing" width="50" height="50"/>
</a>
<a href="https://flet.dev">
<img src="https://github.com/flet-dev/flet/blob/main/media/logo/Icon-192.png?raw=true" alt="drawing" width="50" height="50"/>
</a>

View File

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

32
main.py
View File

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

View File

@ -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',
[

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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',
]

10
utils/network.py Normal file
View File

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