|
|
|
|
@ -6,25 +6,25 @@ import 'components/base_step.dart';
|
|
|
|
|
import 'components/custom_line.dart';
|
|
|
|
|
class CustomStepper extends StatefulWidget {
|
|
|
|
|
final List<StepModel> steps;
|
|
|
|
|
final OnStepReached onStepReached;
|
|
|
|
|
final Color unreachedStepBackgroundColor;
|
|
|
|
|
final Color unreachedStepTextColor;
|
|
|
|
|
final Color unreachedStepIconColor;
|
|
|
|
|
final Color unreachedStepBorderColor;
|
|
|
|
|
final BorderType unreachedStepBorderType;
|
|
|
|
|
final OnStepReached ?onStepReached;
|
|
|
|
|
final Color ?unreachedStepBackgroundColor;
|
|
|
|
|
final Color ?unreachedStepTextColor;
|
|
|
|
|
final Color ?unreachedStepIconColor;
|
|
|
|
|
final Color ?unreachedStepBorderColor;
|
|
|
|
|
final BorderType ?unreachedStepBorderType;
|
|
|
|
|
final Color activeStepBackgroundColor;
|
|
|
|
|
final Color activeStepTextColor;
|
|
|
|
|
final Color? activeStepTextColor;
|
|
|
|
|
final Color activeStepIconColor;
|
|
|
|
|
final Color activeStepBorderColor;
|
|
|
|
|
final BorderType activeStepBorderType;
|
|
|
|
|
final BorderType ?activeStepBorderType;
|
|
|
|
|
final Color finishedStepBackgroundColor;
|
|
|
|
|
final Color finishedStepBorderColor;
|
|
|
|
|
final Color finishedStepTextColor;
|
|
|
|
|
final Color finishedStepIconColor;
|
|
|
|
|
final BorderType finishedStepBorderType;
|
|
|
|
|
final Color ?finishedStepBorderColor;
|
|
|
|
|
final Color ?finishedStepTextColor;
|
|
|
|
|
final Color ?finishedStepIconColor;
|
|
|
|
|
final BorderType ?finishedStepBorderType;
|
|
|
|
|
final double stepRadius;
|
|
|
|
|
final int activeStep;
|
|
|
|
|
final int maxReachedStep;
|
|
|
|
|
final int ?maxReachedStep;
|
|
|
|
|
final Set<int>? reachedSteps;
|
|
|
|
|
final AlignmentGeometry alignment;
|
|
|
|
|
final double internalPadding;
|
|
|
|
|
@ -34,11 +34,11 @@ class CustomStepper extends StatefulWidget {
|
|
|
|
|
final Duration stepAnimationDuration;
|
|
|
|
|
final double borderThickness;
|
|
|
|
|
final StepShape stepShape;
|
|
|
|
|
final double stepBorderRadius;
|
|
|
|
|
final double ?stepBorderRadius;
|
|
|
|
|
final bool showStepBorder;
|
|
|
|
|
final bool showScrollbar;
|
|
|
|
|
final bool fitWidth;
|
|
|
|
|
final LineStyle lineStyle;
|
|
|
|
|
final LineStyle ?lineStyle;
|
|
|
|
|
|
|
|
|
|
const CustomStepper({
|
|
|
|
|
Key? key,
|
|
|
|
|
@ -85,9 +85,9 @@ class CustomStepper extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
late ScrollController _scrollController;
|
|
|
|
|
int _selectedIndex;
|
|
|
|
|
LineStyle lineStyle;
|
|
|
|
|
EdgeInsetsGeometry _padding;
|
|
|
|
|
int ?_selectedIndex;
|
|
|
|
|
LineStyle? lineStyle;
|
|
|
|
|
EdgeInsetsGeometry? _padding;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -97,14 +97,14 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
|
|
|
|
|
_padding = const EdgeInsetsDirectional.all(10);
|
|
|
|
|
if (widget.steps.any((element) => element.topTitle)) {
|
|
|
|
|
_padding = _padding.add(const EdgeInsetsDirectional.only(top: 45));
|
|
|
|
|
_padding = _padding!.add(const EdgeInsetsDirectional.only(top: 45));
|
|
|
|
|
}
|
|
|
|
|
if (widget.titlesAreLargerThanSteps) {
|
|
|
|
|
_padding = _padding.add(EdgeInsetsDirectional.symmetric(
|
|
|
|
|
horizontal: lineStyle.lineLength / 2));
|
|
|
|
|
_padding = _padding!.add(EdgeInsetsDirectional.symmetric(
|
|
|
|
|
horizontal: lineStyle!.lineLength / 2));
|
|
|
|
|
}
|
|
|
|
|
if (widget.padding != null) {
|
|
|
|
|
_padding.add(widget.padding);
|
|
|
|
|
_padding!.add(widget.padding);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -126,21 +126,6 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Controls the step scrolling.
|
|
|
|
|
void _afterLayout(_) {
|
|
|
|
|
for (int i = 0; i < widget.steps.length; i++) {
|
|
|
|
|
_scrollController.animateTo(
|
|
|
|
|
i *
|
|
|
|
|
((widget.stepRadius * 2) +
|
|
|
|
|
widget.internalPadding +
|
|
|
|
|
lineStyle.lineLength),
|
|
|
|
|
duration: widget.stepAnimationDuration,
|
|
|
|
|
curve: widget.stepAnimationCurve,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (_selectedIndex == i) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -184,26 +169,26 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
radius: widget.stepRadius,
|
|
|
|
|
isActive: index == widget.activeStep,
|
|
|
|
|
isFinished: widget.reachedSteps != null
|
|
|
|
|
? index < widget.activeStep && widget.reachedSteps.contains(index)
|
|
|
|
|
? index < widget.activeStep && widget.reachedSteps!.contains(index)
|
|
|
|
|
: index < widget.activeStep,
|
|
|
|
|
isUnreached: index > widget.activeStep,
|
|
|
|
|
isAlreadyReached: widget.reachedSteps != null
|
|
|
|
|
? widget.reachedSteps.contains(index)
|
|
|
|
|
? widget.reachedSteps!.contains(index)
|
|
|
|
|
: widget.maxReachedStep != null
|
|
|
|
|
? index <= widget.maxReachedStep
|
|
|
|
|
? index <= widget.maxReachedStep!
|
|
|
|
|
: false,
|
|
|
|
|
activeStepBackgroundColor: widget.activeStepBackgroundColor,
|
|
|
|
|
activeStepBorderColor: widget.activeStepBorderColor,
|
|
|
|
|
activeTextColor: widget.activeStepTextColor,
|
|
|
|
|
activeTextColor: widget.activeStepTextColor??AppColor.neutral100,
|
|
|
|
|
activeIconColor: widget.activeStepIconColor,
|
|
|
|
|
unreachedBackgroundColor: widget.unreachedStepBackgroundColor,
|
|
|
|
|
unreachedBorderColor: widget.unreachedStepBorderColor,
|
|
|
|
|
unreachedTextColor: widget.unreachedStepTextColor,
|
|
|
|
|
unreachedIconColor: widget.unreachedStepIconColor,
|
|
|
|
|
unreachedBackgroundColor: widget.unreachedStepBackgroundColor??AppColor.white10,
|
|
|
|
|
unreachedBorderColor: widget.unreachedStepBorderColor??AppColor.neutral100,
|
|
|
|
|
unreachedTextColor: widget.unreachedStepTextColor??AppColor.neutral100,
|
|
|
|
|
unreachedIconColor: widget.unreachedStepIconColor??AppColor.neutral100,
|
|
|
|
|
padding: max(widget.internalPadding, 0),
|
|
|
|
|
stepRadius: widget.stepBorderRadius,
|
|
|
|
|
stepRadius: widget.stepBorderRadius??10,
|
|
|
|
|
showStepBorder: widget.showStepBorder,
|
|
|
|
|
lineLength: lineStyle.lineLength,
|
|
|
|
|
lineLength: lineStyle!.lineLength,
|
|
|
|
|
enabled: widget.steps[index].enabled,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -224,20 +209,20 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Color _getLineColor(int index) {
|
|
|
|
|
Color preferredColor;
|
|
|
|
|
Color ?preferredColor;
|
|
|
|
|
if (index == widget.activeStep) {
|
|
|
|
|
//Active Step
|
|
|
|
|
preferredColor = lineStyle.activeLineColor;
|
|
|
|
|
preferredColor = lineStyle!.activeLineColor??AppColor.primary10;
|
|
|
|
|
} else if (index > widget.activeStep) {
|
|
|
|
|
//Unreached Step
|
|
|
|
|
preferredColor = lineStyle.unreachedLineColor;
|
|
|
|
|
preferredColor = lineStyle!.unreachedLineColor??AppColor.primary10;
|
|
|
|
|
} else if (index < widget.activeStep) {
|
|
|
|
|
//Finished Step
|
|
|
|
|
preferredColor = lineStyle.finishedLineColor;
|
|
|
|
|
preferredColor = lineStyle!.finishedLineColor??AppColor.primary10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return preferredColor ??
|
|
|
|
|
lineStyle.defaultLineColor ??
|
|
|
|
|
lineStyle!.defaultLineColor ??
|
|
|
|
|
Theme.of(context).colorScheme.primary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -248,7 +233,7 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
top: axis == Axis.horizontal
|
|
|
|
|
? (widget.stepRadius - lineStyle.lineThickness)
|
|
|
|
|
? (widget.stepRadius - lineStyle!.lineThickness)
|
|
|
|
|
: 0,
|
|
|
|
|
),
|
|
|
|
|
child: _buildBaseLine(index, axis),
|
|
|
|
|
@ -257,7 +242,7 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
widget.steps[index].lineText != null) ...[
|
|
|
|
|
const SizedBox(height: 5),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: lineStyle.lineLength,
|
|
|
|
|
width: lineStyle!.lineLength,
|
|
|
|
|
child: widget.steps[index].customLineWidget ??
|
|
|
|
|
Text(
|
|
|
|
|
widget.steps[index].lineText,
|
|
|
|
|
@ -274,16 +259,16 @@ class _CustomStepperState extends State<CustomStepper> {
|
|
|
|
|
|
|
|
|
|
EasyLine _buildBaseLine(int index, Axis axis) {
|
|
|
|
|
return EasyLine(
|
|
|
|
|
length: lineStyle.lineLength,
|
|
|
|
|
length: lineStyle!.lineLength,
|
|
|
|
|
color: _getLineColor(index),
|
|
|
|
|
thickness: lineStyle.lineThickness,
|
|
|
|
|
spacing: lineStyle.lineSpace,
|
|
|
|
|
width: lineStyle.lineWidth,
|
|
|
|
|
thickness: lineStyle!.lineThickness,
|
|
|
|
|
spacing: lineStyle!.lineSpace,
|
|
|
|
|
width: lineStyle!.lineWidth,
|
|
|
|
|
axis: axis,
|
|
|
|
|
lineType:
|
|
|
|
|
index > widget.activeStep - 1 && lineStyle.unreachedLineType != null
|
|
|
|
|
? lineStyle.unreachedLineType
|
|
|
|
|
: lineStyle.lineType,
|
|
|
|
|
index > widget.activeStep - 1 && lineStyle!.unreachedLineType != null
|
|
|
|
|
? lineStyle!.unreachedLineType
|
|
|
|
|
: lineStyle!.lineType,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|