settings UI
This commit is contained in:
3
modules/settings/functions/__init__.py
Normal file
3
modules/settings/functions/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .config import config
|
||||
from .theme import Theme
|
||||
__all__ = ['config', 'Theme']
|
60
modules/settings/functions/config.py
Normal file
60
modules/settings/functions/config.py
Normal file
@ -0,0 +1,60 @@
|
||||
from configparser import ConfigParser
|
||||
import os
|
||||
|
||||
static = """
|
||||
|
||||
[general]
|
||||
name = CustomIcon
|
||||
phone =
|
||||
email =
|
||||
|
||||
[apps]
|
||||
dhiraagu = true
|
||||
ooredoo = true
|
||||
hdc = true
|
||||
mwsc = true
|
||||
stelco = true
|
||||
medianet = true
|
||||
|
||||
[dhiraagu]
|
||||
phone =
|
||||
otp =
|
||||
cookie =
|
||||
|
||||
[ooredoo]
|
||||
phone =
|
||||
otp =
|
||||
cookie =
|
||||
|
||||
[hdc]
|
||||
property =
|
||||
nid =
|
||||
|
||||
[mwsc]
|
||||
meter_no =
|
||||
account_no =
|
||||
mobile_no =
|
||||
|
||||
[stelco]
|
||||
account_no =
|
||||
bill_no =
|
||||
|
||||
[medianet]
|
||||
account_no =
|
||||
nid =
|
||||
phone =
|
||||
"""
|
||||
|
||||
class Config(ConfigParser):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
if not os.path.exists("config.ini"):
|
||||
self.initialize(content=static)
|
||||
self.read("config.ini")
|
||||
|
||||
def initialize(self, content):
|
||||
with open("config.ini", 'a+') as file:
|
||||
file.write(content)
|
||||
|
||||
|
||||
config = Config()
|
16
modules/settings/functions/theme.py
Normal file
16
modules/settings/functions/theme.py
Normal file
@ -0,0 +1,16 @@
|
||||
import flet as ft
|
||||
|
||||
class Theme:
|
||||
def __init__(self, page: ft.Page) -> None:
|
||||
self.page = page
|
||||
|
||||
def change(self, theme: ft.ThemeMode = None):
|
||||
if theme:
|
||||
self.page.theme_mode = theme
|
||||
else:
|
||||
self.page.theme_mode = (
|
||||
ft.ThemeMode.DARK
|
||||
if self.page.theme_mode == ft.ThemeMode.LIGHT
|
||||
else ft.ThemeMode.LIGHT
|
||||
)
|
||||
self.page.update()
|
Reference in New Issue
Block a user