init
This commit is contained in:
commit
d205277cdd
182 changed files with 22978 additions and 0 deletions
48
lib/widgets/block_progress_bar.dart
Normal file
48
lib/widgets/block_progress_bar.dart
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/tokens.dart';
|
||||
|
||||
/// The segmented block progress bar from Ratune'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(
|
||||
children: List.generate(cells, (i) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0.5),
|
||||
child: ColoredBox(
|
||||
color: i < filled ? filledColor : RatuneColors.border,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue