-
Notifications
You must be signed in to change notification settings - Fork 38
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
Why set background on android? #17
Comments
Nevermind, I figured it out. I'm trying to find a way to adapt this plugin in a way that we no longer override the CSS. One way is using the nativeElement property borderRadius, but we can't set specific values for topleft and topright, for example. We also lose the image, if there is any. Edit: Ok, got this working:
We use a Layer to add the shape to the background while keeping it unaltered. With a RoundRectShape we can then get the CSS border from nativescript to create the correct shape (copied the code I'm using for the ripple plugin I'll be publishing next week):
I can confirm this worked for me on Android. I used a background-image and border-radius and the shadow was the right size and shape:
Do you want me to submit a PR? |
@edusperoni , feel free to make a PR to my fork of this project. https://github.com/TheOriginalJosh/nativescript-ngx-shadow |
@TheOriginalJosh have you disabled issues on your fork? I was going to open an issue there for discussion but it seems it'll have to be done here I'm putting some effort on adding this to the plugin without affecting the current functionality. One problem that arose is that changing the background via CSS, for example, completely removes the custom background I set. I have this issue with my own plugin as well (https://github.com/edusperoni/nativescript-ng-ripple). Unfortunately, there is no way to listen to background changes in {N}, so I've experimentally monkey patched Nativescript's View method This solves the issue, but is very ugly, and may lead to performance problems with animations that change the background. I'm thinking about a similar solution for the nativescript-ng-shadow. What are your thoughts? NOTE: if you try my plugin, ensure to import it's module AFTER the NgShadow, otherwise the shadow overrides the ripple |
@edusperoni thanks for the heads up I did not notice I had issues disabled. As for the monkeypatch, I'm not sure, I do think if it was added it could be something turned on when importing the module. That way if performance problems arise, it could be turned off quickly to see if it was possibly the cause. Just a thouht. |
@TheOriginalJosh yeah, it actually patches the object method, not the class itself, so it's patched when the view is loaded and unpatched when it's unloaded. Now that I think about it, if we animate the current background color property, we'd have almost the same performance as the monkey patch. If performance is really an issue, whoever uses the plugin can just add another layout inside the shadow layout and animate it, but I think it's better that we have a plugin that doesn't stop working on a simple background change. I'll make the PR tomorrow. |
This is more of a question about the implementation. On Android, the background is set to a GradientDrawable with color and corner (https://github.com/Especializa/nativescript-ng-shadow/blob/master/src/common/shadow.ts#L52). Why is this done?
It seems most of the shadow code is in the elevation bit, and this is serving only to remove the CSS background. Am I missing something?
The text was updated successfully, but these errors were encountered: