bible-tracker/lib/widgets/progress_bar.dart

61 lines
1.5 KiB
Dart
Raw Permalink Normal View History

2026-04-20 18:39:49 +00:00
import 'package:flutter/material.dart';
import 'theme.dart';
/// A thin rounded progress bar used throughout the app.
class ProgressBar extends StatelessWidget {
const ProgressBar({
super.key,
required this.value,
required this.color,
this.height = 6,
});
final double value;
final Color color;
final double height;
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(height / 2),
child: LinearProgressIndicator(
value: value.clamp(0.0, 1.0),
minHeight: height,
valueColor: AlwaysStoppedAnimation<Color>(color),
backgroundColor: Theme.of(context).colorScheme.surfaceContainerHighest,
),
);
}
}
/// A pill showing a percentage, colored by the tracker/book accent.
class ProgressPill extends StatelessWidget {
const ProgressPill({super.key, required this.fraction, required this.color});
final double fraction;
final Color color;
@override
Widget build(BuildContext context) {
final int percent = (fraction * 100).round();
return Container(
padding: const EdgeInsets.symmetric(
horizontal: AppTokens.spaceM,
vertical: AppTokens.spaceXS,
),
decoration: BoxDecoration(
color: color.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(AppTokens.radiusL),
),
child: Text(
'$percent%',
style: Theme.of(context).textTheme.labelMedium?.copyWith(
color: color,
fontWeight: FontWeight.w600,
),
),
);
}
}