Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ColorPickerDialog is not supporting an initialColor and a FlagView #104

Open
juliswer opened this issue Aug 17, 2023 · 3 comments
Open

Comments

@juliswer
Copy link

Overview

  • Library ColorPickerView@2.2.4

Bug:
As in the ColorPickerView component, I'd expect to have the same options on the ColorPickerDialog. What do I mean with the same options? Im talking about the method .setInitialColor() and the ability to set a flagView as well.

Do you have some solution to set an initial color in a ColorPickerDialog?

@skydoves
Copy link
Owner

skydoves commented Oct 2, 2023

Hey @juliswer, have you ever tried the way below?

ColorPickerView colorPickerView = builder.getColorPickerView();
colorPickerView.setFlagView(new CustomFlag(this, R.layout.layout_flag)); // sets a custom flagView
colorPickerView. setInitialColor(..)

@juliswer
Copy link
Author

juliswer commented Oct 4, 2023

hey @skydoves. Yes, i did.
The issue is that the code you provided me with is referred to a ColorPickerView, but I'm using a ColorPickerDialog.

This ColorPickerDIalog is not allowing the same methods (setInitialColor & setFlagView) than the ColorPickerView.

this is my implementation:

val colorPickerDialog = ColorPickerDialog.Builder(context, R.style.ColorPickerDialog)
            .setTitle("Pick a Color")
            .setPreferenceName("ColorPickerDialog")
            .setPositiveButton("Apply",
                ColorEnvelopeListener { envelope, _ ->
                    // beauty color
                })
            .setNegativeButton(
                "Cancel"
            ) { dialogInterface, _ -> dialogInterface.dismiss() }
            .setNeutralButton("Delete color") { _, _ -> deleteColor(colorPosition) }
            .attachAlphaSlideBar(false)
            .attachBrightnessSlideBar(true)
            .setBottomSpace(12)
            .show()

@floyder
Copy link

floyder commented Jun 27, 2024

@juliswer You can extend the class and use something like this

public Builder setDefaultColor(int code) {
    if (getColorPickerView() != null) {
        getColorPickerView().setInitialColor(code);
    }
    return this;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants