diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d68e411..a2cf77d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,7 @@ repos: - id: detect-private-key - id: fix-byte-order-marker - id: mixed-line-ending + - id: file-contents-sorter - repo: https://github.com/hhatto/autopep8 rev: v2.1.0 hooks: @@ -30,3 +31,7 @@ repos: rev: v3.15.2 hooks: - id: pyupgrade + - repo: https://github.com/abdelrahman0w/ouro + rev: v0.2.0 + hooks: + - id: ouro diff --git a/apps/__init__.py b/apps/__init__.py index aa44fbd..48b8c10 100644 --- a/apps/__init__.py +++ b/apps/__init__.py @@ -1,5 +1,5 @@ from .apps import Apps __all__ = [ - "Apps" -] \ No newline at end of file + 'Apps', +] diff --git a/apps/apps.py b/apps/apps.py index f0d23e6..a481158 100644 --- a/apps/apps.py +++ b/apps/apps.py @@ -43,7 +43,7 @@ def Apps(page: ft.Page): ), ) AppRow.controls.append( - ft.Text('Dhiraagu') + ft.Text('Dhiraagu'), ) AppRow.controls.append( ft.Container( @@ -56,7 +56,10 @@ def Apps(page: ft.Page): ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.ACCOUNT_BOX, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.ACCOUNT_BOX, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -68,16 +71,22 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Gift",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Gift', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.ELECTRIC_BOLT, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.ELECTRIC_BOLT, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -89,16 +98,22 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Reload",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Reload', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.DASHBOARD, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.DASHBOARD, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -110,16 +125,22 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Usage",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Usage', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.RECEIPT, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.RECEIPT, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -131,16 +152,19 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Bills",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Bills', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ], alignment=ft.MainAxisAlignment.CENTER, ), - ) + ), ) if config.getint('apps', 'ooredoo') == 1: appList.content.controls.append( @@ -165,10 +189,10 @@ def Apps(page: ft.Page): padding=10, on_click=lambda _: page.go('/apps/ooredoo'), ), - ) + ), ) AppRow.controls.append( - ft.Text('Ooredoo') + ft.Text('Ooredoo'), ) AppRow.controls.append( ft.Container( @@ -181,7 +205,10 @@ def Apps(page: ft.Page): ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.SETTINGS_PHONE, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.SETTINGS_PHONE, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -193,16 +220,22 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Add-ons",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Add-ons', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.ELECTRIC_BOLT, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.ELECTRIC_BOLT, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -214,16 +247,22 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Raastas",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Raastas', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.DASHBOARD, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.DASHBOARD, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -235,16 +274,22 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Balance",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Balance', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ft.Column( controls=[ ft.Container( - content=ft.Icon(ft.icons.RECEIPT, color=ft.colors.WHITE), + content=ft.Icon( + ft.icons.RECEIPT, + color=ft.colors.WHITE, + ), margin=10, padding=10, alignment=ft.alignment.center, @@ -256,16 +301,19 @@ def Apps(page: ft.Page): on_click=None, ), ft.Container( - content=ft.Text("Bills",text_align=ft.TextAlign.CENTER), + content=ft.Text( + 'Bills', + text_align=ft.TextAlign.CENTER, + ), alignment=ft.alignment.center, - width=80 - ) - ] + width=80, + ), + ], ), ], alignment=ft.MainAxisAlignment.CENTER, ), - ) + ), ) if config.getint('apps', 'mwsc') == 1: appList.content.controls.append( @@ -313,7 +361,7 @@ def Apps(page: ft.Page): ], ), padding=10, - on_click=lambda _:page.go('/apps/stelco'), + on_click=lambda _: page.go('/apps/stelco'), ), ), ) @@ -353,6 +401,6 @@ def Apps(page: ft.Page): title=ft.Text(Title(str(__file__))), bgcolor=ft.colors.TRANSPARENT, ), - appsContainer + appsContainer, ], ) diff --git a/apps/plugins/__init__.py b/apps/plugins/__init__.py index e56318b..f8fb639 100644 --- a/apps/plugins/__init__.py +++ b/apps/plugins/__init__.py @@ -9,5 +9,5 @@ __all__ = [ 'Ooredoo', 'Medianet', 'Stelco', - 'Mwsc' -] \ No newline at end of file + 'Mwsc', +] diff --git a/apps/plugins/dhiraagu/__init__.py b/apps/plugins/dhiraagu/__init__.py index bd443fd..9ee5dfd 100644 --- a/apps/plugins/dhiraagu/__init__.py +++ b/apps/plugins/dhiraagu/__init__.py @@ -1,5 +1,5 @@ from .app import App as Dhiraagu __all__ = [ - 'Dhiraagu' -] \ No newline at end of file + 'Dhiraagu', +] diff --git a/apps/plugins/dhiraagu/app.py b/apps/plugins/dhiraagu/app.py index 965272e..074f044 100644 --- a/apps/plugins/dhiraagu/app.py +++ b/apps/plugins/dhiraagu/app.py @@ -11,7 +11,7 @@ def App(page: ft.Page): ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, on_click=lambda _: page.go('/apps'), ), - title=ft.Text("Dhiraagu"), + title=ft.Text('Dhiraagu'), bgcolor=ft.colors.TRANSPARENT, ), ], diff --git a/apps/plugins/medianet/__init__.py b/apps/plugins/medianet/__init__.py index fca35af..33f8f8d 100644 --- a/apps/plugins/medianet/__init__.py +++ b/apps/plugins/medianet/__init__.py @@ -1,5 +1,5 @@ from .app import App as Medianet __all__ = [ - "Medianet" -] \ No newline at end of file + 'Medianet', +] diff --git a/apps/plugins/medianet/app.py b/apps/plugins/medianet/app.py index f84912a..6ec4125 100644 --- a/apps/plugins/medianet/app.py +++ b/apps/plugins/medianet/app.py @@ -11,7 +11,7 @@ def App(page: ft.Page): ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, on_click=lambda _: page.go('/apps'), ), - title=ft.Text("Medianet"), + title=ft.Text('Medianet'), bgcolor=ft.colors.TRANSPARENT, ), ], diff --git a/apps/plugins/mwsc/__init__.py b/apps/plugins/mwsc/__init__.py index 11540dc..fe785e1 100644 --- a/apps/plugins/mwsc/__init__.py +++ b/apps/plugins/mwsc/__init__.py @@ -1,5 +1,5 @@ from .app import App as Mwsc __all__ = [ - 'Mwsc' -] \ No newline at end of file + 'Mwsc', +] diff --git a/apps/plugins/mwsc/app.py b/apps/plugins/mwsc/app.py index ceb395c..ffa1d8c 100644 --- a/apps/plugins/mwsc/app.py +++ b/apps/plugins/mwsc/app.py @@ -11,7 +11,7 @@ def App(page: ft.Page): ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, on_click=lambda _: page.go('/apps'), ), - title=ft.Text("MWSC"), + title=ft.Text('MWSC'), bgcolor=ft.colors.TRANSPARENT, ), ], diff --git a/apps/plugins/ooredoo/__init__.py b/apps/plugins/ooredoo/__init__.py index 561fd88..b7d47ae 100644 --- a/apps/plugins/ooredoo/__init__.py +++ b/apps/plugins/ooredoo/__init__.py @@ -1,5 +1,5 @@ from .app import App as Ooredoo __all__ = [ - 'Ooredoo' -] \ No newline at end of file + 'Ooredoo', +] diff --git a/apps/plugins/ooredoo/app.py b/apps/plugins/ooredoo/app.py index caefe57..5aa42ee 100644 --- a/apps/plugins/ooredoo/app.py +++ b/apps/plugins/ooredoo/app.py @@ -11,7 +11,7 @@ def App(page: ft.Page): ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, on_click=lambda _: page.go('/apps'), ), - title=ft.Text("Ooredoo"), + title=ft.Text('Ooredoo'), bgcolor=ft.colors.TRANSPARENT, ), ], diff --git a/apps/plugins/stelco/__init__.py b/apps/plugins/stelco/__init__.py index 0f518c9..0bebf53 100644 --- a/apps/plugins/stelco/__init__.py +++ b/apps/plugins/stelco/__init__.py @@ -1,5 +1,5 @@ from .app import App as Stelco __all__ = [ - 'Stelco' -] \ No newline at end of file + 'Stelco', +] diff --git a/apps/plugins/stelco/app.py b/apps/plugins/stelco/app.py index ffb1b60..969876a 100644 --- a/apps/plugins/stelco/app.py +++ b/apps/plugins/stelco/app.py @@ -11,7 +11,7 @@ def App(page: ft.Page): ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, on_click=lambda _: page.go('/apps'), ), - title=ft.Text("STELCO"), + title=ft.Text('STELCO'), bgcolor=ft.colors.TRANSPARENT, ), ], diff --git a/main.py b/main.py index 3ebd806..ebf46ab 100644 --- a/main.py +++ b/main.py @@ -20,6 +20,7 @@ def main(page: ft.Page): page.views.pop() top_view = page.views[-1] page.go(top_view.route) + if config.get('general', 'theme') == 'dark': page.theme_mode = ft.ThemeMode.DARK else: diff --git a/modules/home.py b/modules/home.py index eea8c9a..359caf1 100644 --- a/modules/home.py +++ b/modules/home.py @@ -45,7 +45,8 @@ def Home(page: ft.Page): [ ft.Container( content=ft.Icon( - ft.icons.APPS, color=ft.colors.WHITE, + ft.icons.APPS, + color=ft.colors.WHITE, ), margin=10, padding=10, @@ -59,34 +60,8 @@ def Home(page: ft.Page): ), ft.Container( content=ft.Icon( - ft.icons.HISTORY, color=ft.colors.WHITE, - ), - margin=10, - padding=10, - alignment=ft.alignment.center, - bgcolor=ft.colors.GREY_700, - width=60, - height=60, - border_radius=10, - on_click=None, - ), - ft.Container( - content=ft.Icon( - ft.icons.SETTINGS, color=ft.colors.WHITE, - ), - margin=10, - padding=10, - alignment=ft.alignment.center, - bgcolor=ft.colors.GREY_700, - width=60, - height=60, - border_radius=10, - ink=True, - on_click=lambda _: page.go('/settings'), - ), - ft.Container( - content=ft.Icon( - ft.icons.LIST, color=ft.colors.WHITE, + ft.icons.HISTORY, + color=ft.colors.WHITE, ), margin=10, padding=10, @@ -100,6 +75,38 @@ def Home(page: ft.Page): 'Clickable with Ink clicked!', ), ), + ft.Container( + content=ft.Icon( + ft.icons.LIST, + color=ft.colors.WHITE, + ), + margin=10, + padding=10, + alignment=ft.alignment.center, + bgcolor=ft.colors.GREY_700, + width=60, + height=60, + border_radius=10, + ink=True, + on_click=lambda e: print( + 'Clickable with Ink clicked!', + ), + ), + ft.Container( + content=ft.Icon( + ft.icons.SETTINGS, + color=ft.colors.WHITE, + ), + margin=10, + padding=10, + alignment=ft.alignment.center, + bgcolor=ft.colors.GREY_700, + width=60, + height=60, + border_radius=10, + ink=True, + on_click=lambda _: page.go('/settings'), + ), ], alignment=ft.MainAxisAlignment.CENTER, ), diff --git a/modules/settings/appSettings/__init__.py b/modules/settings/appSettings/__init__.py new file mode 100644 index 0000000..3990ae2 --- /dev/null +++ b/modules/settings/appSettings/__init__.py @@ -0,0 +1,13 @@ +from .dhiraagu_settings import Settings as DhiraaguSettings +from .medianet_settings import Settings as MedianetSettings +from .mwsc_settings import Settings as MwscSettings +from .ooredoo_settings import Settings as OoredooSettings +from .stelco_settings import Settings as StelcoSettings + +__all__ = [ + 'DhiraaguSettings', + 'MedianetSettings', + 'MwscSettings', + 'OoredooSettings', + 'StelcoSettings' +] \ No newline at end of file diff --git a/modules/settings/appSettings/dhiraagu_settings.py b/modules/settings/appSettings/dhiraagu_settings.py new file mode 100644 index 0000000..475e3b4 --- /dev/null +++ b/modules/settings/appSettings/dhiraagu_settings.py @@ -0,0 +1,58 @@ +import flet as ft +from utils import AppView, Title +from ..functions import config + + +def Settings(page: ft.Page): + settingsContainer = ft.ListView( + expand=True, + ) + settingsContainer.controls.append(ft.Text('General')) + + def _on_enable_change(e): + print(config.getint('apps', 'dhiraagu')) + if config.getint('apps', 'dhiraagu'): + config.save('apps', 'dhiraagu', '0') + else: + config.save('apps', 'dhiraagu', '1') + page.update() + + + generalSettings = ft.Container( + content=ft.Column( + controls=[ + ft.Card( + content=ft.Container( + content=ft.Container( + ft.Switch( + label=' Enable this module', + on_change=_on_enable_change, + value=False + ), + ), + padding=10, + on_click=None, + ), + ), + ], + ), + ) + if config.getint('apps', 'dhiraagu') == 1: + generalSettings.content.controls[0].content.content.content.value = True + settingsContainer.controls.append( + generalSettings, + ) + return AppView( + '/settings/dhiraagu', + [ + ft.AppBar( + leading=ft.IconButton( + ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, + on_click=lambda _: page.go('/settings'), + ), + title=ft.Text(Title(str(__file__))), + bgcolor=ft.colors.TRANSPARENT, + ), + settingsContainer, + ], + ) diff --git a/modules/settings/appSettings/medianet_settings.py b/modules/settings/appSettings/medianet_settings.py new file mode 100644 index 0000000..eb9ba70 --- /dev/null +++ b/modules/settings/appSettings/medianet_settings.py @@ -0,0 +1,58 @@ +import flet as ft +from utils import AppView, Title +from ..functions import config + + +def Settings(page: ft.Page): + settingsContainer = ft.ListView( + expand=True, + ) + settingsContainer.controls.append(ft.Text('General')) + + def _on_enable_change(e): + print(config.getint('apps', 'medianet')) + if config.getint('apps', 'medianet'): + config.save('apps', 'medianet', '0') + else: + config.save('apps', 'medianet', '1') + page.update() + + + generalSettings = ft.Container( + content=ft.Column( + controls=[ + ft.Card( + content=ft.Container( + content=ft.Container( + ft.Switch( + label=' Enable this module', + on_change=_on_enable_change, + value=False + ), + ), + padding=10, + on_click=None, + ), + ), + ], + ), + ) + if config.getint('apps', 'medianet') == 1: + generalSettings.content.controls[0].content.content.content.value = True + settingsContainer.controls.append( + generalSettings, + ) + return AppView( + '/settings/medianet', + [ + ft.AppBar( + leading=ft.IconButton( + ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, + on_click=lambda _: page.go('/settings'), + ), + title=ft.Text(Title(str(__file__))), + bgcolor=ft.colors.TRANSPARENT, + ), + settingsContainer, + ], + ) diff --git a/modules/settings/appSettings/mwsc_settings.py b/modules/settings/appSettings/mwsc_settings.py new file mode 100644 index 0000000..3f4dd64 --- /dev/null +++ b/modules/settings/appSettings/mwsc_settings.py @@ -0,0 +1,58 @@ +import flet as ft +from utils import AppView, Title +from ..functions import config + + +def Settings(page: ft.Page): + settingsContainer = ft.ListView( + expand=True, + ) + settingsContainer.controls.append(ft.Text('General')) + + def _on_enable_change(e): + print(config.getint('apps', 'mwsc')) + if config.getint('apps', 'mwsc'): + config.save('apps', 'mwsc', '0') + else: + config.save('apps', 'mwsc', '1') + page.update() + + + generalSettings = ft.Container( + content=ft.Column( + controls=[ + ft.Card( + content=ft.Container( + content=ft.Container( + ft.Switch( + label=' Enable this module', + on_change=_on_enable_change, + value=False + ), + ), + padding=10, + on_click=None, + ), + ), + ], + ), + ) + if config.getint('apps', 'mwsc') == 1: + generalSettings.content.controls[0].content.content.content.value = True + settingsContainer.controls.append( + generalSettings, + ) + return AppView( + '/settings/mwsc', + [ + ft.AppBar( + leading=ft.IconButton( + ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, + on_click=lambda _: page.go('/settings'), + ), + title=ft.Text(Title(str(__file__))), + bgcolor=ft.colors.TRANSPARENT, + ), + settingsContainer, + ], + ) diff --git a/modules/settings/appSettings/ooredoo_settings.py b/modules/settings/appSettings/ooredoo_settings.py new file mode 100644 index 0000000..4bdbe05 --- /dev/null +++ b/modules/settings/appSettings/ooredoo_settings.py @@ -0,0 +1,58 @@ +import flet as ft +from utils import AppView, Title +from ..functions import config + + +def Settings(page: ft.Page): + settingsContainer = ft.ListView( + expand=True, + ) + settingsContainer.controls.append(ft.Text('General')) + + def _on_enable_change(e): + print(config.getint('apps', 'ooredoo')) + if config.getint('apps', 'ooredoo'): + config.save('apps', 'ooredoo', '0') + else: + config.save('apps', 'ooredoo', '1') + page.update() + + + generalSettings = ft.Container( + content=ft.Column( + controls=[ + ft.Card( + content=ft.Container( + content=ft.Container( + ft.Switch( + label=' Enable this module', + on_change=_on_enable_change, + value=False + ), + ), + padding=10, + on_click=None, + ), + ), + ], + ), + ) + if config.getint('apps', 'ooredoo') == 1: + generalSettings.content.controls[0].content.content.content.value = True + settingsContainer.controls.append( + generalSettings, + ) + return AppView( + '/settings/ooredoo', + [ + ft.AppBar( + leading=ft.IconButton( + ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, + on_click=lambda _: page.go('/settings'), + ), + title=ft.Text(Title(str(__file__))), + bgcolor=ft.colors.TRANSPARENT, + ), + settingsContainer, + ], + ) diff --git a/modules/settings/appSettings/stelco_settings.py b/modules/settings/appSettings/stelco_settings.py new file mode 100644 index 0000000..12eb94f --- /dev/null +++ b/modules/settings/appSettings/stelco_settings.py @@ -0,0 +1,58 @@ +import flet as ft +from utils import AppView, Title +from ..functions import config + + +def Settings(page: ft.Page): + settingsContainer = ft.ListView( + expand=True, + ) + settingsContainer.controls.append(ft.Text('General')) + + def _on_enable_change(e): + print(config.getint('apps', 'stelco')) + if config.getint('apps', 'stelco'): + config.save('apps', 'stelco', '0') + else: + config.save('apps', 'stelco', '1') + page.update() + + + generalSettings = ft.Container( + content=ft.Column( + controls=[ + ft.Card( + content=ft.Container( + content=ft.Container( + ft.Switch( + label=' Enable this module', + on_change=_on_enable_change, + value=False + ), + ), + padding=10, + on_click=None, + ), + ), + ], + ), + ) + if config.getint('apps', 'stelco') == 1: + generalSettings.content.controls[0].content.content.content.value = True + settingsContainer.controls.append( + generalSettings, + ) + return AppView( + '/settings/stelco', + [ + ft.AppBar( + leading=ft.IconButton( + ft.icons.ARROW_BACK_IOS_NEW_ROUNDED, + on_click=lambda _: page.go('/settings'), + ), + title=ft.Text(Title(str(__file__))), + bgcolor=ft.colors.TRANSPARENT, + ), + settingsContainer, + ], + ) diff --git a/modules/settings/functions/__init__.py b/modules/settings/functions/__init__.py index 1a5cc42..049d170 100644 --- a/modules/settings/functions/__init__.py +++ b/modules/settings/functions/__init__.py @@ -1,3 +1,4 @@ from .config import config from .theme import Theme + __all__ = ['config', 'Theme'] diff --git a/modules/settings/functions/config.py b/modules/settings/functions/config.py index 611e937..9dd82ce 100644 --- a/modules/settings/functions/config.py +++ b/modules/settings/functions/config.py @@ -2,20 +2,19 @@ from configparser import ConfigParser import os static = """ - [general] name = phone = email = -theme = dark +nid = +theme = light [apps] -dhiraagu = 1 -ooredoo = 1 -hdc = 1 -mwsc = 1 -stelco = 1 -medianet = 1 +dhiraagu = 0 +ooredoo = 0 +mwsc = 0 +stelco = 0 +medianet = 0 [dhiraagu] phone = @@ -45,6 +44,7 @@ bill_no = account_no = nid = phone = + """ diff --git a/modules/settings/settings.py b/modules/settings/settings.py index 096e0de..131f700 100644 --- a/modules/settings/settings.py +++ b/modules/settings/settings.py @@ -17,19 +17,24 @@ def Settings(page: ft.Page): content=newName, actions=[ ft.CupertinoButton( - 'Save', on_click=lambda _: ( + 'Save', + on_click=lambda _: ( setattr( - dlg, 'open', False, + dlg, + 'open', + False, ), config.save( - 'general', 'name', + 'general', + 'name', newName.value, ), page.update(), ), ), ft.CupertinoButton( - 'Close', on_click=lambda _: ( + 'Close', + on_click=lambda _: ( setattr(dlg, 'open', False), page.update(), ), @@ -48,19 +53,24 @@ def Settings(page: ft.Page): content=newPhone, actions=[ ft.CupertinoButton( - 'Save', on_click=lambda _: ( + 'Save', + on_click=lambda _: ( setattr( - dlg, 'open', False, + dlg, + 'open', + False, ), config.save( - 'general', 'phone', + 'general', + 'phone', newPhone.value, ), page.update(), ), ), ft.CupertinoButton( - 'Close', on_click=lambda _: ( + 'Close', + on_click=lambda _: ( setattr(dlg, 'open', False), page.update(), ), @@ -79,19 +89,24 @@ def Settings(page: ft.Page): content=newEmail, actions=[ ft.CupertinoButton( - 'Save', on_click=lambda _: ( + 'Save', + on_click=lambda _: ( setattr( - dlg, 'open', False, + dlg, + 'open', + False, ), config.save( - 'general', 'email', + 'general', + 'email', newEmail.value, ), page.update(), ), ), ft.CupertinoButton( - 'Close', on_click=lambda _: ( + 'Close', + on_click=lambda _: ( setattr(dlg, 'open', False), page.update(), ), @@ -110,19 +125,24 @@ def Settings(page: ft.Page): content=newNID, actions=[ ft.CupertinoButton( - 'Save', on_click=lambda _: ( + 'Save', + on_click=lambda _: ( setattr( - dlg, 'open', False, + dlg, + 'open', + False, ), config.save( - 'general', 'nid', + 'general', + 'nid', newNID.value, ), page.update(), ), ), ft.CupertinoButton( - 'Close', on_click=lambda _: ( + 'Close', + on_click=lambda _: ( setattr(dlg, 'open', False), page.update(), ), @@ -267,7 +287,7 @@ def Settings(page: ft.Page): ], ), padding=10, - on_click=None, + on_click=lambda _: page.go('/settings/dhiraagu'), ), ), ft.Card( @@ -289,7 +309,7 @@ def Settings(page: ft.Page): ], ), padding=10, - on_click=lambda _: print('clicked ooredoo'), + on_click=lambda _: page.go('/settings/ooredoo'), ), ), ft.Card( @@ -311,7 +331,7 @@ def Settings(page: ft.Page): ], ), padding=10, - on_click=lambda _: print('clicked stelco'), + on_click=lambda _: page.go('/settings/stelco'), ), ), ft.Card( @@ -333,7 +353,7 @@ def Settings(page: ft.Page): ], ), padding=10, - on_click=lambda _: print('clicked mwsc'), + on_click=lambda _: page.go('/settings/mwsc'), ), ), ft.Card( @@ -355,7 +375,7 @@ def Settings(page: ft.Page): ], ), padding=10, - on_click=lambda _: print('clicked medianet'), + on_click=lambda _: page.go('/settings/medianet'), ), ), ], @@ -373,9 +393,13 @@ def Settings(page: ft.Page): e.value = True config.save('general', 'theme', 'light') Theme(page).change( - ft.ThemeMode.DARK if page.theme_mode == - ft.ThemeMode.LIGHT else ft.ThemeMode.LIGHT, + ( + ft.ThemeMode.DARK + if page.theme_mode == ft.ThemeMode.LIGHT + else ft.ThemeMode.LIGHT + ), ) + themeSettings = ft.Container( content=ft.Column( controls=[ diff --git a/utils/title.py b/utils/title.py index 14eb58a..bfad771 100644 --- a/utils/title.py +++ b/utils/title.py @@ -2,4 +2,4 @@ import os def Title(title: str): - return str(os.path.basename(title)).split('.')[0].title() + return str(os.path.basename(title)).split('.')[0].title().replace('_', ' ') diff --git a/utils/views.py b/utils/views.py index 691b4c3..448fd12 100644 --- a/utils/views.py +++ b/utils/views.py @@ -1,6 +1,13 @@ from modules import Home, Settings from apps import Apps from apps.plugins import Ooredoo, Dhiraagu, Medianet, Mwsc, Stelco +from modules.settings.appSettings import ( + DhiraaguSettings, + MedianetSettings, + StelcoSettings, + OoredooSettings, + MwscSettings, +) def views_handler(page): @@ -10,6 +17,12 @@ def views_handler(page): # settings views['/settings'] = Settings(page) + views['/settings/dhiraagu'] = DhiraaguSettings(page) + views['/settings/ooredoo'] = OoredooSettings(page) + views['/settings/mwsc'] = MwscSettings(page) + views['/settings/medianet'] = MedianetSettings(page) + views['/settings/stelco'] = StelcoSettings(page) + # apps views['/apps'] = Apps(page) views['/apps/dhiraagu'] = Dhiraagu(page) diff --git a/wrappers/__init__.py b/wrappers/__init__.py index 8ecee4d..c498fd6 100644 --- a/wrappers/__init__.py +++ b/wrappers/__init__.py @@ -1,5 +1,5 @@ from .dhiraagu import DhiraaguAPI __all__ = [ - 'DhiraaguAPI' -] \ No newline at end of file + 'DhiraaguAPI', +] diff --git a/wrappers/dhiraagu.py b/wrappers/dhiraagu.py index 1bf4644..3321b10 100644 --- a/wrappers/dhiraagu.py +++ b/wrappers/dhiraagu.py @@ -1,13 +1,14 @@ import requests + class DhiraaguAPI: def __init__( - self, - phone: str = None, - otp: str = None, - token: str = None, - account: str = None, - ) -> None: + self, + phone: str = None, + otp: str = None, + token: str = None, + account: str = None, + ) -> None: self.phone = phone self.otp = otp self.token = token @@ -24,19 +25,19 @@ class DhiraaguAPI: } if self.token: self.headers['Authorization'] = f'Bearer {self.token}' - + def login(self): data = requests.post( 'https://app-production.dhiraagu.com.mv/auth', json={ 'number': self.phone, - 'otp': self.otp - } + 'otp': self.otp, + }, ) return data.json() def bills(self): return requests.get( f'https://app-production.dhiraagu.com.mv/io/v1/info/subscribers/{self.account}/liberate/billinfo', - headers=self.headers + headers=self.headers, ).json()