bthurlow / nativescript-imagecropper

A nativescript image cropping plugin.
Other
49 stars 35 forks source link

Customize activity colors #5

Closed mounirka closed 7 years ago

mounirka commented 7 years ago

Hi, the plugin is working perfectly, i want to ask you if you can add the possibility to customize the color of the view on android, give that UCrop now supports the customization.

Thank you

mounirka commented 7 years ago

For anyone who's asking how to customize the view i'll tell you how i did (android only). in the file imagecropper.android.js above this line: if (_options && _options.width && _options.height) { //line number 78

Just put this code:

var options = new com.yalantis.ucrop.UCrop.Options();
options.setStatusBarColor(android.graphics.Color.parseColor("#1565c0"));
options.setToolbarColor(android.graphics.Color.parseColor("#a2b6f3"));

You can find all the available options here

Then you have to add this:

if (_options && _options.width && _options.height) {
                        var gcd = _this._gcd(_options.width, _options.height);
                        UCrop.of(sourcePath, destinationPath)
                            .withOptions(options) //Add this line for options
                            .withAspectRatio(_options.width / gcd, _options.height / gcd)
                            .withMaxResultSize(_options.width, _options.height)
                            .start(_this._getContext());
                    }
                    else {
                        UCrop.of(sourcePath, destinationPath)
                            .withOptions(options) //Add this line for options
                            .start(_this._getContext());
                    }