show badge for deep nesting

This commit is contained in:
Fabian Freund
2026-05-26 20:31:23 +02:00
parent 3b99bd8a93
commit 6f59d048bf
@@ -17,13 +17,12 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import 'dart:math' as math;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart'; import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
import 'package:weblibre/presentation/widgets/inline_count_badge.dart';
// Cap glyph count so the badge stays readable on deep trees. // Above this depth, collapse the chevrons into a single icon + count badge.
const int _maxDepthGlyphs = 4; const int _maxInlineGlyphs = 3;
class TabDepthIndicator extends StatelessWidget { class TabDepthIndicator extends StatelessWidget {
final int depth; final int depth;
@@ -42,7 +41,8 @@ class TabDepthIndicator extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme; final scheme = Theme.of(context).colorScheme;
final glyphCount = math.min(depth, _maxDepthGlyphs); final showBadge = depth > _maxInlineGlyphs;
final glyphCount = showBadge ? 1 : depth;
return SizedBox( return SizedBox(
height: height, height: height,
@@ -60,6 +60,14 @@ class TabDepthIndicator extends StatelessWidget {
size: iconSize, size: iconSize,
color: scheme.onSurfaceVariant, color: scheme.onSurfaceVariant,
), ),
if (showBadge) ...[
const SizedBox(width: 2),
InlineCountBadge(
count: depth,
backgroundColor: scheme.secondaryContainer,
foregroundColor: scheme.onSecondaryContainer,
),
],
], ],
), ),
), ),