Skip to content

Commit

Permalink
Fix alpha value dismissing (#23)
Browse files Browse the repository at this point in the history
* Remove unused code

* Auto-update iOS file

* Fix alpha value dismissing, refactor color changing methods

* Update version and changelog
  • Loading branch information
nohli authored Jun 24, 2022
1 parent efa8676 commit f14aca5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
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

0 comments on commit f14aca5

Please sign in to comment.