Skip to content

Android - Navigation back loses styles applyied programmatically #2206

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

Open
pianetarosso opened this issue Jul 31, 2020 · 1 comment
Open

Comments

@pianetarosso
Copy link

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 8.2.0
  • Cross-platform modules: 6.6.0-next-2020-05-08-112112-01
  • Android Runtime: 6.5.3
  • iOS Runtime: 6.5.2
  • Plugin(s): nativescript-ng-shadow ^2.1.0
  • NativeScript-Angular: ~8.21.0
  • Angular:

Describe the bug
We have a directive to apply some styles programmatically (ex. backgroundColor, backgroundImage, ...) and shadow (using the plugin above) based on a JSON downloaded from a server. On Android to get the styles working we have to use a setTimeout with a non-empty time value (ex. setTimeout() => ... , 2) ).
The problem is only on Android when using the back button. Returning to a previous created page made all set styles lost. To avoid this I listen to router changes and, inside a setTimeout, I change the backgroundColor of the HTMLElement first to '' " then to its previous value. This seem to trigger the redraw of the page.

This solution causes flickering and, if the background is a remote image, the re-download of it, so it's far from perfect.

To Reproduce
On Android, apply a directive to a StackLayout component, setting the backgroundColor style of the HTMLElement. Then navigate to a page and return back.

Expected behavior
The programmatic styles are not lost on back, and backgroundImages are not reloaded like on iOS

Sample project
Currently I don't have time to set one up, I'll try in the weekend

Additional context

@pianetarosso pianetarosso changed the title Navigation back loses styles applyied programmatically Android - Navigation back loses styles applyied programmatically Jul 31, 2020
@mohammadrafigh
Copy link

In addition the back stack is completely broken in my case. when I navigate to a page then I press back I see wrong styles, then when I press back the app again navigates to the page I was in and when I press back again I see the first page with correct styles.

I'm using "@nativescript/angular": "10.0.0" and "@nativescript/core": "rc"

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

2 participants