Skip to content

Instantly share code, notes, and snippets.

@PhantomKnight287
Last active July 17, 2023 06:19
Show Gist options
  • Select an option

  • Save PhantomKnight287/efb766100ab1310554f288eb569e18e1 to your computer and use it in GitHub Desktop.

Select an option

Save PhantomKnight287/efb766100ab1310554f288eb569e18e1 to your computer and use it in GitHub Desktop.
Custom Bottom Bar
const bottomBarActions = useMemo(() => {
const actions = [
{
name: "Home",
icon: (
<Entypo
name="home"
size={24}
color={theme === "Dark" ? "#fff" : "#000"}
/>
),
onPress: undefined,
},
{
name: "Library",
icon: (
<MaterialIcons
name="my-library-music"
size={24}
color={theme === "Dark" ? "#fff" : "#000"}
/>
),
onPress: () => push("/library"),
},
];
if (state.user.premium === false) {
actions.push({
name: "Premium",
icon: (
<FontAwesome
name="diamond"
size={24}
color={theme === "Dark" ? "#fff" : "#000"}
/>
),
onPress: () =>
push(Platform.OS === "ios" ? "/premium/ios" : "/premium/android"),
});
}
return actions;
}, [theme, state.user.id]);
<View
style={{
position: "absolute",
bottom: 0,
left: 0,
width: Dimensions.get("window").width,
alignItems: "center",
justifyContent: "space-around",
paddingBottom: 10,
flexDirection: "row",
paddingTop: 10,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 12,
},
shadowOpacity: 1,
shadowRadius: 16.0,
elevation: 24,
backgroundColor: theme === "Dark" ? "#282828" : "#efefef",
}}
>
{bottomBarActions.map((action) => (
<TouchableOpacity
key={action.name}
activeOpacity={0.5}
onPress={action.onPress}
style={{
alignItems: "center",
justifyContent: "center",
}}
>
{action.icon}
<Text>{action.name}</Text>
</TouchableOpacity>
))}
</View>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment