Skip to content

Commit f14aca5

Browse files
authored
Fix alpha value dismissing (#23)
* Remove unused code * Auto-update iOS file * Fix alpha value dismissing, refactor color changing methods * Update version and changelog
1 parent efa8676 commit f14aca5

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.2.3]
2+
3+
* Fix bug on color change where previously set alpha value was ignored.
4+
15
## [1.2.2]
26

37
* Update example app.

example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@
4141
</array>
4242
<key>UIViewControllerBasedStatusBarAppearance</key>
4343
<false/>
44+
<key>CADisableMinimumFrameDurationOnPhone</key>
45+
<true/>
4446
</dict>
4547
</plist>

lib/src/color_picker.dart

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import 'package:flutter/material.dart';
22

3-
import 'widgets/alpha_picker.dart';
4-
import 'widgets/hex_picker.dart';
53
import 'pickers/hsv_picker.dart';
64
import 'pickers/palette_hue_picker.dart';
75
import 'pickers/palette_saturation_picker.dart';
86
import 'pickers/palette_value_picker.dart';
97
import 'pickers/rgb_picker.dart';
108
import 'pickers/swatches_picker.dart';
119
import 'pickers/wheel_picker.dart';
10+
import 'widgets/alpha_picker.dart';
11+
import 'widgets/hex_picker.dart';
1212

1313
enum Picker {
1414
swatches,
@@ -70,29 +70,26 @@ class _ColorPickerState extends State<ColorPicker> {
7070
late int _index;
7171

7272
void _alphaOnChanged(int value) {
73-
_alpha = value;
74-
_color = _color.withAlpha(_alpha);
75-
widget.onChanged(_color);
73+
_updateColor(_color.withAlpha(value));
7674
}
7775

7876
void _colorOnChanged(Color value) {
79-
_color = value;
80-
_hSVColor = HSVColor.fromColor(value);
81-
widget.onChanged(value);
77+
_updateColor(value.withAlpha(_color.alpha));
8278
}
8379

8480
void _hSVColorOnChanged(HSVColor value) {
85-
_color = value.toColor();
86-
_hSVColor = value;
87-
widget.onChanged(value.toColor());
81+
_updateColor(value.toColor().withAlpha(_color.alpha));
8882
}
8983

9084
void _colorWithAlphaOnChanged(Color value) {
91-
_alpha = value.alpha;
92-
final Color color = value.withAlpha(255);
85+
_updateColor(value);
86+
}
87+
88+
void _updateColor(Color color) {
89+
_alpha = color.alpha;
9390
_color = color;
9491
_hSVColor = HSVColor.fromColor(color);
95-
widget.onChanged(value);
92+
widget.onChanged(color);
9693
}
9794

9895
void _pickerOnChanged(_IPicker? value) {

lib/src/pickers/swatches_picker.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ class _SwatchesPickerState extends State<SwatchesPicker>
3030
);
3131
}
3232

33-
Widget buildListView(Color? item) {
34-
if (item == null) return const Divider(height: 60.0);
35-
33+
Widget buildListView(Color item) {
3634
return Container(
3735
width: 40.0,
3836
height: 40.0,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_hsvcolor_picker
22
description: A HSV color picker inspired by chrome devtools and a material color picker for your flutter app.
3-
version: 1.2.2
3+
version: 1.2.3
44
homepage: https://github.com/fluttercandies/flutter_hsvcolor_picker
55

66
dependencies:

0 commit comments

Comments
 (0)