Skip to content
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

Implemented option to remove color indicator and to change the width of the pallet type slider #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions lib/src/colorpicker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class ColorPicker extends StatefulWidget {
this.labelTypes = const [ColorLabelType.rgb, ColorLabelType.hsv, ColorLabelType.hsl],
@Deprecated('Use Theme.of(context).textTheme.bodyText1 & 2 to alter text style.') this.labelTextStyle,
this.displayThumbColor = false,
this.displayColorIndicator = true,
this.palletTypeSliderWidth = 225.0,
this.portraitOnly = false,
this.colorPickerWidth = 300.0,
this.pickerAreaHeightPercent = 1.0,
Expand All @@ -47,6 +49,8 @@ class ColorPicker extends StatefulWidget {
final double pickerAreaHeightPercent;
final BorderRadius pickerAreaBorderRadius;
final bool hexInputBar;
final bool displayColorIndicator;
final double palletTypeSliderWidth;

/// Allows setting the color using text input, via [TextEditingController].
///
Expand Down Expand Up @@ -290,18 +294,28 @@ class _ColorPickerState extends State<ColorPicker> {
mainAxisAlignment: MainAxisAlignment.center,

Choose a reason for hiding this comment

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

There's some padding just above this line that looks like this:
padding: const EdgeInsets.fromLTRB(15.0, 5.0, 10.0, 5.0),

When widget.displayColorIndicator is false, could you make it so the left and right padding are both 10? Else we end up with the slider being pushed slightly to the right.

children: <Widget>[
GestureDetector(
onTap: () => setState(() {
if (widget.onHistoryChanged != null && !colorHistory.contains(currentHsvColor.toColor())) {
colorHistory.add(currentHsvColor.toColor());
widget.onHistoryChanged!(colorHistory);
onTap: () {
if (widget.displayColorIndicator) {
setState(() {
if (widget.onHistoryChanged != null && !colorHistory.contains(currentHsvColor.toColor())) {
colorHistory.add(currentHsvColor.toColor());
widget.onHistoryChanged!(colorHistory);
}
});
}
}),
child: ColorIndicator(currentHsvColor),
},
child: widget.displayColorIndicator ? ColorIndicator(currentHsvColor) : const SizedBox(),
),
Expanded(
child: Column(
children: <Widget>[
SizedBox(height: 40.0, width: widget.colorPickerWidth - 75.0, child: sliderByPaletteType()),
SizedBox(
height: 40.0,
width: widget.displayColorIndicator
? widget.colorPickerWidth - 75.0
: widget.palletTypeSliderWidth,
child: sliderByPaletteType(),
),
if (widget.enableAlpha)
SizedBox(
height: 40.0,
Expand Down