akveo / kittenTricks

React Native starter kit with over 40 screens and modern Light and Dark theme for creating stunning cross-platform mobile applications.
https://akveo.github.io/react-native-ui-kitten/
MIT License
7.17k stars 986 forks source link

Get UI Theme variables via hooks (instead of withStyles()) #252

Closed dandevs closed 4 years ago

dandevs commented 4 years ago

Issue type

I'm submitting a ... (check one with "x")

Issue description

Request in title, I believe it'd be much simpler to use a hook over the current withStyles() method

Related code:

const Component = () => {
  const theme = useKittenTheme();
  const primary = theme["color-success-200"];

  // Or something like
  const styles = useKittenTheme(theme => ({
    layout: {
      backgroundColor: theme["color-success-200"]
    }
  });

  <Layout style={styles.layout}/>;
  return <Layout style={{backgroundColor: primary}>...</Layout>;
}

Other information:

OS, device, application version

UI Kitten 4.3.1
dandevs commented 4 years ago

Sorry, wrong repo 🔢 👎 🥇