<template>
<div class="root">
    <div class="app-bar theme-primary">
        <div class="app-bar-content">
            <span class="heading1">{{ translations.get("Title") }}</span>

            <toggle-button class="theme-primary-l1" v-model="showInfo" :reverseState="true">
                <span class="material-icons mdi-l">info</span>
            </toggle-button>
        </div>

        <div v-if="showInfo" class="paper" v-html="translations.get('Description')" />
    </div>

    <div class="paper content">
        <tab-bar :tabs="tabs" v-model="selectedTab" />
        <hr class="divider" />

        <div class="inner-content" v-if="selectedTab === 'direct'">
            <direct-input />
        </div>
        <div class="inner-content" v-if="selectedTab === 'file'">
            <file-input />
        </div>
    </div>
</div>

<SnackBar ref="snackBar" />
</template>

<style lang="scss">
html, body, #app {
    height: 100%;
}

.root {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-bar {
    display: flex;
    flex-direction: column;
    gap: 1em;

    background-color: var(--bg-color);
    color: var(--fg-color);
    box-shadow: 0px 0px 4px 3px #6d6d6d;

    padding: 1em;
    margin-bottom: 1em;
}

.app-bar-content {
    display: flex;
    align-items: center;
    gap: 1em;

    width: 100%;

    & :first-child {
        flex-grow: 1;
    }
}

.content {
    padding: 0;
    margin: 1em;
    flex-grow: 1;
}

.inner-content {
    padding: 1em;
}
</style>

<script>
import { mapState } from "vuex";
import DirectInput from "./components/DirectInput.vue"
import FileInput from "./components/FileInput.vue"
import SnackBar, { SnackController } from "./components/SnackBar.vue"
import TabBar from "./components/TabBar.vue"

export default {
    name: "App",
    components: {
        DirectInput,
        FileInput,
        SnackBar,
        TabBar
    },
    data() {
        return {
            selectedTab: "direct",
            showInfo: false
        }
    },
    computed: {
        tabs() {
            return [
                { label: this.translations.get("DirectInput"), value: "direct" },
                { label: this.translations.get("FileInput"), value: "file" }
            ]
        },
        ...mapState({
            translations: state => state.translations
        })
    },
    mounted() {
        SnackController.setBar(this.$refs.snackBar);
    }
}
</script>
