@@ -36,6 +36,9 @@ class TDProgress extends StatelessWidget {
3636 this .linearBorderRadius,
3737 double ? circleRadius,
3838 this .showLabel = true ,
39+ this .customProgressLabel,
40+ this .labelWidgetWidth,
41+ this .labelWidgetAlignment,
3942 this .onTap,
4043 this .onLongPress,
4144 int animationDuration = 300 ,
@@ -78,6 +81,15 @@ class TDProgress extends StatelessWidget {
7881 /// 是否显示标签
7982 final bool showLabel;
8083
84+ /// 自定义标签
85+ final Widget ? customProgressLabel;
86+
87+ /// 自定义标签宽度
88+ final double ? labelWidgetWidth;
89+
90+ /// 自定义标签对齐方式
91+ final Alignment ? labelWidgetAlignment;
92+
8193 /// 点击事件
8294 final VoidCallback ? onTap;
8395
@@ -113,6 +125,9 @@ class TDProgress extends StatelessWidget {
113125 linearBorderRadius: linearBorderRadius ?? defaultValues.linearBorderRadius,
114126 circleRadius: circleRadius ?? defaultValues.circleRadius,
115127 showLabel: showLabel,
128+ customProgressLabel: customProgressLabel,
129+ labelWidgetWidth: labelWidgetWidth,
130+ labelWidgetAlignment: labelWidgetAlignment,
116131 onTap: onTap,
117132 onLongPress: onLongPress,
118133 type: type,
@@ -180,6 +195,9 @@ class ProgressIndicator extends StatefulWidget {
180195 final TDProgressType type;
181196 final TDProgressStatus progressStatus;
182197 final bool showLabel;
198+ final Widget ? customProgressLabel;
199+ final double ? labelWidgetWidth;
200+ final Alignment ? labelWidgetAlignment;
183201 final VoidCallback ? onTap;
184202 final VoidCallback ? onLongPress;
185203 final int animationDuration;
@@ -198,6 +216,9 @@ class ProgressIndicator extends StatefulWidget {
198216 required this .type,
199217 this .progressStatus = TDProgressStatus .primary,
200218 this .showLabel = true ,
219+ this .customProgressLabel,
220+ this .labelWidgetWidth,
221+ this .labelWidgetAlignment,
201222 this .onTap,
202223 this .onLongPress,
203224 this .animationDuration = 300 ,
@@ -371,9 +392,15 @@ class _ProgressIndicatorState extends State<ProgressIndicator>
371392 crossAxisAlignment: CrossAxisAlignment .center,
372393 children: [
373394 if (widget.progressLabelPosition == TDProgressLabelPosition .left)
374- Padding (
395+ Container (
375396 padding: const EdgeInsets .only (right: 8.0 ),
376- child: _buildLabelWidget (TDTheme .of (context).fontGyColor1),
397+ alignment: widget.labelWidgetAlignment?? Alignment .centerRight,
398+ constraints: BoxConstraints (
399+ minWidth: widget.labelWidgetWidth?? (maxWidth* 0.1 > 70 ? maxWidth* 0.04
400+ : maxWidth* 0.1 ),
401+ ),
402+ child: widget.customProgressLabel??
403+ _buildLabelWidget (TDTheme .of (context).fontGyColor1),
377404 ),
378405 Expanded (
379406 child: Stack (
@@ -390,10 +417,16 @@ class _ProgressIndicatorState extends State<ProgressIndicator>
390417 ],
391418 )),
392419 if (widget.progressLabelPosition == TDProgressLabelPosition .right)
393- Padding (
394- padding: const EdgeInsets .only (left: 8.0 ),
395- child: _buildLabelWidget (TDTheme .of (context).fontGyColor1),
420+ Container (
421+ padding: const EdgeInsets .only (left: 8.0 ),
422+ alignment: widget.labelWidgetAlignment?? Alignment .centerLeft,
423+ constraints: BoxConstraints (
424+ minWidth: widget.labelWidgetWidth?? (maxWidth* 0.1 > 70 ? maxWidth* 0.04
425+ : maxWidth* 0.1 ),
396426 ),
427+ child: widget.customProgressLabel??
428+ _buildLabelWidget (TDTheme .of (context).fontGyColor1),
429+ )
397430 ],
398431 );
399432 },
0 commit comments