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

[v3] reanimated interpolateColor doesn't update theme color #393

Open
jeremybarbet opened this issue Dec 4, 2024 · 1 comment
Open

[v3] reanimated interpolateColor doesn't update theme color #393

jeremybarbet opened this issue Dec 4, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@jeremybarbet
Copy link
Contributor

jeremybarbet commented Dec 4, 2024

Description

When using interpolateColor from reanimated, with theme colors from unistyles, if the theme is changed, the color is not updating to the right theme's color.

unistyles.ts

// ...

const themes = {
  light: {
    background: "#ffffff",
    box: "#0000ff",
  },

  dark: {
    background: "#000000",
    box: "#ff0000",
  },
};

StyleSheet.configure({
  themes,
  settings: {
    adaptiveThemes: true,
  },
});

index.tsx

// ...

export default function Index() {
  const { box } = UnistylesRuntime.getTheme();
  const sv = useSharedValue(0);

  const boxStyle = useAnimatedStyle(() => ({
    backgroundColor: interpolateColor(sv.value, [0, 1], [box, "#00ff00"]),
  }));

  return (
    <View style={s.wrapper}>
      <Animated.View style={[s.box, boxStyle]} />
    </View>
  );
}

// ...
interpolate-color.mov

Steps to Reproduce

  1. git clone [email protected]:jeremybarbet/interpolate-color-reproducer.git
  2. yarn/yarn ios
  3. Go to system settings, switch from light to dark mode
  4. Box background doesn't update

Snack or Repository Link (Optional)

https://github.com/jeremybarbet/interpolate-color-reproducer

Unistyles Version

3.0.0-beta.1

React Native Version

0.76.3

Platforms

Android, iOS

Expo

Yes

@jeremybarbet jeremybarbet changed the title reanimated interpolateColor doesn't update theme color [v3] reanimated interpolateColor doesn't update theme color Dec 4, 2024
@jpudysz
Copy link
Owner

jpudysz commented Dec 4, 2024

Thanks for putting it down from Discord to Github.

Context:
Unistyles is not (yet) capable of using worklets or sharing up-to-date values on different threads. But it will be!

I will definitely bring it on before 1st stable release.

@jpudysz jpudysz added enhancement New feature or request good first issue Good for newcomers labels Dec 4, 2024
@jpudysz jpudysz modified the milestones: 3.0.0-rc.1, 3.0.0-beta.3 Dec 4, 2024
@jpudysz jpudysz modified the milestones: 3.0.0-beta.3, 3.0.0-beta.6 Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants