import flet as ft from pages.home import Home from pages.history import History from pages.settings import Settings from flet import app def main(page: ft.Page): page.title = "Nahrungstracker" page.scroll = True history_instance = History() # Erstellen der History-Instanz home = Home(history_instance) # Übergeben der History-Instanz an Home home.page = page settings = Settings() settings.page = page def on_navigation_change(e): page.controls.clear() if e.control.selected_index == 0: page.appbar = home.create_appbar() page.add(home) elif e.control.selected_index == 1: page.appbar = ft.AppBar(title=ft.Text("History")) history_instance.update_history_view() page.add(history_instance) # Hinzufügen der History-Instanz zur Seite elif e.control.selected_index == 2: page.appbar = ft.AppBar(title=ft.Text("Settings")) page.add(settings) page.update() #test = ft.NavigationBarDestination(icon=ft.icons.HOME, label="Home") page.navigation_bar = ft.NavigationBar( destinations=[ ft.NavigationBarDestination(icon=ft.icons.HOME, label="Home"), ft.NavigationBarDestination(icon=ft.icons.HISTORY, label="History"), ft.NavigationBarDestination(icon=ft.icons.SETTINGS, label="Settings") ], on_change=on_navigation_change, ) page.appbar = home.create_appbar() page.add(home) page.update() if __name__ == "__main__": print("run") app(target=main)