Skip to content

Commit 7582ae0

Browse files
committed
Merge branch 'main' into dev
2 parents fe99a5d + b5f8158 commit 7582ae0

File tree

3 files changed

+94
-25
lines changed

3 files changed

+94
-25
lines changed

app/core/views.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,73 @@ def __init__(
869869
)
870870

871871

872+
class TNavigationMenuNoLeading(UserControl):
873+
"""
874+
Returns a navigation menu for the application without a leading content.
875+
876+
:param title: Title of the navigation menu.
877+
:param on_change: Callable function to be called when the selected item in the menu changes.
878+
:param selected_index: The index of the selected item in the menu.
879+
:param destinations: List of destinations in the menu.
880+
:param menu_height: The height of the menu.
881+
:return: A NavigationRail widget containing the navigation menu.
882+
"""
883+
884+
def __init__(
885+
self,
886+
title: str,
887+
on_change,
888+
selected_index: Optional[int] = 0,
889+
destinations=[],
890+
menu_height: int = 200,
891+
width: int = int(dimens.MIN_WINDOW_WIDTH * 0.3),
892+
left_padding: int = dimens.SPACE_STD,
893+
top_margin: int = dimens.SPACE_STD,
894+
):
895+
896+
super().__init__()
897+
self.titleContainer = Container(
898+
content=TSubHeading(
899+
subtitle=title,
900+
align=utils.TXT_ALIGN_LEFT,
901+
expand=True,
902+
color=colors.GRAY_DARK_COLOR,
903+
),
904+
expand=False,
905+
width=width,
906+
alignment=alignment.center_left,
907+
margin=margin.only(top=top_margin),
908+
padding=padding.only(left=left_padding),
909+
)
910+
self.navigationRail = NavigationRail(
911+
selected_index=selected_index,
912+
min_width=utils.COMPACT_RAIL_WIDTH,
913+
extended=True,
914+
height=menu_height,
915+
min_extended_width=width,
916+
destinations=destinations,
917+
on_change=on_change,
918+
)
919+
920+
def setBgColor(self, side_bar_bg_color):
921+
# set the background color of the navigation menu
922+
self.navigationRail.bgcolor = side_bar_bg_color
923+
self.titleContainer.bgcolor = side_bar_bg_color
924+
self.update()
925+
926+
def build(self):
927+
return Column(
928+
controls=[
929+
self.titleContainer,
930+
self.navigationRail,
931+
],
932+
alignment=utils.START_ALIGNMENT,
933+
horizontal_alignment=utils.START_ALIGNMENT,
934+
spacing=0,
935+
run_spacing=0,
936+
)
937+
938+
872939
class THomeGrid(GridView):
873940
"""Returns a grid view used in the home screen"""
874941

app/home/view.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ def __init__(self, params: TViewParams):
222222
]
223223

224224

225+
226+
SIDEBAR_WIDTH = 250 # width of the sidebar menu in home screen
225227
class HomeScreen(TView, UserControl):
226228
"""The home screen"""
227229

@@ -239,15 +241,17 @@ def __init__(
239241
)
240242
self.selected_tab = 0
241243

242-
self.main_menu = views.TNavigationMenu(
244+
self.main_menu = views.TNavigationMenuNoLeading(
243245
title=self.main_menu_handler.menu_title,
244246
destinations=self.get_menu_destinations(),
245247
on_change=lambda e: self.on_menu_destination_change(e),
248+
246249
)
247-
self.secondary_menu = views.TNavigationMenu(
250+
self.secondary_menu = views.TNavigationMenuNoLeading(
248251
title=self.secondary_menu_handler.menu_title,
249252
destinations=self.get_menu_destinations(menu_level=1),
250253
on_change=lambda e: self.on_menu_destination_change(e, menu_level=1),
254+
251255
)
252256
self.current_menu_handler = self.main_menu_handler
253257
self.destination_view = self.current_menu_handler.items[0].destination
@@ -347,22 +351,23 @@ def build(self):
347351
),
348352
height=dimens.FOOTER_HEIGHT,
349353
)
350-
self.main_body = Column(
351-
col={
352-
"xs": 8,
353-
"md": 9,
354-
"lg": 10,
355-
},
356-
alignment=utils.START_ALIGNMENT,
357-
horizontal_alignment=utils.START_ALIGNMENT,
358-
controls=[
359-
self.action_bar,
360-
self.destination_content_container,
361-
],
354+
self.main_body = Container(
355+
width=dimens.MIN_WINDOW_WIDTH - SIDEBAR_WIDTH,
356+
content=Column(
357+
alignment=utils.START_ALIGNMENT,
358+
horizontal_alignment=utils.START_ALIGNMENT,
359+
controls=[
360+
self.action_bar,
361+
self.destination_content_container,
362+
],
363+
),
362364
)
363365
self.side_bar = Container(
364-
col={"xs": 4, "md": 3, "lg": 2},
365-
padding=padding.only(top=dimens.SPACE_XL),
366+
width=SIDEBAR_WIDTH,
367+
padding=padding.only(
368+
top=dimens.SPACE_XL,
369+
left=0,
370+
),
366371
content=Column(
367372
controls=[
368373
self.main_menu,
@@ -384,7 +389,7 @@ def build(self):
384389
self.home_screen_view = Container(
385390
Column(
386391
[
387-
ResponsiveRow(
392+
Row(
388393
controls=[
389394
self.side_bar,
390395
self.main_body,
@@ -419,18 +424,14 @@ def load_preferred_theme(self):
419424
self.show_snack(result.error_msg, is_error=True)
420425
return
421426
self.preferred_theme = result.data
422-
side_bar_components = [
423-
self.side_bar,
424-
self.main_menu,
425-
self.secondary_menu,
426-
]
427427
side_bar_bg_color = colors.SIDEBAR_DARK_COLOR # default is dark mode
428428
self.action_bar.bgcolor = colors.ACTION_BAR_DARK_COLOR
429429
if self.preferred_theme == theme.THEME_MODES.light.value:
430430
side_bar_bg_color = colors.SIDEBAR_LIGHT_COLOR
431431
self.action_bar.bgcolor = colors.ACTION_BAR_LIGHT_COLOR
432-
for component in side_bar_components:
433-
component.bgcolor = side_bar_bg_color
432+
self.side_bar.bgcolor = side_bar_bg_color
433+
self.main_menu.setBgColor(side_bar_bg_color)
434+
self.secondary_menu.setBgColor(side_bar_bg_color)
434435
self.footer.bgcolor = side_bar_bg_color # footer and side bar have same bgcolor
435436
self.update_self()
436437

@@ -443,6 +444,7 @@ def on_window_resized_listener(self, width, height):
443444
self.action_bar.height + self.footer.height + 50
444445
)
445446
self.destination_content_container.height = DESTINATION_CONTENT_PERCENT_HEIGHT
447+
self.main_body.width = self.page_width - SIDEBAR_WIDTH
446448
self.update_self()
447449

448450
def will_unmount(self):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pytest
2-
pandas
2+
pandas<2.0.0
33
matplotlib
44
altair
55
pydantic

0 commit comments

Comments
 (0)