<template>
  <f7-page name="home">
    <!-- Top Navbar -->
    <f7-navbar>
      <f7-nav-left>
        <f7-link icon-ios="f7:bars" icon-md="f7:bars" panel-open="left"></f7-link>
      </f7-nav-left>
      <f7-nav-title sliding>A.L.V.I.N.N.</f7-nav-title>
      <f7-nav-right>
        <f7-link v-if="!isCordova" :icon-only="true" tooltip="Fullscreen" :icon-f7="isFullscreen ? 'viewfinder_circle_fill' : 'viewfinder'" @click="toggleFullscreen"></f7-link>
        <f7-link :icon-only="true" tooltip="ALVINN help" icon-f7="question_circle_fill" href="/help/"></f7-link>
      </f7-nav-right>
    </f7-navbar>
    <!-- Page content-->
    <div style="display: grid; grid-template-columns: 100%; grid-template-rows: min-content min-content min-content 1fr; align-content: stretch; gap: 15px; min-height: 0px; max-height: calc(100vh - (var(--f7-navbar-height) + var(--f7-safe-area-top))); height: calc(100vh - (var(--f7-navbar-height) + var(--f7-safe-area-top)));">
      <h2 style="text-align: center; padding-left: 30px; padding-right: 30px;">Anatomy Lab Visual Identification Neural Network</h2>
      <h4 style="text-align: center; margin: 0;">
        Veterinary Anatomy Edition
        <f7-link @click="alphaWarn">
          ALPHA RELEASE
          <f7-badge style="margin-left: 3px;" v-if="!alphaCheck" color="red">!</f7-badge>
        </f7-link>
      </h4>
      <p style="text-align: center; margin: 0;">Select a region to begin.</p>
      <div class="region-grid">
        <f7-button :class="`region-button thorax${isAgreed && getRegions.includes('thorax') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('thorax') && '/detect/thorax/'">
          <RegionIcon class="region-image" :region="0" :iconSet="getIconSet" />
        </f7-button>
        <f7-button :class="`region-button abdomen${isAgreed && getRegions.includes('abdomen') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('abdomen') && '/detect/abdomen/'">
          <RegionIcon class="region-image" :region="1" :iconSet="getIconSet" />
        </f7-button>
        <f7-button :class="`region-button limbs${isAgreed && getRegions.includes('limbs') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('limbs') && '/detect/limbs/'">
          <RegionIcon class="region-image" :region="2" :iconSet="getIconSet" />
        </f7-button>
        <f7-button :class="`region-button headneck${isAgreed && getRegions.includes('head') ? '' : ' disabled'}`" :href="isAgreed && getRegions.includes('head') && '/detect/head/'">
          <RegionIcon class="region-image" :region="3" :iconSet="getIconSet" />
        </f7-button>
      </div>
    </div>
  </f7-page>
</template>

<style>
  .region-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(120px,max-content) minmax(120px,max-content);
    justify-items: center;
    align-content: center;
    gap: 20px 20px;
    margin: 30px;
    margin-top: 0;
    transform: scale(97%);
  }

  .region-button {
    aspect-ratio: 1;
    min-width: 100px;
    height: auto;
    width: 100%;
    background-color: var(--avn-button-bg-color);
    padding: 5px;
    max-width: 200px;
  }

  .region-image {
    width: 100%;
  }

  @media (min-width: 600px) {
    .region-grid {
      grid-template-columns: 1fr [thorax] auto [abdomen] auto [limbs] auto [headneck] auto 1fr;
      grid-template-rows: minmax(0, 1fr);
    }

    .thorax {
      grid-column-start: thorax;
    }

    .abdomen {
      grid-column-start: abdomen;
    }

    .limbs {
      grid-column-start: limbs;
    }

    .headneck {
      grid-column-start: headneck;
    }

    .region-button {
      max-height: calc(100% - 15px);
    }
  }

</style>

<script>
  import { touchstart } from 'dom7'
import RegionIcon from '../components/region-icon.vue'
  import store from '../js/store'
  import { f7 } from 'framework7-vue'

  export default {
    components: {
      RegionIcon
    },
    data () {
      return {
        isCordova: !!window.cordova,
        alphaCheck: false
      }
    },
    setup() {
      return store()
    },
    methods: {
      alphaWarn () {
        f7.dialog.alert('This is an alpha release. Expect bugs and use the contact page to report any bugs you encounter.', 'Warning', () => { this.alphaCheck = true })
      }
    }
  }
</script>
