-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Customize color and thickness of connected lines in Stepper.dart #122485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@HansMuller Can you please review this PR? |
| } | ||
|
|
||
| Widget _buildLine(bool visible) { | ||
| Color _connectorColor(bool isActive) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If widget.connectorColor resolves to null, then we should use the default colors:
final ColorScheme colorScheme = Theme.of(context).colorScheme;
final Set<MaterialState> states = <MaterialState>{
if (isActive) MaterialState.selected else MaterialState.disabled,
};
return widget.connectorColor?.resolve(states) ?? isActive ? colorScheme.primary : Colors.grey.shade400;A test should confirm this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(widget.connectorColor == null) {
return isActive ? colorSchema.primary : Colors.grey.shade400;
}
this code set colors to default if connectorColor is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That fails if connectorColor is non-null but connectorColor.resolve(states) returns null. Please see https://github.com/flutter/flutter/pull/122485/files#r1149856878
|
|
||
| Color _circleColor(int index) { | ||
| final ColorScheme colorScheme = Theme.of(context).colorScheme; | ||
| if (widget.connectorColor != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same feedback as for _connectorColor
|
@HansMuller I uploaded the new changes, you can check them. |
| if(widget.connectorColor?.resolve(states) != null) { | ||
| return widget.connectorColor!.resolve(states); | ||
| } else { | ||
| return widget.steps[index].isActive ? colorScheme.secondary : colorScheme.background; | ||
| if (!_isDark()) { | ||
| return widget.steps[index].isActive ? colorScheme.primary : colorScheme.onSurface.withOpacity(0.38); | ||
| } else { | ||
| return widget.steps[index].isActive ? colorScheme.secondary : colorScheme.background; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final Color? color = widget.connectorColor?.resolve(states);
if (color != null) {
return color;
}
final bool isActive = widget.steps[index].isActive;
if (!_isDark()) {
return isActive ? colorScheme.primary : colorScheme.onSurface.withOpacity(0.38);
}
return sActive ? colorScheme.secondary : colorScheme.background;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's clear now, though isActive has to be at the top because it's used in states variable.
For consistency with the rest of Flutter renamed colorSchema to colorScheme
| final Set<MaterialState> states = <MaterialState>{ | ||
| if (isActive) MaterialState.selected else MaterialState.disabled, | ||
| }; | ||
| return widget.connectorColor?.resolve(states) ?? (isActive ?colorScheme.primary:Colors.grey.shade400); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to be backwards compatible. It looks like the color was unconditionally Colors.grey.shade400. That would explain the customer testing failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but active lines won't be colorized,
Color _connectorColor(bool isActive) {
final ColorScheme colorScheme = Theme.of(context).colorScheme;
final Set<MaterialState> states = <MaterialState>{
if (isActive) MaterialState.selected else MaterialState.disabled,
};
final Color? connectorColor = widget.connectorColor?.resolve(states);
if(connectorColor != null) {
return connectorColor;
}
return isActive ? colorScheme.primary : Colors.grey.shade400;
}
what do you think about code above?
or maybe like this
final Color? connectorColor = widget.connectorColor?.resolve(states);
if(connectorColor == null) {
return isActive ? colorScheme.primary : Colors.grey.shade400;
}
return connectorColor;
|
@mub-pro - please merge the stepper changes after pulling the changes I've landed into your repo with something like: git fetch origin |
|
@HansMuller I think I messed up the branch history 😟 |
I did git reset and forced push, I think it's working. What happened before is some kind of wrong way of git rebase command done by me that makes commits get duplicated and the number of files that were changed increased which I did not touch. |
|
@HansMuller any updates? |
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Unfortunately I'm going to be out for a week. I will try and land it when I return.
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Manual roll requested by [email protected] flutter/flutter@50171bb...15cb1f8 2023-04-17 [email protected] Fix Chip highlight color isn't drawn on top of the background color (flutter/flutter#124673) 2023-04-17 [email protected] Deprecates string for reorderable list in material_localizations (flutter/flutter#124711) 2023-04-17 [email protected] Fix a null crash in SelectableRegion Widget (flutter/flutter#124736) 2023-04-17 [email protected] Customize color and thickness of connected lines in Stepper.dart (flutter/flutter#122485) 2023-04-17 [email protected] Roll Flutter Engine from 30e1c4308213 to b2d07388ceb6 (7 revisions) (flutter/flutter#124987) 2023-04-17 [email protected] Remove token permissions for coverage. (flutter/flutter#124909) 2023-04-17 [email protected] Roll Packages from e4ec155 to 0277f2a (9 revisions) (flutter/flutter#124972) 2023-04-17 [email protected] Roll Flutter Engine from 360ca05311c8 to 30e1c4308213 (3 revisions) (flutter/flutter#124963) 2023-04-17 [email protected] Roll Flutter Engine from 4a998b73a2df to 360ca05311c8 (2 revisions) (flutter/flutter#124952) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Manual roll requested by [email protected] flutter/flutter@50171bb...15cb1f8 2023-04-17 [email protected] Fix Chip highlight color isn't drawn on top of the background color (flutter/flutter#124673) 2023-04-17 [email protected] Deprecates string for reorderable list in material_localizations (flutter/flutter#124711) 2023-04-17 [email protected] Fix a null crash in SelectableRegion Widget (flutter/flutter#124736) 2023-04-17 [email protected] Customize color and thickness of connected lines in Stepper.dart (flutter/flutter#122485) 2023-04-17 [email protected] Roll Flutter Engine from 30e1c4308213 to b2d07388ceb6 (7 revisions) (flutter/flutter#124987) 2023-04-17 [email protected] Remove token permissions for coverage. (flutter/flutter#124909) 2023-04-17 [email protected] Roll Packages from e4ec155 to 0277f2a (9 revisions) (flutter/flutter#124972) 2023-04-17 [email protected] Roll Flutter Engine from 360ca05311c8 to 30e1c4308213 (3 revisions) (flutter/flutter#124963) 2023-04-17 [email protected] Roll Flutter Engine from 4a998b73a2df to 360ca05311c8 (2 revisions) (flutter/flutter#124952) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
| width: 24.0, | ||
| child: Center( | ||
| child: SizedBox( | ||
| width: _isLast(index) ? 0.0 : 1.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can someone please tell me why the _isLast check was removed here?
Hi, I added the ability to customize the color of the connected lines in Stepper.dart, also the circle's color will match the set value of the connector color.
Before

After

fixes #37229
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.