ezColorPicker function

Future ezColorPicker({
  1. required BuildContext context,
  2. required Color startColor,
  3. required void onColorChange(
    1. Color chosenColor
    ),
  4. required void apply(),
  5. required void cancel(),
})

Wrap a ColorPicker in an EzDialog

Implementation

Future<dynamic> ezColorPicker({
  required BuildContext context,
  required Color startColor,
  required void Function(Color chosenColor) onColorChange,
  required void Function() apply,
  required void Function() cancel,
}) {
  final double space = EzConfig.instance.prefs[buttonSpacingKey];

  return showPlatformDialog(
    context: context,
    builder: (context) => EzDialog(
      title: const EzSelectableText('Pick a color!'),
      contents: [
        // Color picker
        ColorPicker(
          pickerColor: startColor,
          onColorChanged: onColorChange,
          // ignore: deprecated_member_use
          labelTextStyle: Theme.of(context).dialogTheme.contentTextStyle,

          // Above is necessary for Cupertino
          // It is deprecated, but it points to an also deprecated solution
          // ...ain't broke...
        ),
        EzSpacer(space),

        // Apply/cancel
        EzYesNo(
          onConfirm: apply,
          confirmMsg: 'Apply',
          onDeny: cancel,
          denyMsg: 'Cancel',
        ),
      ],
      needsClose: false,
    ),
  );
}