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

Skeleton displays in device's selected theme for fraction of second #392

Open
4 of 8 tasks
KrishnaKaira opened this issue May 11, 2021 · 6 comments
Open
4 of 8 tasks

Comments

@KrishnaKaira
Copy link

KrishnaKaira commented May 11, 2021

Description

We have custom implementation of dark theme, and user can select theme from inside the application setting. Now, when user either uses system theme, or same theme as device, skeleton color shows smoothly. But lets say if user selects 'Dark' theme in application setting, and user's device is in 'Light' mode, the skeleton displays in light mode for a fraction of second before it switches to dark color, and vice versa.
Seems like some how skeleton is picking device's theme before it switches to application's theme. We are overriding the theme using
overrideUserInterfaceStyle = style //.dark, .light OR .unspecified
in viewDidLoad() before adding skeleton to the view.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

We are overriding the UIViewController's property inside viewDidLoad based on user's preference from inside app setting:
overrideUserInterfaceStyle = style //.dark, .light OR .unspecified
Now, added skeleton view as subview and setting the color for skeleton as:
view.showAnimatedGradientSkeleton(usingGradient: SkeletonGradient(baseColor: UIColor.appColor(.gray6)))

UIColor.appColor(.gray6) -> returns adaptive color equals to UIColor.systemGray6

We have tried to set fix color also, but still it shows in device's theme first before setting the color properly.

SkeletonView Environment:

SkeletonView version: 1.8.6
Xcode version: 12.4
Swift version: 4.x

Steps to reproduce:

Please replace this with the steps to reproduce the behavior.

  1. Add this to viewDidLoad: overrideUserInterfaceStyle = .dark
  2. Now add skeleton view as subview on viewController's view
  3. keep your device in light mode (disable dark mode)
  4. show Skeleton using view.showAnimatedGradientSkeleton(usingGradient: SkeletonGradient(baseColor: UIColor.systemGray6))

Expected result:

Skeletons color should always show in provided color.

Actual result:

Skeleton color was displaying in device's theme for fraction of second before displaying the accurate color.

Attachments:

SkeletonView_bug.mp4
@KrishnaKaira
Copy link
Author

@Juanpe Did you get any chance to look into it? I would like to drag your attention here.
Is there any way that we could override user interface style for skeleton view? It is somehow picking system's selected style for fraction of second.

@Juanpe
Copy link
Owner

Juanpe commented Jun 9, 2021

Hi @KrishnaKaira,

TBH, I could check this issue yet. I'm going to try to check it asap. :)

@diogot
Copy link
Contributor

diogot commented Oct 13, 2021

I'm observing similar behaviour.
I override overrideUserInterfaceStyle for all app windows and the skeletons always follow the system style instead of the window one (that's inherited by it's subviews).
I did some investigation and I think that happens because the layers are created unattached from the view/layer hierarchy (SkeletonType.layer), so when the colors are set CALayer+Tint.swift:20 the layer will infer the style from the system because it can't get it from the parent layer.

But I don't how to fix this.

@Juanpe Juanpe added the triaged label Jan 11, 2022
@colincavil112
Copy link

I am also experiencing this issue.

@chetankasundra
Copy link

I am also experiencing this issue. Let me know if this issue is fixed now.

@rahulVermaSimpplr
Copy link

@Juanpe did you get any chance to look into this issue, actually now in latest release it's not just flickering but it picks the system theme only and ignore apps theme.

Simulator Screenshot - iPhone 15 Pro - 2024-03-05 at 12 56 42
Here in attached screenshot, my app's theme is dark and device theme is light, so the skeleton automatically picks the light colour which is for light app theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants