Skip to content

Commit

Permalink
[#69] add toggle for the odd showDialog component
Browse files Browse the repository at this point in the history
  • Loading branch information
mchome committed Dec 11, 2021
1 parent a34ad4b commit 993da66
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.17.0"
13 changes: 9 additions & 4 deletions lib/src/block_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ class BlockPicker extends StatefulWidget {
required this.pickerColor,
required this.onColorChanged,
this.availableColors = _defaultColors,
this.useInShowDialog = true,
this.layoutBuilder = _defaultLayoutBuilder,
this.itemBuilder = _defaultItemBuilder,
}) : super(key: key);

final Color pickerColor;
final ValueChanged<Color> onColorChanged;
final List<Color> availableColors;
final bool useInShowDialog;
final PickerLayoutBuilder layoutBuilder;
final PickerItemBuilder itemBuilder;

Expand All @@ -118,9 +120,10 @@ class _BlockPickerState extends State<BlockPicker> {
return widget.layoutBuilder(
context,
widget.availableColors,
(Color color, [bool? _, Function? __]) => widget.itemBuilder(
(Color color) => widget.itemBuilder(
color,
_currentColor.value == color.value,
(_currentColor.value == color.value) &&
(widget.useInShowDialog ? true : widget.pickerColor.value == color.value),
() => changeColor(color),
),
);
Expand All @@ -134,13 +137,15 @@ class MultipleChoiceBlockPicker extends StatefulWidget {
required this.pickerColors,
required this.onColorsChanged,
this.availableColors = _defaultColors,
this.useInShowDialog = true,
this.layoutBuilder = _defaultLayoutBuilder,
this.itemBuilder = _defaultItemBuilder,
}) : super(key: key);

final List<Color> pickerColors;
final ValueChanged<List<Color>> onColorsChanged;
final List<Color> availableColors;
final bool useInShowDialog;
final PickerLayoutBuilder layoutBuilder;
final PickerItemBuilder itemBuilder;

Expand All @@ -167,9 +172,9 @@ class _MultipleChoiceBlockPickerState extends State<MultipleChoiceBlockPicker> {
return widget.layoutBuilder(
context,
widget.availableColors,
(Color color, [bool? _, Function? __]) => widget.itemBuilder(
(Color color) => widget.itemBuilder(
color,
_currentColors.contains(color),
_currentColors.contains(color) && (widget.useInShowDialog ? true : widget.pickerColors.contains(color)),
() => toggleColor(color),
),
);
Expand Down
4 changes: 3 additions & 1 deletion lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import 'package:flutter/painting.dart';
/// the background color, and optional bias.
///
/// Reference:
///
/// Old: https://www.w3.org/TR/WCAG20-TECHS/G18.html
/// new: https://github.com/mchome/flutter_statusbarcolor/issues/40
///
/// New: https://github.com/mchome/flutter_statusbarcolor/issues/40
bool useWhiteForeground(Color backgroundColor, {double bias = 0.0}) {
// Old:
// return 1.05 / (color.computeLuminance() + 0.05) > 4.5;
Expand Down

0 comments on commit 993da66

Please sign in to comment.