1
0
Fork 0
forked from Fuji/Fuji

Add a warning banner while changing settings

This commit is contained in:
Maarceeli 2025-02-26 06:56:27 +01:00
parent 5616173290
commit 04e2352cd3
2 changed files with 74 additions and 27 deletions

View file

@ -76,13 +76,15 @@ def main(page: ft.Page):
"/behaviour": BehaviourPage(),
"/settings": SettingsPage()
}
page.views.clear()
page.views.append(ft.View(route, [
view = ft.View(route, [
ft.Row([
bar,
ft.Container(content=routes.get(route, HomePage()), expand=True)
], expand=True)
]))
])
page.views.append(view)
page.update()
def on_route_change(e):

View file

@ -4,6 +4,37 @@ from utils import setthemecolor, setlanguage
from i18n import _
def SettingsPage():
# Create the main container to hold everything
main_container = ft.Container()
# Create a custom notification that we'll show/hide
notification = ft.Container(
visible=False,
bgcolor=ft.colors.AMBER_100,
border_radius=5,
padding=10,
margin=ft.margin.only(bottom=20, left=20, right=20),
content=ft.Row([
ft.Icon(ft.icons.INFO_OUTLINED, color=ft.colors.AMBER),
ft.Text(_("Settings changed. Restart required for changes to take effect."),
color=ft.colors.BLACK, expand=True),
ft.IconButton(
icon=ft.icons.CLOSE,
icon_color=ft.colors.GREY_800,
icon_size=20,
on_click=lambda e: hide_notification()
)
])
)
def hide_notification():
notification.visible = False
main_container.update()
def show_notification():
notification.visible = True
main_container.update()
def getlangoptions():
return [
ft.DropdownOption(key="Polski", content=ft.Text("Polski")),
@ -27,12 +58,17 @@ def SettingsPage():
def onlangchange(e):
setlanguage(e)
show_notification()
def onthemechange(e):
setthemecolor(e.data)
show_notification()
return ft.Column([
# Create a column with settings at top and notification container at bottom
main_content = ft.Column([
# Settings at the top
ft.Container(
content=ft.Column([
ft.Text(_("Settings"), size=30, weight="bold"),
ft.Row([
ft.Text(_("Language (Requires restart)")),
@ -43,7 +79,6 @@ def SettingsPage():
on_change=onlangchange
),
]),
ft.Row([
ft.Text(_("Theme (Requires restart)")),
ft.Dropdown(
@ -53,4 +88,14 @@ def SettingsPage():
on_change=onthemechange
)
]),
])
]),
expand=True # Make this container expand to push the notification to the bottom
),
# Notification at the bottom
notification
], expand=True) # Make the column expand to fill the available space
main_container.content = main_content
main_container.expand = True # Make the main container expand
return main_container