2020-12-30 14:13:25 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class ProgressBar extends StatefulWidget {
|
2022-05-24 18:55:39 +00:00
|
|
|
const ProgressBar({
|
2021-03-15 15:39:44 +00:00
|
|
|
required this.steps,
|
|
|
|
required this.activeIndex,
|
2022-10-26 16:26:09 +00:00
|
|
|
super.key,
|
2022-06-05 19:36:32 +00:00
|
|
|
});
|
2020-12-30 14:13:25 +00:00
|
|
|
|
|
|
|
final int activeIndex;
|
|
|
|
|
|
|
|
final List<String> steps;
|
|
|
|
|
|
|
|
@override
|
2022-05-25 12:21:56 +00:00
|
|
|
State<ProgressBar> createState() => _ProgressBarState();
|
2020-12-30 14:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _ProgressBarState extends State<ProgressBar> {
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) {
|
2022-06-05 22:40:34 +00:00
|
|
|
final double progress =
|
|
|
|
1 / widget.steps.length * (widget.activeIndex + 0.3);
|
2020-12-30 14:13:25 +00:00
|
|
|
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
decoration: BoxDecoration(
|
2023-03-27 17:02:44 +00:00
|
|
|
color: const Color(0xFFDDDDDD),
|
2020-12-30 14:13:25 +00:00
|
|
|
borderRadius: BorderRadius.circular(5),
|
|
|
|
),
|
|
|
|
child: LayoutBuilder(
|
2022-06-05 19:36:32 +00:00
|
|
|
builder: (final _, final constraints) => AnimatedContainer(
|
2022-06-05 22:40:34 +00:00
|
|
|
width: constraints.maxWidth * progress,
|
|
|
|
height: 5,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(5),
|
2022-08-24 05:35:49 +00:00
|
|
|
color: Theme.of(context).colorScheme.surfaceVariant,
|
|
|
|
gradient: LinearGradient(
|
2022-06-05 22:40:34 +00:00
|
|
|
begin: Alignment.topLeft,
|
|
|
|
end: Alignment.bottomRight,
|
2022-08-24 05:35:49 +00:00
|
|
|
colors: [
|
|
|
|
Theme.of(context).colorScheme.primary,
|
2023-11-06 13:15:38 +00:00
|
|
|
Theme.of(context).colorScheme.secondary,
|
2022-08-24 05:35:49 +00:00
|
|
|
],
|
2020-12-30 14:13:25 +00:00
|
|
|
),
|
2022-06-05 19:36:32 +00:00
|
|
|
),
|
2022-06-05 22:40:34 +00:00
|
|
|
duration: const Duration(
|
|
|
|
milliseconds: 300,
|
|
|
|
),
|
|
|
|
),
|
2020-12-30 14:13:25 +00:00
|
|
|
),
|
2021-01-06 17:35:57 +00:00
|
|
|
),
|
2020-12-30 14:13:25 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|