From bd314eccd2a95b0d44b33c35383f3add419d40a8 Mon Sep 17 00:00:00 2001
From: Iisakki Rotko <iisakki.rotko@gmail.com>
Date: Tue, 21 May 2024 13:59:39 +0200
Subject: [PATCH] refactor!: streamline and improve applayout api

---
 solara/components/applayout.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/solara/components/applayout.py b/solara/components/applayout.py
index b46564458..2c56e76b4 100644
--- a/solara/components/applayout.py
+++ b/solara/components/applayout.py
@@ -196,9 +196,10 @@ def AppLayout(
     children=[],
     sidebar_open=True,
     title=None,
+    show_app_bar: Optional[bool] = None,
     navigation=True,
-    toolbar_dark=True,
-    color: Optional[str] = "primary",
+    toolbar_dark: Optional[bool] = None,
+    color: Optional[str] = None,
     classes: List[str] = [],
     style: Optional[Union[str, Dict[str, str]]] = None,
 ):
@@ -225,6 +226,10 @@ def AppLayout(
      * `children`: The children of the AppLayout. The first child is used as the sidebar content, the rest as the main content.
      * `sidebar_open`: Whether the sidebar is open or not.
      * `title`: The title of the app shown in the app bar, can also be set using the [Title](/documentation/components/page/title) component.
+     * `show_app_bar`: Whether the app bar should be shown. If `None` (the default), `AppBar` is shown if:
+         * There are one or more sibling routes to the current page.
+         * **OR**: There are one or more children of the `AppBar` component.
+         * **OR**: There are one or more children of the `AppBarTitle` component.
      * `toolbar_dark`: Whether the toolbar should be dark or not.
      * `navigation`: Whether the navigation tabs based on routing should be shown.
      * `color`: The color of the toolbar.
@@ -273,7 +278,8 @@ def set_path(index):
             tabs = child_appbar
             children_appbar.remove(tabs)
 
-    show_app_bar = (title and (len(routes) > 1 and navigation)) or bool(children_appbar) or bool(use_drawer) or bool(children_appbartitle) or bool(tabs)
+    if show_app_bar is None:
+        show_app_bar = (len(routes) > 1) or bool(children_appbar) or bool(use_drawer) or bool(children_appbartitle) or bool(tabs)
 
     if style is None:
         style = {"height": "100%", "max-height": "100%", "overflow": "auto"}
@@ -284,12 +290,12 @@ def set_path(index):
     if (tabs is None) and routes and navigation and (len(routes) > 1):
         with solara.lab.Tabs(value=index, on_value=set_path, align="center") as tabs_to_render:
             for route in routes:
-                name = route.path if route.path != "/" else "Home"
+                name = route.label if route.label is not None else (route.path if route.path != "/" else "Home")
                 solara.lab.Tab(name)
 
     if tabs is not None:
         tabs_to_render = tabs
-    if tabs_to_render is not None:
+    if tabs_to_render is not None and navigation:
         v_slots = [{"name": "extension", "children": tabs_to_render}]
     if embedded_mode and not fullscreen:
         # this version doesn't need to run fullscreen