44from dataclasses import dataclass
55
66from flet import (
7- Alignment ,
87 Border ,
98 BorderSide ,
109 Column ,
1110 Container ,
1211 ElevatedButton ,
1312 Icon ,
14- IconButton ,
1513 Icons ,
1614 Margin ,
1715 NavigationRailDestination ,
1816 Padding ,
19- PopupMenuButton ,
20- PopupMenuItem ,
2117 ResponsiveRow ,
2218 Row ,
2319 Text ,
4541from ..preferences .intent import PreferencesIntent
4642
4743
48- def get_toolbar (
49- on_click_new_btn : Callable ,
50- on_click_profile_btn : Callable ,
51- on_view_settings_clicked : Callable ,
52- ):
53- """Slim toolbar — actions only, no redundant title."""
54- new_btn = TextButton (
55- content = Row (
56- controls = [
57- Icon (
58- Icons .ADD ,
59- size = dimens .SM_ICON_SIZE ,
60- color = colors .accent ,
61- ),
62- Text (
63- "New" ,
64- size = fonts .BODY_1_SIZE ,
65- color = colors .accent ,
66- weight = fonts .BOLD_FONT ,
67- ),
68- ],
69- spacing = dimens .SPACE_XXS ,
70- ),
71- on_click = on_click_new_btn ,
72- )
73- toolbar = Container (
74- alignment = Alignment .CENTER ,
75- height = dimens .TOOLBAR_HEIGHT ,
76- bgcolor = colors .bg ,
77- padding = Padding .symmetric (horizontal = dimens .SPACE_LG ),
78- content = Row (
79- alignment = MainAxisAlignment .END ,
80- vertical_alignment = CrossAxisAlignment .CENTER ,
81- controls = [
82- Row (
83- spacing = dimens .SPACE_XXS ,
84- controls = [
85- new_btn ,
86- IconButton (
87- icon = Icons .SETTINGS_OUTLINED ,
88- icon_size = dimens .ICON_SIZE ,
89- icon_color = colors .text_muted ,
90- on_click = on_view_settings_clicked ,
91- tooltip = "Preferences" ,
92- ),
93- IconButton (
94- icon = Icons .PERSON_OUTLINE_OUTLINED ,
95- icon_size = dimens .ICON_SIZE ,
96- icon_color = colors .text_muted ,
97- tooltip = "Profile" ,
98- on_click = on_click_profile_btn ,
99- ),
100- PopupMenuButton (
101- icon = Icons .HELP_OUTLINE ,
102- icon_size = dimens .ICON_SIZE ,
103- icon_color = colors .text_secondary ,
104- items = [
105- PopupMenuItem (
106- icon = Icons .CONTACT_SUPPORT ,
107- content = "Ask a question" ,
108- on_click = lambda _ : webbrowser .open (
109- "https://github.com/tuttle-dev/tuttle/discussions"
110- ),
111- ),
112- PopupMenuItem (
113- icon = Icons .BUG_REPORT ,
114- content = "Report a bug" ,
115- on_click = lambda _ : webbrowser .open (
116- "https://github.com/tuttle-dev/tuttle/issues"
117- ),
118- ),
119- ],
120- ),
121- ],
122- ),
123- ],
124- ),
125- )
126- return toolbar , new_btn
127-
128-
12944class MainMenuItemsHandler :
13045 """Manages home's main-menu items."""
13146
@@ -272,21 +187,39 @@ def __init__(self, params: TViewParams):
272187 self .status_bar_manager = StatusBarManager (
273188 on_click_overdue = lambda e : self ._jump_to_invoicing (),
274189 on_click_outstanding = lambda e : self ._jump_to_invoicing (),
190+ on_click_settings = lambda e : self .on_view_settings_clicked (e ),
191+ on_click_profile = lambda e : self .on_click_profile (e ),
192+ on_click_help_ask = lambda _ : webbrowser .open (
193+ "https://github.com/tuttle-dev/tuttle/discussions"
194+ ),
195+ on_click_help_bug = lambda _ : webbrowser .open (
196+ "https://github.com/tuttle-dev/tuttle/issues"
197+ ),
275198 )
276199
277- # Toolbar (slim, no title — view heading is the title)
278- self .toolbar , self ._new_btn = get_toolbar (
279- on_click_new_btn = self .on_click_add_new ,
280- on_click_profile_btn = self .on_click_profile ,
281- on_view_settings_clicked = self .on_view_settings_clicked ,
200+ # "+ New" button (shown only for views that support creating entities)
201+ self ._new_btn = TextButton (
202+ content = Row (
203+ controls = [
204+ Icon (Icons .ADD , size = dimens .SM_ICON_SIZE , color = colors .accent ),
205+ Text (
206+ "New" ,
207+ size = fonts .BODY_1_SIZE ,
208+ color = colors .accent ,
209+ weight = fonts .BOLD_FONT ,
210+ ),
211+ ],
212+ spacing = dimens .SPACE_XXS ,
213+ ),
214+ on_click = self .on_click_add_new ,
282215 )
283216 self ._update_new_btn_visibility ()
284217
285218 def _on_sidebar_item_selected (self , item : views .NavigationMenuItem ):
286219 """Called when the user clicks a sidebar nav item."""
287220 self ._selected_flat_index = self ._all_items .index (item )
288221 self .destination_view = item .destination
289- self .destination_content_container .content = self .destination_view
222+ self ._destination_wrapper .content = self .destination_view
290223 self ._update_new_btn_visibility ()
291224 self ._update_status_bar_for_view (item .label )
292225 self .update_self ()
@@ -323,26 +256,33 @@ def on_click_profile(self, e):
323256
324257 # ── Build ─────────────────────────────────────────────────
325258 def build (self ):
326- self .destination_content_container = Container (
327- padding = Padding .all (dimens .SPACE_MD ),
259+ self ._destination_wrapper = Container (
328260 content = self .destination_view ,
329261 expand = True ,
330262 )
331-
332- # Status bar — VS Code style thin bar at bottom
333- self .status_bar = Container (
334- height = dimens .FOOTER_HEIGHT ,
335- bgcolor = colors .bg_statusbar ,
336- padding = Padding .symmetric (horizontal = dimens .SPACE_SM ),
337- content = Row (
263+ self .destination_content_container = Container (
264+ padding = Padding .only (
265+ left = dimens .SPACE_MD ,
266+ right = dimens .SPACE_MD ,
267+ bottom = dimens .SPACE_MD ,
268+ top = dimens .SPACE_XS ,
269+ ),
270+ content = Column (
338271 controls = [
339- Text ("Tuttle" , size = 11 , color = colors .text_inverse ),
272+ Row (
273+ controls = [self ._new_btn ],
274+ alignment = MainAxisAlignment .END ,
275+ ),
276+ self ._destination_wrapper ,
340277 ],
341- alignment = MainAxisAlignment .START ,
342- vertical_alignment = CrossAxisAlignment .CENTER ,
278+ spacing = 0 ,
343279 ),
280+ expand = True ,
344281 )
345282
283+ # Status bar — interactive bar built by StatusBarManager
284+ self .status_bar = self .status_bar_manager .build ()
285+
346286 # Sidebar
347287 self .side_bar = Container (
348288 width = dimens .SIDEBAR_WIDTH ,
@@ -363,7 +303,6 @@ def build(self):
363303 horizontal_alignment = CrossAxisAlignment .START ,
364304 spacing = 0 ,
365305 controls = [
366- self .toolbar ,
367306 self .destination_content_container ,
368307 ],
369308 )
0 commit comments