diff --git a/README.md b/README.md
index fa79c63..b176d39 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
A fully Independent Application for cross platform
## 🎯 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.
+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.
@@ -46,5 +46,5 @@ So what could be better than having a fully independent App where YOU control YO
### Developed with ❤️:
-
-
+
+
diff --git a/main.py b/main.py
index 8fff741..d44f4e6 100644
--- a/main.py
+++ b/main.py
@@ -1,13 +1,13 @@
import flet as ft
from utils import views_handler
-
+from modules.settings.functions import config
def main(page: ft.Page):
page.title = 'BillPay'
- print("Initial route:", page.route)
+ print('Initial route:', page.route)
def route_change(e):
- print("Route change:", e.route)
+ print('Route change:', e.route)
page.views.clear()
page.views.append(
views_handler(page)[page.route],
@@ -15,11 +15,14 @@ def main(page: ft.Page):
page.update()
def view_pop(e):
- print("View pop:", e.view)
+ print('View pop:', e.view)
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:
+ page.theme_mode = ft.ThemeMode.LIGHT
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)
diff --git a/modules/home.py b/modules/home.py
index e377be1..30f31e2 100644
--- a/modules/home.py
+++ b/modules/home.py
@@ -6,11 +6,11 @@ from datetime import datetime
def greet(time: datetime):
if 5 <= time.hour < 12:
- return "Goodmorning,"
+ return 'Goodmorning,'
elif 12 <= time.hour < 18:
- return "Goodafternoon,"
+ return 'Goodafternoon,'
else:
- return "Goodevening,"
+ return 'Goodevening,'
def Home(page: ft.Page):
@@ -24,7 +24,7 @@ def Home(page: ft.Page):
weight=ft.FontWeight.W_200,
),
ft.Text(
- config.get('general', 'name').split(" ")[0],
+ config.get('general', 'name').split(' ')[0],
size=40,
weight=ft.FontWeight.W_200,
),
@@ -32,7 +32,7 @@ def Home(page: ft.Page):
ft.ResponsiveRow(
[
ft.Container(
- content=ft.Text("A"),
+ content=ft.Text('A'),
margin=10,
padding=10,
bgcolor=ft.colors.with_opacity(0.1, '#000000'),
@@ -40,7 +40,7 @@ def Home(page: ft.Page):
),
ft.Divider(),
ft.Container(
- content=ft.Text("B"),
+ content=ft.Text('B'),
margin=10,
padding=10,
bgcolor=ft.colors.with_opacity(0.1, '#000000'),
@@ -48,7 +48,7 @@ def Home(page: ft.Page):
),
ft.Divider(),
ft.Container(
- content=ft.Text("C"),
+ content=ft.Text('C'),
margin=10,
padding=10,
bgcolor=ft.colors.with_opacity(0.1, '#000000'),
@@ -56,7 +56,7 @@ def Home(page: ft.Page):
),
ft.Divider(),
ft.Container(
- content=ft.Text("D"),
+ content=ft.Text('D'),
margin=10,
padding=10,
bgcolor=ft.colors.with_opacity(0.1, '#000000'),
@@ -74,7 +74,7 @@ def Home(page: ft.Page):
content=ft.Row(
[
ft.Container(
- content=ft.Icon(ft.icons.APPS),
+ content=ft.Icon(ft.icons.APPS, color=ft.colors.WHITE),
margin=10,
padding=10,
alignment=ft.alignment.center,
@@ -85,7 +85,7 @@ def Home(page: ft.Page):
on_click=None,
),
ft.Container(
- content=ft.Icon(ft.icons.HISTORY),
+ content=ft.Icon(ft.icons.HISTORY, color=ft.colors.WHITE),
margin=10,
padding=10,
alignment=ft.alignment.center,
@@ -96,7 +96,7 @@ def Home(page: ft.Page):
on_click=None,
),
ft.Container(
- content=ft.Icon(ft.icons.SETTINGS),
+ content=ft.Icon(ft.icons.SETTINGS, color=ft.colors.WHITE),
margin=10,
padding=10,
alignment=ft.alignment.center,
@@ -105,10 +105,10 @@ def Home(page: ft.Page):
height=60,
border_radius=10,
ink=True,
- on_click=lambda _: page.go("/settings"),
+ on_click=lambda _: page.go('/settings'),
),
ft.Container(
- content=ft.Icon(ft.icons.LIST),
+ content=ft.Icon(ft.icons.LIST, color=ft.colors.WHITE),
margin=10,
padding=10,
alignment=ft.alignment.center,
@@ -117,7 +117,9 @@ def Home(page: ft.Page):
height=60,
border_radius=10,
ink=True,
- on_click=lambda e: print("Clickable with Ink clicked!"),
+ on_click=lambda e: print(
+ 'Clickable with Ink clicked!',
+ ),
),
],
alignment=ft.MainAxisAlignment.CENTER,
diff --git a/modules/settings/functions/config.py b/modules/settings/functions/config.py
index 7fc57e4..252b72f 100644
--- a/modules/settings/functions/config.py
+++ b/modules/settings/functions/config.py
@@ -4,9 +4,10 @@ import os
static = """
[general]
-name =
+name =
phone =
email =
+theme = dark
[apps]
dhiraagu = true
@@ -57,5 +58,11 @@ class Config(ConfigParser):
with open('config.ini', 'a+') as file:
file.write(content)
+ def save(self, section, key, value):
+ config.set(section, key, value)
+ with open('config.ini', 'w') as configfile:
+ self.write(configfile)
+ self.read('config.ini')
+
config = Config()
diff --git a/modules/settings/functions/theme.py b/modules/settings/functions/theme.py
index febd161..f2bfc33 100644
--- a/modules/settings/functions/theme.py
+++ b/modules/settings/functions/theme.py
@@ -1,4 +1,5 @@
import flet as ft
+from .config import config
class Theme:
@@ -8,10 +9,5 @@ class Theme:
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
- )
+ print(theme)
self.page.update()
diff --git a/modules/settings/settings.py b/modules/settings/settings.py
index 8bdefe2..acc9e49 100644
--- a/modules/settings/settings.py
+++ b/modules/settings/settings.py
@@ -1,6 +1,6 @@
import flet as ft
from utils import AppView, Title
-from .functions import Theme
+from .functions import Theme, config
def Settings(page: ft.Page):
@@ -8,6 +8,131 @@ def Settings(page: ft.Page):
expand=True,
)
settingsContainer.controls.append(ft.Text('General'))
+
+ def _on_name_change(e):
+ newName = ft.CupertinoTextField(value=config.get('general', 'name'))
+ dlg = ft.CupertinoAlertDialog(
+ modal=True,
+ title=ft.Text('Enter your Full name'),
+ content=newName,
+ actions=[
+ ft.CupertinoButton(
+ 'Save', on_click=lambda _: (
+ setattr(
+ dlg, 'open', False,
+ ),
+ config.save(
+ 'general', 'name',
+ newName.value,
+ ),
+ page.update(),
+ ),
+ ),
+ ft.CupertinoButton(
+ 'Close', on_click=lambda _: (
+ setattr(dlg, 'open', False),
+ page.update()
+ ),
+ ),
+ ],
+ )
+ page.dialog = dlg
+ dlg.open = True
+ page.update()
+
+ def _on_phone_change(e):
+ newPhone = ft.CupertinoTextField(value=config.get('general', 'phone'))
+ dlg = ft.CupertinoAlertDialog(
+ modal=True,
+ title=ft.Text('Enter your Mobile'),
+ content=newPhone,
+ actions=[
+ ft.CupertinoButton(
+ 'Save', on_click=lambda _: (
+ setattr(
+ dlg, 'open', False,
+ ),
+ config.save(
+ 'general', 'phone',
+ newPhone.value,
+ ),
+ page.update(),
+ ),
+ ),
+ ft.CupertinoButton(
+ 'Close', on_click=lambda _: (
+ setattr(dlg, 'open', False),
+ page.update()
+ ),
+ ),
+ ],
+ )
+ page.dialog = dlg
+ dlg.open = True
+ page.update()
+
+ def _on_email_change(e):
+ newEmail = ft.CupertinoTextField(value=config.get('general', 'email'))
+ dlg = ft.CupertinoAlertDialog(
+ modal=True,
+ title=ft.Text('Enter your Email'),
+ content=newEmail,
+ actions=[
+ ft.CupertinoButton(
+ 'Save', on_click=lambda _: (
+ setattr(
+ dlg, 'open', False,
+ ),
+ config.save(
+ 'general', 'email',
+ newEmail.value,
+ ),
+ page.update(),
+ ),
+ ),
+ ft.CupertinoButton(
+ 'Close', on_click=lambda _: (
+ setattr(dlg, 'open', False),
+ page.update()
+ ),
+ ),
+ ],
+ )
+ page.dialog = dlg
+ dlg.open = True
+ page.update()
+
+ def _on_nid_change(e):
+ newNID = ft.CupertinoTextField(value=config.get('general', 'nid'))
+ dlg = ft.CupertinoAlertDialog(
+ modal=True,
+ title=ft.Text('Enter your NID'),
+ content=newNID,
+ actions=[
+ ft.CupertinoButton(
+ 'Save', on_click=lambda _: (
+ setattr(
+ dlg, 'open', False,
+ ),
+ config.save(
+ 'general', 'nid',
+ newNID.value,
+ ),
+ page.update(),
+ ),
+ ),
+ ft.CupertinoButton(
+ 'Close', on_click=lambda _: (
+ setattr(dlg, 'open', False),
+ page.update()
+ ),
+ ),
+ ],
+ )
+ page.dialog = dlg
+ dlg.open = True
+ page.update()
+
generalSettings = ft.Container(
content=ft.Column(
controls=[
@@ -26,7 +151,7 @@ def Settings(page: ft.Page):
],
),
padding=10,
- on_click=lambda _: print('clicked username'),
+ on_click=_on_name_change,
),
),
ft.Card(
@@ -44,7 +169,7 @@ def Settings(page: ft.Page):
],
),
padding=10,
- on_click=lambda _: print('clicked phone'),
+ on_click=_on_phone_change,
),
),
ft.Card(
@@ -62,7 +187,7 @@ def Settings(page: ft.Page):
],
),
padding=10,
- on_click=lambda _: print('clicked email'),
+ on_click=_on_email_change,
),
),
ft.Card(
@@ -80,7 +205,7 @@ def Settings(page: ft.Page):
],
),
padding=10,
- on_click=lambda _: print('clicked email'),
+ on_click=_on_nid_change,
),
),
],
@@ -89,35 +214,35 @@ def Settings(page: ft.Page):
settingsContainer.controls.append(
generalSettings,
)
- settingsContainer.controls.append(ft.Divider())
- settingsContainer.controls.append(ft.Text('Notifications'))
- notificationsSettings = ft.Container(
- content=ft.Column(
- controls=[
- ft.Card(
- content=ft.Container(
- ink=True,
- content=ft.Column(
- [
- ft.ListTile(
- leading=ft.Icon(ft.icons.TELEGRAM),
- title=ft.Text('Telegram'),
- subtitle=ft.Text(
- 'Telegram Notifications for reminders and Bill pays',
- ),
- ),
- ],
- ),
- padding=10,
- on_click=lambda _: print('clicked username'),
- ),
- ),
- ],
- ),
- )
- settingsContainer.controls.append(
- notificationsSettings,
- )
+ # settingsContainer.controls.append(ft.Divider())
+ # settingsContainer.controls.append(ft.Text('Notifications'))
+ # notificationsSettings = ft.Container(
+ # content=ft.Column(
+ # controls=[
+ # ft.Card(
+ # content=ft.Container(
+ # ink=True,
+ # content=ft.Column(
+ # [
+ # ft.ListTile(
+ # leading=ft.Icon(ft.icons.TELEGRAM),
+ # title=ft.Text('Telegram'),
+ # subtitle=ft.Text(
+ # 'Telegram Notifications for reminders and Bill pays',
+ # ),
+ # ),
+ # ],
+ # ),
+ # padding=10,
+ # on_click=lambda _: print('clicked username'),
+ # ),
+ # ),
+ # ],
+ # ),
+ # )
+ # settingsContainer.controls.append(
+ # notificationsSettings,
+ # )
settingsContainer.controls.append(ft.Divider())
settingsContainer.controls.append(ft.Text('Apps'))
appsSettings = ft.Container(
@@ -241,7 +366,16 @@ def Settings(page: ft.Page):
settingsContainer.controls.append(ft.Text('Theme'))
def _on_theme_change(e):
- Theme(page).change()
+ if page.theme_mode == ft.ThemeMode.LIGHT:
+ e.value = False
+ config.save('general', 'theme', 'light')
+ else:
+ e.value = True
+ config.save('general', 'theme', 'dark')
+ Theme(page).change(
+ ft.ThemeMode.DARK if page.theme_mode ==
+ ft.ThemeMode.LIGHT else ft.ThemeMode.LIGHT,
+ )
themeSettings = ft.Container(
content=ft.Column(
controls=[
@@ -249,9 +383,9 @@ def Settings(page: ft.Page):
content=ft.Container(
content=ft.Container(
ft.Switch(
- value=True,
label=' Switch to dark theme',
on_change=_on_theme_change,
+ value=True,
),
),
padding=10,
diff --git a/utils/title.py b/utils/title.py
index 2d916c6..14eb58a 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()