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

how to change seperator line color #45

Open
mostafaolyai opened this issue May 8, 2018 · 17 comments
Open

how to change seperator line color #45

mostafaolyai opened this issue May 8, 2018 · 17 comments

Comments

@mostafaolyai
Copy link

how to change seperator line color?
tnx

@ZeinabDanaee
Copy link

how to change seperator line color?

@mostafaolyai
Copy link
Author

yes
default color is white

@jollimies
Copy link

jollimies commented May 16, 2018

I think you can change the color only by editing directly the node_package which is anti pattern.

try editing your
ReactWheelCurvedPicker.java

...
    @Override
    protected void drawForeground(Canvas canvas) {
        super.drawForeground(canvas);

        Paint paint = new Paint();
        paint.setColor(Color.WHITE); // try changing this to Color.BLACK
        int colorFrom = 0x00FFFFFF;//Color.BLACK;
        int colorTo = Color.WHITE;
        LinearGradient linearGradientShader = new LinearGradient(rectCurItem.left, rectCurItem.top, rectCurItem.right/2, rectCurItem.top, colorFrom, colorTo, Shader.TileMode.MIRROR);
        paint.setShader(linearGradientShader);
        canvas.drawLine(rectCurItem.left, rectCurItem.top, rectCurItem.right, rectCurItem.top, paint);
        canvas.drawLine(rectCurItem.left, rectCurItem.bottom, rectCurItem.right, rectCurItem.bottom, paint);
    }
...

I solved this issue by rendering a view with absolute position and styled borders top of the picker... which isn't good solution either.

@mostafaolyai
Copy link
Author

ill try this dude, tnx

@mostafaolyai
Copy link
Author

@jollimies one question
when you edit this , line sep show correctly in ios & android?

@Foveluy
Copy link

Foveluy commented Sep 1, 2018

 @Override
    protected void drawForeground(Canvas canvas) {
        super.drawForeground(canvas);

        Paint paint = new Paint();
        paint.setColor(Color.BLACK); // change this 
        int colorFrom = 0x00FFFFFF;//Color.BLACK;
        int colorTo = Color.BLACK;  // change this 
        LinearGradient linearGradientShader = new LinearGradient(rectCurItem.left, rectCurItem.top, rectCurItem.right/2, rectCurItem.top, colorFrom, colorTo, Shader.TileMode.MIRROR);
        paint.setShader(linearGradientShader);
        canvas.drawLine(rectCurItem.left, rectCurItem.top, rectCurItem.right, rectCurItem.top, paint);
        canvas.drawLine(rectCurItem.left, rectCurItem.bottom, rectCurItem.right, rectCurItem.bottom, paint);
    }

for someone wants to change their border, you have to edit
paint.setColor(Color.BLACK); // change this and int colorTo = Color.BLACK; // change this.

why?

 LinearGradient linearGradientShader = new LinearGradient(rectCurItem.left, rectCurItem.top, rectCurItem.right/2, rectCurItem.top, colorFrom, colorTo, Shader.TileMode.MIRROR);
        paint.setShader(linearGradientShader);

here is the key

@KingAmo
Copy link

KingAmo commented Sep 17, 2018

能不能加个props修改分隔线的颜色呢?作者不维护这个项目了吗? @lesliesam

@mikeyamato
Copy link

Has anyone been successful in updating the border colors by going into the Java file? I've tweaked it using different standard colors but it doesn't have any visible effect.

I'm also trying to update the itemSpace but that's a whole different can of worms.

@Foveluy
Copy link

Foveluy commented Dec 22, 2018

@mikeyamato check out the code i posted above

@mikeyamato
Copy link

@mikeyamato check out the code i posted above

@Foveluy I did but without success. That's why I was wondering if anyone was able to change it.

I changed the color from white to red but what I'm seeing (iOS) is still unchanged.

screen shot 2018-12-22 at 5 38 47 pm

screen shot 2018-12-22 at 5 39 15 pm

@mikeyamato
Copy link

@Foveluy out of curiosity were you able to update the line color in iOS or are you working with Android only?

@Foveluy
Copy link

Foveluy commented Dec 27, 2018

@mikeyamato very interesting. can you post all drawForeground function out?

i update this line color in Android for sure.

@mikeyamato
Copy link

@Foveluy I wonder if this is a iOS vs Android limitation.

As requested...

protected void drawForeground(Canvas canvas) {
    super.drawForeground(canvas);

    Paint paint = new Paint();
    paint.setColor(Color.RED);  // originally 'Color.WHITE'
    int colorFrom = 0x00FFFFFF;//Color.BLACK;
    int colorTo = Color.RED;  // originally 'Color.WHITE'
    LinearGradient linearGradientShader = new LinearGradient(rectCurItem.left, rectCurItem.top, rectCurItem.right/2, rectCurItem.top, colorFrom, colorTo, Shader.TileMode.MIRROR);
    paint.setShader(linearGradientShader);
    canvas.drawLine(rectCurItem.left, rectCurItem.top, rectCurItem.right, rectCurItem.top, paint);
    canvas.drawLine(rectCurItem.left, rectCurItem.bottom, rectCurItem.right, rectCurItem.bottom, paint);
}

@mikeyamato
Copy link

I took a look at PR #8 and even changed my code to how it was done but was unsuccessful 🙁

@mikeyamato
Copy link

Okay, so the following solution is a temporary solution for iOS that worked for me. You'll need to go into the RCTPicker.m file through the following path: */node_modules/react-native/React/Views/RCTPicker.m

Right below the line label.font = _font; place the following:

pickerView.subviews[1].backgroundColor = [UIColor darkGrayColor];
pickerView.subviews[2].backgroundColor = [UIColor darkGrayColor];

You'll need to stop your current Metro Bundler process then re-start react-native run-ios.

Although I'm using darkGray you can find additional color options here.

Just remember, since this is saved to your node_modules anytime you re-install you'll need to repeat this process.

screen shot 2019-01-05 at 10 27 51 am

@AarshOza
Copy link

Has anyone been successful in updating the separator color ??? If so please give the solution

@m3rlin94
Copy link

Has anyone been successful in updating the separator color ??? If so please give the solution

I have forked and exposed the line color, and gradient start, gradient end (if gradient is necessary. otherwise solid color can be set from line color prop) as react props. check this out.

https://github.com/m3rlin94/react-native-wheel-picker

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

8 participants