jrshikoku/lib/initIcon.tsx
harukin-expo-dev-env 9ac41bc907 initIcon→tsx
2024-08-20 03:49:36 +00:00

21 lines
631 B
TypeScript

import React from "react";
import { Ionicons, AntDesign } from "@expo/vector-icons";
type name = keyof typeof Ionicons.glyphMap & keyof typeof AntDesign.glyphMap;
type type = "Ionicons" | "AntDesign";
export const initIcon = (name: name, type:type) => {
switch (type) {
case "Ionicons":
return ({ focused, color, size }) => (
<Ionicons name={name} size={32} color={focused ? "#0099CC" : "black"} />
);
case "AntDesign":
return ({ focused, color, size }) => (
<AntDesign
name={name}
size={32}
color={focused ? "#0099CC" : "black"}
/>
);
}
};