<script lang="ts">
    import {EventsOn} from '../wailsjs/runtime/runtime'

    var stat: string = ""
    var completed: number = 0
    var total: number = 0
    var downloading: boolean = false
    
    EventsOn("status", (status) => {
        stat = status;
    })

    EventsOn("download", (Completed, Total) => {
        completed = (Completed / (1024*1024)).toFixed(2)
        total = (Total / (1024*1024)).toFixed(2)
        downloading = true
    })

    EventsOn("download_complete", () => {
        downloading = false
    })
</script>

<main>
    <p id="status">{stat}</p>
    {#if downloading}
        <p id="download_status">{completed}MB / {total}MB</p>
    {/if}
</main>
