@@ -228,13 +228,33 @@ class _SidebarHeaderItem extends StatelessWidget {
228228 bool get hasLeading => item.leading != null ;
229229 bool get hasTrailing => item.trailing != null ;
230230
231+ DefaultTextStyle _buildLabelWithDefaultTextStyle (
232+ TextStyle labelStyle,
233+ BuildContext context,
234+ ) {
235+ final isDarkModeEnabled = MacosTheme .of (context).brightness.isDark;
236+
237+ return DefaultTextStyle (
238+ style: labelStyle.copyWith (
239+ fontWeight: FontWeight .bold,
240+ fontSize: (labelStyle.fontSize ?? 14.0 ) * 0.85 ,
241+ color: isDarkModeEnabled
242+ ? MacosColors .white.withValues (alpha: 0.3 )
243+ : MacosColors .black.withValues (alpha: 0.3 ),
244+ overflow: TextOverflow .ellipsis,
245+ ),
246+ child: item.label,
247+ );
248+ }
249+
231250 @override
232251 Widget build (BuildContext context) {
233252 assert (debugCheckHasMacosTheme (context));
234253 final theme = MacosTheme .of (context);
235254
236255 final double spacing = 10.0 + theme.visualDensity.horizontal;
237256 final itemSize = _SidebarItemsConfiguration .of (context).itemSize;
257+
238258 TextStyle ? labelStyle;
239259 switch (itemSize) {
240260 case SidebarItemSize .small:
@@ -289,25 +309,6 @@ class _SidebarHeaderItem extends StatelessWidget {
289309 ),
290310 );
291311 }
292-
293- DefaultTextStyle _buildLabelWithDefaultTextStyle (
294- TextStyle labelStyle,
295- BuildContext context,
296- ) {
297- final isDarkModeEnabled = MacosTheme .of (context).brightness.isDark;
298-
299- return DefaultTextStyle (
300- style: labelStyle.copyWith (
301- fontWeight: FontWeight .bold,
302- fontSize: (labelStyle.fontSize ?? 14.0 ) * 0.85 ,
303- color: isDarkModeEnabled
304- ? MacosColors .white.withValues (alpha: 0.3 )
305- : MacosColors .black.withValues (alpha: 0.3 ),
306- overflow: TextOverflow .ellipsis,
307- ),
308- child: item.label,
309- );
310- }
311312}
312313
313314/// A macOS style navigation-list item intended for use in a [Sidebar]
@@ -336,6 +337,36 @@ class _SidebarItem extends StatelessWidget {
336337
337338 void _handleActionTap () => onClick? .call ();
338339
340+ DefaultTextStyle _buildLabelWithDefaultTextStyle (
341+ TextStyle labelStyle,
342+ Color selectedColor,
343+ BuildContext context,
344+ ) {
345+ if (item.section ?? true ) {
346+ final isDarkModeEnabled = MacosTheme .of (context).brightness.isDark;
347+
348+ return DefaultTextStyle (
349+ style: labelStyle.copyWith (
350+ fontWeight: FontWeight .bold,
351+ fontSize: (labelStyle.fontSize ?? 14.0 ) * 0.85 ,
352+ color: isDarkModeEnabled
353+ ? MacosColors .white.withValues (alpha: 0.3 )
354+ : MacosColors .black.withValues (alpha: 0.3 ),
355+ overflow: TextOverflow .ellipsis,
356+ ),
357+ child: item.label,
358+ );
359+ }
360+
361+ return DefaultTextStyle (
362+ style: labelStyle.copyWith (
363+ color: selected ? textLuminance (selectedColor) : null ,
364+ overflow: TextOverflow .ellipsis,
365+ ),
366+ child: item.label,
367+ );
368+ }
369+
339370 Map <Type , Action <Intent >> get _actionMap => < Type , Action <Intent >> {
340371 ActivateIntent : CallbackAction <ActivateIntent >(
341372 onInvoke: (ActivateIntent intent) => _handleActionTap (),
@@ -344,8 +375,8 @@ class _SidebarItem extends StatelessWidget {
344375 onInvoke: (ButtonActivateIntent intent) => _handleActionTap (),
345376 ),
346377 };
347-
348378 bool get hasLeading => item.leading != null ;
379+
349380 bool get hasTrailing => item.trailing != null ;
350381
351382 @override
@@ -366,6 +397,7 @@ class _SidebarItem extends StatelessWidget {
366397
367398 final double spacing = 10.0 + theme.visualDensity.horizontal;
368399 final itemSize = _SidebarItemsConfiguration .of (context).itemSize;
400+
369401 TextStyle ? labelStyle;
370402 switch (itemSize) {
371403 case SidebarItemSize .small:
@@ -442,36 +474,6 @@ class _SidebarItem extends StatelessWidget {
442474 ),
443475 );
444476 }
445-
446- DefaultTextStyle _buildLabelWithDefaultTextStyle (
447- TextStyle labelStyle,
448- Color selectedColor,
449- BuildContext context,
450- ) {
451- if (item.section ?? true ) {
452- final isDarkModeEnabled = MacosTheme .of (context).brightness.isDark;
453-
454- return DefaultTextStyle (
455- style: labelStyle.copyWith (
456- fontWeight: FontWeight .bold,
457- fontSize: (labelStyle.fontSize ?? 14.0 ) * 0.85 ,
458- color: isDarkModeEnabled
459- ? MacosColors .white.withValues (alpha: 0.3 )
460- : MacosColors .black.withValues (alpha: 0.3 ),
461- overflow: TextOverflow .ellipsis,
462- ),
463- child: item.label,
464- );
465- }
466-
467- return DefaultTextStyle (
468- style: labelStyle.copyWith (
469- color: selected ? textLuminance (selectedColor) : null ,
470- overflow: TextOverflow .ellipsis,
471- ),
472- child: item.label,
473- );
474- }
475477}
476478
477479class _DisclosureSidebarHeaderItem extends StatefulWidget {
0 commit comments