Skip to content

ohmae/color-chooser

Repository files navigation

color chooser

license GitHub release GitHub issues GitHub closed issues Maven Central

ScreenShots

How to use

Jetpack Compose

latest version: Maven Central

dependencies {
    implementation 'net.mm2d.color-chooser:color-chooser-compose:<version>'
}
var show by rememberSaveable { mutableStateOf(false) }

...

if (!show) return
ColorChooserDialog(
    initialColor = Color(color),
    onDismissRequest = {
        show = false
        // dismiss the dialog 
    },
    onChooseColor = { color ->
        // handle chosen color
    },
)

View-base app

latest version: Maven Central

dependencies {
    implementation 'net.mm2d.color-chooser:color-chooser:<version>'
}

Register the listener to receive the result. Write the following process in onViewCreated of Fragment or onCreate of Activity.

ColorChooserDialog.registerListener(REQUEST_KEY, this) {
    // it is selected color as @ColorInt
}

To show dialog. On FragmentActivity or Fragment

ColorChooserDialog.show(
    this,         // Fragment or FragmentActivity
    REQUEST_KEY,  // request key for receive result
    initialColor, // initial color, optional, default #FFFFFF
    true,         // need for alpha, optional, default false
    TAB_RGB       // initial tab, TAB_PALETTE/TAB_HSV/TAB_RGB, optional, default  TAB_PALETTE
)

The style of implementing a callback interface in Activity and Fragment has been deprecated.

Please see Sample code for detail.

API Document

Dependent OSS

Author

大前 良介 (OHMAE Ryosuke) http://www.mm2d.net/

License

MIT License