vector-icons icon indicating copy to clipboard operation
vector-icons copied to clipboard

Implement getImageSource

Open jakex7 opened this issue 8 months ago • 3 comments

Why

Fixes #26 Since expo-font now supports rendering glyphs to images using Font.renderToImageAsync (https://github.com/expo/expo/pull/36185), we can implement support for getImageSource with the same interface as react-native-vector-icons https://github.com/oblador/react-native-vector-icons#static-methods

How

Implemented static method getImageSource on Icon component.

Test Plan

import { FontAwesome } from "@expo/vector-icons";
import { useState } from "react";
import { Button, Image, PlatformColor, StyleSheet, View } from "react-native";

export default function App() {
  const [img, setImg] = useState("");
  return (
    <View style={styles.container}>
      <FontAwesome name="home" size={24} color={PlatformColor("systemRed")} />
      <Button
        title="Click Me"
        onPress={async () => {
          const image = await FontAwesome.getImageSource(
            "home",
            200,
            PlatformColor("systemBlue"),
          ).catch((e) => console.warn(e));
          console.log(image);
          if (image) setImg(image);
        }}
      />

      {img && (
        <Image source={{ uri: img }} style={{ width: 200, height: 200 }} />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Results: LOG file:///Users/jakubgrzywacz/Library/Developer/CoreSimulator/Devices/68321A76-B7B0-427D-A714-E44443E8FD01/data/Containers/Data/Application/5DC40FC3-7740-42A0-BE98-00356838C77B/tmp/F96326C7-B585-4EDB-995B-5B2CEFDFC8EC.png image

jakex7 avatar Apr 23 '25 13:04 jakex7

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
vector-icons ✅ Ready (Inspect) Visit Preview Apr 23, 2025 1:04pm

vercel[bot] avatar Apr 23 '25 13:04 vercel[bot]

when is this planned to be released?

Ladvace avatar May 03 '25 18:05 Ladvace

@lukmccall this is already merged, can we just get a new release out? This is blocking us from using the amazing https://github.com/callstackincubator/react-native-bottom-tabs library.

thespacemanatee avatar Jun 15 '25 05:06 thespacemanatee