Skip to content

Conversation

@mub-pro
Copy link
Contributor

@mub-pro mub-pro commented Mar 12, 2023

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Mar 12, 2023
@mub-pro mub-pro changed the title Fix/37229 Customize color and thickness of connected lines in Stepper.dart Mar 12, 2023
@HansMuller HansMuller self-requested a review March 17, 2023 17:44
@mub-pro
Copy link
Contributor Author

mub-pro commented Mar 26, 2023

@HansMuller Can you please review this PR?

}

Widget _buildLine(bool visible) {
Color _connectorColor(bool isActive) {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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) {
Copy link
Contributor

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

@mub-pro
Copy link
Contributor Author

mub-pro commented Mar 28, 2023

@HansMuller I uploaded the new changes, you can check them.

Comment on lines 430 to 438
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;
}
}
Copy link
Contributor

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;

Copy link
Contributor Author

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.

HansMuller and others added 2 commits March 28, 2023 15:07
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);
Copy link
Contributor

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.

Copy link
Contributor Author

@mub-pro mub-pro Mar 29, 2023

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;

@HansMuller
Copy link
Contributor

@mub-pro - please merge the stepper changes after pulling the changes I've landed into your repo with something like:

git fetch origin
git pull origin your_branchName

@mub-pro
Copy link
Contributor Author

mub-pro commented Mar 30, 2023

@HansMuller I think I messed up the branch history 😟
what do you recommend to solve this problem?

@mub-pro
Copy link
Contributor Author

mub-pro commented Mar 30, 2023

@HansMuller I think I messed up the branch history 😟 what do you recommend to solve this problem?

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.

@mub-pro
Copy link
Contributor Author

mub-pro commented Apr 2, 2023

@HansMuller any updates?

@mub-pro mub-pro requested a review from HansMuller April 7, 2023 22:22
Copy link
Contributor

@HansMuller HansMuller left a 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.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HansMuller HansMuller merged commit df8d819 into flutter:master Apr 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 17, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 18, 2023
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
@reidbaker reidbaker mentioned this pull request Apr 21, 2023
8 tasks
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
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,

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stepper: Custom Connector Line Colours

5 participants