I tried flipping gravity but i cant jump

So i made it that when i press space the player flips unto the top platform but when he flip and starts floating to the top platform he cant jump anymore

Here’s the code
public class SwitchGravity : MonoBehaviour
{

private Rigidbody2D _body;
private Player player;

private bool top;

void Start()
{
player = GetComponent();
_body = GetComponent();
}

void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
_body.gravityScale *= -1;
Rotation();
}

}

void Rotation()
{
if(top == false)
{
transform.eulerAngles = new Vector3(0, 0, 180f);
}
else
{
transform.eulerAngles = Vector3.zero;
}

top = !top;
}
}

So i made it that when i press space the player flips and floats unto the top platform but when he flips and starts floating to the top platform he cant jump anymore and when he lands on the top platform he cant jump either
(its not letting me update the previous post)