Skip to content

Commit

Permalink
Add support for shadow and tint colors to the dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
rydmike committed Mar 3, 2024
1 parent 6167765 commit 3bed4ac
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Requires min Flutter 3.16.0 and Dart 3.0.0.
- Added `dialogActionOnlyOkButton` to `ColorPickerActionButtons`. Defaults to false. If set to true and `dialogActionButtons` is true, only the OK button will be shown.
- Added support for a second custom color palette to the picker. In addition to `ColorPickerType.custom` there is now also a `ColorPickerType.customSecondary` picker selector. It gets its values from `ColorPicker.customSecondaryColorSwatchesAndNames`.
- Added support for transparent colors for both custom color palette pickers. They can now have opacity in the picker in their custom color values. This also works if the opacity and slider in `ColorPicker.enableOpacity` is not enabled. Nothing new is needed to use this feature. It works automatically when custom color palettes are used that have partially transparent colors in them.
- Added `shadowColor` and `surfaceTintColor` to the dialog properties to enable control of the shadow color and surface tint color of the color picker dialog.
- The color utilities `ColorTools.createPrimarySwatch` and `ColorTools.createAccentSwatch` now create color swatches with alpha channel value kept at its input values for all created swatch indexes. Previously they set alpha to `#FF`, even if the value might have been something else. Creating palettes with very low alpha in the source color will not produce pretty palettes, but it is now possible to create them.
- The Color picker received two new layout properties. Previously all vertical spacings between the column elements in the picker were controlled by the `ColorPicker` property `columnSpacing`. For two key elements, you can now override this spacing.
- Use `toolbarSpacing` to adjust the vertical spacing below the top toolbar header and its action buttons. The purpose is to enable using zero space or close to it, so the top toolbar and action buttons can be closer to the picker selection control than the rest of the spacing in the picker uses.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.4.0"
version: "3.3.1"
flex_seed_scheme:
dependency: transitive
description:
Expand Down
10 changes: 10 additions & 0 deletions lib/src/color_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,14 @@ class ColorPicker extends StatefulWidget {
/// Defaults to 0.
final double? elevation,

/// The color used to paint a drop shadow under the dialog's Material,
/// which reflects the dialog's elevation.
final Color? shadowColor,

/// The color used as a surface tint overlay on the dialog's background
/// color, which reflects the dialog's elevation.
final Color? surfaceTintColor,

/// The semantic label of the dialog used by accessibility frameworks to
/// announce screen transitions when the dialog is opened and closed.
///
Expand Down Expand Up @@ -1193,6 +1201,8 @@ class ColorPicker extends StatefulWidget {
buttonPadding: buttonPadding,
backgroundColor: backgroundColor,
elevation: elevation,
shadowColor: shadowColor,
surfaceTintColor: surfaceTintColor,
semanticLabel: semanticLabel,
insetPadding: insetPadding,
clipBehavior: clipBehavior,
Expand Down
10 changes: 10 additions & 0 deletions lib/src/show_color_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,14 @@ Future<Color> showColorPickerDialog(
/// Defaults to 0.
final double? dialogElevation,

/// The color used to paint a drop shadow under the dialog's Material,
/// which reflects the dialog's elevation.
final Color? shadowColor,

/// The color used as a surface tint overlay on the dialog's background
/// color, which reflects the dialog's elevation.
final Color? surfaceTintColor,

/// The semantic label of the dialog used by accessibility frameworks to
/// announce screen transitions when the dialog is opened and closed.
///
Expand Down Expand Up @@ -741,6 +749,8 @@ Future<Color> showColorPickerDialog(
buttonPadding: buttonPadding,
backgroundColor: backgroundColor,
elevation: dialogElevation,
shadowColor: shadowColor,
surfaceTintColor: surfaceTintColor,
semanticLabel: semanticLabel,
insetPadding: insetPadding,
clipBehavior: clipBehavior,
Expand Down

0 comments on commit 3bed4ac

Please sign in to comment.