import 'package:flutter/material.dart'; import '../theme/tokens.dart'; /// The segmented block progress bar from Timbre's now-playing strip /// (`progress_style = "██░"`). Discrete cells: filled cells use the accent, /// empty cells the border grey, with hairline gaps between them. class BlockProgressBar extends StatelessWidget { const BlockProgressBar({ super.key, required this.progress, this.cells = 40, this.height = 10, this.color, }) : assert(progress >= 0 && progress <= 1); /// 0.0–1.0 elapsed fraction. final double progress; /// Number of block cells to render. final int cells; final double height; /// Filled color; defaults to the theme accent. final Color? color; @override Widget build(BuildContext context) { final filledColor = color ?? Theme.of(context).colorScheme.primary; final filled = (progress * cells).round(); return SizedBox( height: height, child: Row( // Stretch each cell to the bar's full height. Without this the childless // ColoredBox cells get loose (min-height 0) constraints under the Row's // default center alignment and collapse to zero height — making the whole // bar invisible. crossAxisAlignment: CrossAxisAlignment.stretch, children: List.generate(cells, (i) { return Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 0.5), child: ColoredBox( color: i < filled ? filledColor : TimbreColors.border, ), ), ); }), ), ); } }