Skip to content

Commit

Permalink
save & sync switch states
Browse files Browse the repository at this point in the history
  • Loading branch information
0dm committed Jun 2, 2023
1 parent 56d3cff commit e3732a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openadapt/app/cards.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from nicegui import ui
from subprocess import Popen
from openadapt.app.objects.local_file_picker import local_file_picker
from openadapt.app.util import set_dark, sync_switch


def settings(dark_mode):
with ui.dialog() as settings, ui.card():
ui.switch("Dark mode", on_change=lambda: dark_mode.toggle())

s = ui.switch("Dark mode", on_change=lambda: set_dark(dark_mode, s.value))
sync_switch(s, dark_mode)
ui.button("Close", on_click=lambda: settings.close())

settings.open()
Expand Down
8 changes: 8 additions & 0 deletions openadapt/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ def on_export(dest):
os.remove("openadapt.db.bz2")

ui.notify("Exported data.")


def sync_switch(switch, prop):
switch.value = prop.value


def set_dark(dark_mode, value):
dark_mode.value = value

0 comments on commit e3732a3

Please sign in to comment.