From 201b444ebbed14e0c7ce785274deaec2e1ffb747 Mon Sep 17 00:00:00 2001 From: Mike Rydstrom Date: Wed, 3 Mar 2021 06:02:50 +0200 Subject: [PATCH] Version 1.1.4 release --- CHANGELOG.md | 9 +- example/lib/main.dart | 6 +- example/pubspec.lock | 44 +++---- example/pubspec.yaml | 4 +- lib/src/color_picker.dart | 115 +++++++++++------- pubspec.lock | 81 +++++++----- pubspec.yaml | 6 +- test/flex_color_indicator_test.dart | 5 - ..._tests.dart => flex_color_tools_test.dart} | 0 9 files changed, 164 insertions(+), 106 deletions(-) delete mode 100644 test/flex_color_indicator_test.dart rename test/{flex_color_tools_tests.dart => flex_color_tools_test.dart} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index deee5de..e421691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the **FlexColorPicker** package will be documented in this file. +## [1.1.4] - March 3, 2021 +* New property `selectedPickerTypeColor`: Defines the color of the thumb on the slider that shows the selected picker. +* New property `colorCodePrefixStyle`: Defines the text style of the prefix for the color code. + If not defined it defaults to same style as `colorCodeTextStyle`. + ## [1.1.3] - December 22, 2020 * Fixed the faulty documentation and comment for showPickerDialog parameter insetPadding. * Fixed the faulty default value for showPickerDialog parameter insetPadding, the new default @@ -11,11 +16,11 @@ All notable changes to the **FlexColorPicker** package will be documented in thi ## [1.1.2] - December 5, 2020 * Temporary: The Wrap implementation for showing the color code and integer value was changed to a Row due to a regression in Flutter SDK causing a crash issue on channels dev and master when showing the ColorPicker in a Dialog. For more info see here: https://github.com/flutter/flutter/issues/71687 -When the issue is resolved, the implementation will be reverted back to a Wrap. Using a Wrap has the added benefit of breaking the color code display+input field, and the rarely used int value, into two rows in case a large font is used in a narrow view when they are both configured to be shown. The Row may overflow in some rare cases. If you do not plan to use the ColorPicker with channels and versions affected by the issue, you can still use the previous version 1.1.1 to keep using the Wrap implementation if you need it. With normal styling it is typically not needed. +When the issue is resolved, the implementation will be reverted to a Wrap. Using a Wrap has the added benefit of breaking the color code display+input field, and the rarely used int value, into two rows in case a large font is used in a narrow view when they are both configured to be shown. The Row may overflow in some rare cases. If you do not plan to use the ColorPicker with channels and versions affected by the issue, you can still use the previous version 1.1.1 to keep using the Wrap implementation if you need it. With normal styling it is typically not needed. * Fixed that the provided `TextStyle` via property `colorCodeTextStyle` was not also applied to the shown color integer value when `showColorValue` was set to `true`, as stated in API doc and intended. ## [1.1.1] - November 11, 2020 -* Updated the example app and documentation. The update includes updated screen shots and updated animated gifs. +* Updated the example app and documentation. The update includes updated screenshots and updated animated gifs. * Unit tests for ColorTools added, widget tests still pending for later updates. ## [1.1.0] - November 6, 2020 diff --git a/example/lib/main.dart b/example/lib/main.dart index 1a16e95..c84bd0e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -208,7 +208,11 @@ class _ColorPickerPageState extends State { showColorCode: true, materialNameTextStyle: Theme.of(context).textTheme.caption, colorNameTextStyle: Theme.of(context).textTheme.caption, - colorCodeTextStyle: Theme.of(context).textTheme.caption, + // Showing color code prefix and text styled differently in the dialog. + colorCodeTextStyle: Theme.of(context).textTheme.bodyText2, + colorCodePrefixStyle: Theme.of(context).textTheme.caption, + // Showing the new thumb color property option in dialog version + selectedPickerTypeColor: Theme.of(context).colorScheme.primary, pickersEnabled: const { ColorPickerType.both: false, ColorPickerType.primary: true, diff --git a/example/pubspec.lock b/example/pubspec.lock index 4bc7b0a..9c5773b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,56 +7,56 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flex_color_picker: dependency: "direct main" description: - name: flex_color_picker - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" + path: ".." + relative: true + source: path + version: "1.1.4" flutter: dependency: "direct main" description: flutter @@ -73,21 +73,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -99,55 +99,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: dart: ">=2.12.0-0.0 <3.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d8bf1e7..ea191e8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,12 +1,12 @@ name: color_picker_example description: Simple example of how to use the FlexColorPicker package. -version: 1.1.3 +version: 1.1.4 environment: sdk: ">=2.7.0 <3.0.0" dependencies: - flex_color_picker: any + flex_color_picker: ^1.1.4 flutter: sdk: flutter diff --git a/lib/src/color_picker.dart b/lib/src/color_picker.dart index 35051db..504254a 100644 --- a/lib/src/color_picker.dart +++ b/lib/src/color_picker.dart @@ -77,16 +77,6 @@ class ColorPicker extends StatefulWidget { this.wheelDiameter = 190, this.wheelWidth = 16, this.wheelHasBorder = false, - this.selectedPickerTypeColor, - // Color picker types shown and used by the color picker. - this.pickersEnabled = const { - ColorPickerType.both: false, - ColorPickerType.primary: true, - ColorPickerType.accent: true, - ColorPickerType.bw: false, - ColorPickerType.custom: false, - ColorPickerType.wheel: false, - }, // Headings and sub headings used by the color picker. this.heading, this.subheading, @@ -99,10 +89,20 @@ class ColorPicker extends StatefulWidget { this.showColorCode = false, this.showColorValue = false, this.colorCodeTextStyle, + this.colorCodePrefixStyle, this.colorCodeIcon = Icons.copy, this.enableTooltips = true, - this.colorCodePrefixStyle, + // Color picker types shown and used by the color picker. + this.pickersEnabled = const { + ColorPickerType.both: false, + ColorPickerType.primary: true, + ColorPickerType.accent: true, + ColorPickerType.bw: false, + ColorPickerType.custom: false, + ColorPickerType.wheel: false, + }, // Segmented color picker selector control properties. + this.selectedPickerTypeColor, this.pickerTypeTextStyle, this.pickerTypeLabels = const { ColorPickerType.primary: _selectPrimaryLabel, @@ -272,20 +272,6 @@ class ColorPicker extends StatefulWidget { /// Defaults to false. final bool wheelHasBorder; - /// A [ColorPickerType] to bool map. - /// - /// Defines which picker types are - /// enabled in the color picker's sliding segmented selector and - /// are thus available as color pickers. - /// - /// Available options are based on the [ColorPickerType] enum that - /// includes both, primary, accent, bw, custom and wheel. - /// Any undefined or missing enum keys in a given map are treated as false. - /// - /// By default a map that that sets primary and accent pickers to true is - /// used if no or a null map is given. - final Map pickersEnabled; - /// Heading widget for the color picker. /// /// Typically a Text widget, e.g. Text('Select color'). @@ -354,6 +340,11 @@ class ColorPicker extends StatefulWidget { /// Defaults to Theme.of(context).textTheme.bodyText2, if not defined. final TextStyle colorCodeTextStyle; + /// The TextStyle of the prefix of the color code. + /// + /// Defaults to [colorCodeTextStyle], if not defined. + final TextStyle colorCodePrefixStyle; + /// Icon data for icon used on the button that copies the Flutter style color /// code to the to clipboard. /// @@ -367,6 +358,27 @@ class ColorPicker extends StatefulWidget { /// Defaults to true. final bool enableTooltips; + /// A [ColorPickerType] to bool map. + /// + /// Defines which picker types are + /// enabled in the color picker's sliding segmented selector and + /// are thus available as color pickers. + /// + /// Available options are based on the [ColorPickerType] enum that + /// includes both, primary, accent, bw, custom and wheel. + /// Any undefined or missing enum keys in a given map are treated as false. + /// + /// By default a map that that sets primary and accent pickers to true is + /// used if no or a null map is given. + final Map pickersEnabled; + + /// The color of the thumb on the slider that shows the selected picker. + /// + /// If not defined, defaults to Color(0xFFFFFFFF) (white) in light theme and + /// to Color(0xFF636366) in dark theme, which are defaults for the used + /// CupertinoSlidingSegmentedControl. + final Color selectedPickerTypeColor; + /// The TextStyle of the labels in segmented control swatch selector. /// /// Defaults to Theme.of(context).textTheme.caption, if not defined. @@ -406,13 +418,6 @@ class ColorPicker extends StatefulWidget { /// English default label for the HSV wheel picker that can select any color. static const String _selectWheelAnyLabel = 'Wheel'; - /// The color that shows the selected PickerType. - final Color selectedPickerTypeColor; - - /// The TextStyle of the prefix of the color code. - /// - /// Defaults to Theme.of(context).textTheme.bodyText2, if not defined. - final TextStyle colorCodePrefixStyle; @override _ColorPickerState createState() => _ColorPickerState(); @@ -753,6 +758,18 @@ class _ColorPickerState extends State { final TextStyle segmentTextStyle = widget.pickerTypeTextStyle ?? Theme.of(context).textTheme.caption; + // Define thumb color based on null fallback Cupertino defaults. + final Color _thumbColor = widget.selectedPickerTypeColor ?? + const CupertinoDynamicColor.withBrightness( + color: Color(0xFFFFFFFF), + darkColor: Color(0xFF636366), + ); + // Define thumb onColor based on thumb color brightness. + final Color _thumbOnColor = + ThemeData.estimateBrightnessForColor(_thumbColor) == Brightness.light + ? Colors.black + : Colors.white; + // Widget map for the sliding Cupertino segmented control that allows us to // switch between the pickers we enabled. // We set the labels to default values if none given. The constructor also @@ -767,7 +784,9 @@ class _ColorPickerState extends State { widget.pickerTypeLabels[ColorPickerType.both] ?? ColorPicker._selectBothLabel, textAlign: TextAlign.center, - style: segmentTextStyle, + style: activePicker == ColorPickerType.both + ? segmentTextStyle.copyWith(color: _thumbOnColor) + : segmentTextStyle, ), ), if (pickersEnabled[ColorPickerType.primary]) @@ -777,7 +796,9 @@ class _ColorPickerState extends State { widget.pickerTypeLabels[ColorPickerType.primary] ?? ColorPicker._selectPrimaryLabel, textAlign: TextAlign.center, - style: segmentTextStyle, + style: activePicker == ColorPickerType.primary + ? segmentTextStyle.copyWith(color: _thumbOnColor) + : segmentTextStyle, ), ), if (pickersEnabled[ColorPickerType.accent]) @@ -787,7 +808,9 @@ class _ColorPickerState extends State { widget.pickerTypeLabels[ColorPickerType.accent] ?? ColorPicker._selectAccentLabel, textAlign: TextAlign.center, - style: segmentTextStyle, + style: activePicker == ColorPickerType.accent + ? segmentTextStyle.copyWith(color: _thumbOnColor) + : segmentTextStyle, ), ), if (pickersEnabled[ColorPickerType.bw]) @@ -797,7 +820,9 @@ class _ColorPickerState extends State { widget.pickerTypeLabels[ColorPickerType.bw] ?? ColorPicker._selectBlackWhiteLabel, textAlign: TextAlign.center, - style: segmentTextStyle, + style: activePicker == ColorPickerType.bw + ? segmentTextStyle.copyWith(color: _thumbOnColor) + : segmentTextStyle, ), ), if (pickersEnabled[ColorPickerType.custom]) @@ -807,7 +832,9 @@ class _ColorPickerState extends State { widget.pickerTypeLabels[ColorPickerType.custom] ?? ColorPicker._selectCustomLabel, textAlign: TextAlign.center, - style: segmentTextStyle, + style: activePicker == ColorPickerType.custom + ? segmentTextStyle.copyWith(color: _thumbOnColor) + : segmentTextStyle, ), ), if (pickersEnabled[ColorPickerType.wheel]) @@ -817,7 +844,9 @@ class _ColorPickerState extends State { widget.pickerTypeLabels[ColorPickerType.wheel] ?? ColorPicker._selectWheelAnyLabel, textAlign: TextAlign.center, - style: segmentTextStyle, + style: activePicker == ColorPickerType.wheel + ? segmentTextStyle.copyWith(color: _thumbOnColor) + : segmentTextStyle, ), ), }; @@ -885,7 +914,11 @@ class _ColorPickerState extends State { padding: EdgeInsets.only(bottom: widget.columnSpacing), child: CupertinoSlidingSegmentedControl( children: pickerTypes, - thumbColor: widget.selectedPickerTypeColor, + thumbColor: widget.selectedPickerTypeColor ?? + const CupertinoDynamicColor.withBrightness( + color: Color(0xFFFFFFFF), + darkColor: Color(0xFF636366), + ), onValueChanged: (ColorPickerType value) { setState(() => activePicker = value); }, @@ -1370,8 +1403,8 @@ class _ColorCodeFieldState extends State<_ColorCodeField> { isDense: true, contentPadding: EdgeInsetsDirectional.only(start: fontSize), prefixText: '0xFF', - prefixStyle: widget.colorCodePrefixStyle ?? - Theme.of(context).textTheme.bodyText2, + // If null, defaults via SDK to `style` of TextField. + prefixStyle: widget.colorCodePrefixStyle, filled: true, fillColor: fieldBackground, border: OutlineInputBorder( diff --git a/pubspec.lock b/pubspec.lock index c38269a..7e68a16 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,28 +28,28 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0-nullsafety.1" cli_util: dependency: transitive description: @@ -63,14 +63,14 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0-nullsafety.1" collection: dependency: "direct dev" description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0-nullsafety.3" convert: dependency: transitive description: @@ -98,7 +98,14 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0-nullsafety.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.1" flutter: dependency: "direct main" description: flutter @@ -116,6 +123,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.2" http_multi_server: dependency: transitive description: @@ -130,13 +144,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.16.1" io: dependency: transitive description: name: io url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "0.3.5" js: dependency: transitive description: @@ -157,14 +178,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -178,21 +199,21 @@ packages: name: node_interop url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" node_io: dependency: transitive description: name: node_io url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.2.0" node_preamble: dependency: transitive description: name: node_preamble url: "https://pub.dartlang.org" source: hosted - version: "1.4.12" + version: "1.4.13" package_config: dependency: transitive description: @@ -206,7 +227,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0-nullsafety.1" pedantic: dependency: transitive description: @@ -241,21 +262,21 @@ packages: name: shelf_packages_handler url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" shelf_static: dependency: transitive description: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "0.2.8" + version: "0.2.9+2" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.3" + version: "0.2.4+1" sky_engine: dependency: transitive description: flutter @@ -281,70 +302,70 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0-nullsafety.1" test: dependency: "direct dev" description: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.0-nullsafety.12" + version: "1.16.0-nullsafety.5" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19-nullsafety.2" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.12-nullsafety.11" + version: "0.3.12-nullsafety.5" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0-nullsafety.3" vm_service: dependency: transitive description: @@ -365,14 +386,14 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol url: "https://pub.dartlang.org" source: hosted - version: "0.7.4" + version: "0.7.5" yaml: dependency: transitive description: @@ -381,4 +402,4 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.12.0-0.0 <=2.12.0-141.0.dev" + dart: ">=2.10.0 <2.11.0" diff --git a/pubspec.yaml b/pubspec.yaml index e7b255b..c25d838 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flex_color_picker description: A customizable Flutter primary, accent and custom color picker. Includes an optional HSV wheel color picker. -version: 1.1.3 +version: 1.1.4 homepage: https://github.com/rydmike/flex_color_picker environment: @@ -18,5 +18,5 @@ dev_dependencies: test: -#flutter: - #uses-material-design: true +flutter: + uses-material-design: true diff --git a/test/flex_color_indicator_test.dart b/test/flex_color_indicator_test.dart deleted file mode 100644 index 64b2761..0000000 --- a/test/flex_color_indicator_test.dart +++ /dev/null @@ -1,5 +0,0 @@ -// import 'package:flutter/material.dart'; -// import 'package:test/test.dart'; -// import 'package:flex_color_picker/flex_color_picker.dart'; - -void main() {} diff --git a/test/flex_color_tools_tests.dart b/test/flex_color_tools_test.dart similarity index 100% rename from test/flex_color_tools_tests.dart rename to test/flex_color_tools_test.dart