npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2024 โ€“ย Pkg Stats / Ryan Hefner

@react-native-oh-tpl/react-native-theme-switch-animation

v0.6.0-2.1.1

Published

A Plug & Play Animations for Switching (Dark/Light) Themes. ๐ŸŒ–

Downloads

148

Readme

react-native-theme-switch-animation

A Plug & Play Animations for Switching (Dark/Light) themes. ๐ŸŒ—

๐Ÿฆ„ Features

  • โœ… Supports multiple animation types.
  • โœ… Blazing fast - [60/120]fps
  • โœ… Plug and Play, doesn't matter what you use for switching themes
  • โœ… Can be used for different theme colors, not necessarily for dark/light
  • โœ… Supports turbo modules for new architecture

Installation

npm install react-native-theme-switch-animation

OR

yarn add react-native-theme-switch-animation

Link

(if you are using expo managed project, do a prebuild - npx expo prebuild)

npx pod-install

For React Native Versions 0.67 and Below

Usage

import switchTheme from 'react-native-theme-switch-animation';

export default function Example() {
  const [theme, setTheme] = React.useState('light');

  return (
    <Button
      title="Switch Theme"
      onPress={() => {

        switchTheme({
          switchThemeFunction: () => {
            setTheme(theme === 'light' ? 'dark' : 'light'); // your switch theme function
          },
          animationConfig: {
            type: 'fade',
            duration: 900,
          },
        });

      }}
    />
  );
}

Circular Example

switchTheme({
  switchThemeFunction: () => {
    setTheme(theme === 'light' ? 'dark' : 'light'); // your switch theme function
  },
  animationConfig: {
    type: 'circular',
    duration: 900,
    startingPoint: {
      cxRatio: 0.5,
      cyRatio: 0.5
    }
  },
});

switchTheme Function Props

| Name | Type | Description | | :------ | :------ | :------ | | switchThemeFunction | () => void | Adds the function you use in your app to switch themes, doesn't matter if you use redux/context/zustand/mobx or any other way | | animationConfig | AnimationConfig | Configuration for the animation -> type, duration, starting point (default is 'fade' with 500ms duration) |

animationConfig options

| Name | Type | Description | | :------ | :------ | :------ | | type | fade circular inverted-circular | Specifies animation type | | duration | number | Specifies duration in milliseconds | | startingPoint | StartingPointConfig | Configuration for the circular animation, where does the animation start in the screen |

startingPoint options

| Name | Type | Description | | :------ | :------ | :------ | | cx | number | Specifies starting x point for circular and inverted-circular animation (should not exceed your screen width) | | cy | number | Specifies starting y point for circular and inverted-circular animation (should not exceed your screen height) | | cxRatio | number | Specifies starting percentage of x point for circular and inverted-circular animation (should be number between -1 and 1) | | cyRatio | number | Specifies starting percentage of y point for circular and inverted-circular animation (should be number between -1 and 1) |

Start Circular Animation from/to speceific Button

If you would like the circular animation to start from/to a button/view on your ui automatically, you can do the following

import switchTheme from 'react-native-theme-switch-animation';

<TouchableOpacity
  onPress={(e) => {
    e.currentTarget.measure((x1, y1, width, height, px, py) => {
      switchTheme({
        switchThemeFunction: () => {
          setTheme(theme === 'light' ? 'dark' : 'light');
        },
        animationConfig: {
          type: 'circular',
          duration: 900,
          startingPoint: {
            cy: py + height / 2,
            cx: px + width / 2,
          }
        },
      });
    });
  }}
/>

Trouble shooting

[iOS] Artifact for some components with border

https://github.com/WadhahEssam/react-native-theme-switch-animation/assets/24798045/8ad14c41-8757-4c21-b7e7-bf47b23e7f8b

this can be solved by adding a borderRadius of any value more than 1.2 for the component

<View
  style={{
    borderWidth: 1,
    borderColor: theme === 'light' ? 'black' : 'white',
    borderRadius: 1.2, // -> Add This
    padding: 20,
    marginBottom: 20,
  }}
>
  <Text
    style={{
      color: theme === 'light' ? 'black' : 'white',
    }}
  >
    test
  </Text>
</View>

License

MIT