|
|
|
@ -32,9 +32,20 @@ const Navbar = ({ |
|
|
|
|
setBoxPosition, |
|
|
|
|
headerOptions, |
|
|
|
|
addToBookmark, |
|
|
|
|
deleteBookmark, |
|
|
|
|
userFavoriteList, |
|
|
|
|
}) => { |
|
|
|
|
const navigation = useNavigation(); |
|
|
|
|
const colorScheme = Appearance.getColorScheme(); |
|
|
|
|
|
|
|
|
|
const isActiveBookmark = React.useMemo(() => { |
|
|
|
|
return userFavoriteList.filter((object) => |
|
|
|
|
headerOptions.bookmarkItem?.productId |
|
|
|
|
? object.productId === headerOptions.bookmarkItem?.productId |
|
|
|
|
: object.contentId === headerOptions.bookmarkItem?.contentId |
|
|
|
|
).length; |
|
|
|
|
}, [headerOptions, userFavoriteList]); |
|
|
|
|
|
|
|
|
|
const Button = useCallback(({ icon, route }) => { |
|
|
|
|
return ( |
|
|
|
|
<TouchableOpacity |
|
|
|
@ -242,7 +253,32 @@ const Navbar = ({ |
|
|
|
|
/> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
{headerOptions?.bookmark && ( |
|
|
|
|
{headerOptions?.bookmark && |
|
|
|
|
(isActiveBookmark ? ( |
|
|
|
|
<Ionicons |
|
|
|
|
name="bookmark" |
|
|
|
|
style={tw("mr-2")} |
|
|
|
|
size={24} |
|
|
|
|
color={"#52796F"} |
|
|
|
|
onPress={() => |
|
|
|
|
headerOptions?.bookmarkItem?.contentId |
|
|
|
|
? deleteBookmark({ |
|
|
|
|
id: userFavoriteList.filter( |
|
|
|
|
(object) => |
|
|
|
|
object.contentId === |
|
|
|
|
headerOptions.bookmarkItem?.contentId |
|
|
|
|
)[0].id, |
|
|
|
|
}) |
|
|
|
|
: deleteBookmark({ |
|
|
|
|
id: userFavoriteList.filter( |
|
|
|
|
(object) => |
|
|
|
|
object.productId === |
|
|
|
|
headerOptions.bookmarkItem?.productId |
|
|
|
|
)[0].id, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
) : ( |
|
|
|
|
<Ionicons |
|
|
|
|
name="bookmark-outline" |
|
|
|
|
style={tw("mr-2")} |
|
|
|
@ -258,7 +294,7 @@ const Navbar = ({ |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
))} |
|
|
|
|
{headerOptions?.menu && ( |
|
|
|
|
<Entypo name="dots-three-vertical" size={24} color="#52796F" /> |
|
|
|
|
)} |
|
|
|
@ -267,10 +303,13 @@ const Navbar = ({ |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({}); |
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
userFavoriteList: state.userFavorite.list, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
addToBookmark: userFavorite.add, |
|
|
|
|
deleteBookmark: userFavorite.del, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Navbar); |
|
|
|
|