this fixes #1 and improved the code base
This commit is contained in:
@ -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,
|
||||
),
|
||||
|
13
modules/settings/appSettings/__init__.py
Normal file
13
modules/settings/appSettings/__init__.py
Normal file
@ -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'
|
||||
]
|
58
modules/settings/appSettings/dhiraagu_settings.py
Normal file
58
modules/settings/appSettings/dhiraagu_settings.py
Normal file
@ -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,
|
||||
],
|
||||
)
|
58
modules/settings/appSettings/medianet_settings.py
Normal file
58
modules/settings/appSettings/medianet_settings.py
Normal file
@ -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,
|
||||
],
|
||||
)
|
58
modules/settings/appSettings/mwsc_settings.py
Normal file
58
modules/settings/appSettings/mwsc_settings.py
Normal file
@ -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,
|
||||
],
|
||||
)
|
58
modules/settings/appSettings/ooredoo_settings.py
Normal file
58
modules/settings/appSettings/ooredoo_settings.py
Normal file
@ -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,
|
||||
],
|
||||
)
|
58
modules/settings/appSettings/stelco_settings.py
Normal file
58
modules/settings/appSettings/stelco_settings.py
Normal file
@ -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,
|
||||
],
|
||||
)
|
@ -1,3 +1,4 @@
|
||||
from .config import config
|
||||
from .theme import Theme
|
||||
|
||||
__all__ = ['config', 'Theme']
|
||||
|
@ -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 =
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
@ -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=[
|
||||
|
Reference in New Issue
Block a user