Display cooldown timer

I’m new to unity, so I want to display a cooldown timer every time the player shoots, I made an animation as the cooldown icon but I’m not sure how I’m supposed to make it work with the code, that it stops when the time is up and plays again when the player shoots

This is the cooldown:

public float firingRate = 1.8f;
public float nextFire = 0.0f;


void Update()
    {
        
        if (Input.GetButtonDown("Fire1") && Time.time > nextFireCannon)
        {
            
            Shoot();

            nextFire = Time.time + firingRate;

        }
        
        
    }

public float firingRate = 1.8f;
public float timer = 0.0f;

    private void Update()
    {
        if (Input.GetButtonDown("Fire1") && timer <= 0)
        {
            Shoot();
            timer = firingRate;
        }
        if (timer > 0)
        {
            timer -= time.deltaTime;
        }
    }