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

Fix alpha value dismissing #23

Merged
merged 4 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.2.3]

* Fix bug on color change where previously set alpha value was ignored.

## [1.2.2]

* Update example app.
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
25 changes: 11 additions & 14 deletions lib/src/color_picker.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';

import 'widgets/alpha_picker.dart';
import 'widgets/hex_picker.dart';
import 'pickers/hsv_picker.dart';
import 'pickers/palette_hue_picker.dart';
import 'pickers/palette_saturation_picker.dart';
import 'pickers/palette_value_picker.dart';
import 'pickers/rgb_picker.dart';
import 'pickers/swatches_picker.dart';
import 'pickers/wheel_picker.dart';
import 'widgets/alpha_picker.dart';
import 'widgets/hex_picker.dart';

enum Picker {
swatches,
Expand Down Expand Up @@ -70,29 +70,26 @@ class _ColorPickerState extends State<ColorPicker> {
late int _index;

void _alphaOnChanged(int value) {
_alpha = value;
_color = _color.withAlpha(_alpha);
widget.onChanged(_color);
_updateColor(_color.withAlpha(value));
}

void _colorOnChanged(Color value) {
_color = value;
_hSVColor = HSVColor.fromColor(value);
widget.onChanged(value);
_updateColor(value.withAlpha(_color.alpha));
}

void _hSVColorOnChanged(HSVColor value) {
_color = value.toColor();
_hSVColor = value;
widget.onChanged(value.toColor());
_updateColor(value.toColor().withAlpha(_color.alpha));
}

void _colorWithAlphaOnChanged(Color value) {
_alpha = value.alpha;
final Color color = value.withAlpha(255);
_updateColor(value);
}

void _updateColor(Color color) {
_alpha = color.alpha;
_color = color;
_hSVColor = HSVColor.fromColor(color);
widget.onChanged(value);
widget.onChanged(color);
}

void _pickerOnChanged(_IPicker? value) {
Expand Down
4 changes: 1 addition & 3 deletions lib/src/pickers/swatches_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class _SwatchesPickerState extends State<SwatchesPicker>
);
}

Widget buildListView(Color? item) {
if (item == null) return const Divider(height: 60.0);

Widget buildListView(Color item) {
return Container(
width: 40.0,
height: 40.0,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_hsvcolor_picker
description: A HSV color picker inspired by chrome devtools and a material color picker for your flutter app.
version: 1.2.2
version: 1.2.3
homepage: https://github.com/fluttercandies/flutter_hsvcolor_picker

dependencies:
Expand Down