<template>
  <m-grid
    :template="['title title title', 'left . right']"
    columns="16vw auto 49vw"
    rows="0.4rem auto"
    gap="0.05rem"
  >
    <m-title area="title">南东城运</m-title>
    <m-animate enter="fadeInLeft" leave="fadeOutLeft">
      <Command v-show="'street' === curViewType && !fullScreen" area="left" />
    </m-animate>
    <m-animate enter="fadeInLeft" leave="fadeOutLeft">
      <ManageBasic
        v-show="'street' !== curViewType && !fullScreen"
        area="left"
      />
    </m-animate>

    <m-animate
      v-for="part in streetComponentList"
      :key="part.name"
      enter="fadeInRight"
      leave="fadeOutRight"
    >
      <component
        :is="part.component"
        v-show="
          'street' === curViewType && curTheme === part.name && !fullScreen
        "
        area="right"
      />
    </m-animate>
    <m-animate enter="fadeInRight" leave="fadeOutRight">
      <PublicWork
        v-show="'street' !== curViewType && !fullScreen"
        area="right"
      />
    </m-animate>
    <ViewSelector />
    <MapBtns @full="fullScreen = $event" />
    <m-drawer v-model="showDrawer"> test </m-drawer>
  </m-grid>
</template>

<script lang="ts">
import { computed, defineComponent, ref } from 'vue'
import ManageBasic from './left/manage-basic.vue'
import Command from './left/command.vue'
import PublicWork from './right/public-work.vue'
import PublicManage from './right/public-manage.vue'
import PublicService from './right/public-service.vue'
import PublicSafety from './right/public-safety.vue'
import ViewSelector from './components/view-selector.vue'
import MapBtns from './components/map-btns.vue'
import store from '@/store'

export default defineComponent({
  name: 'Main',
  components: {
    ManageBasic,
    Command,
    PublicWork,
    PublicManage,
    PublicService,
    PublicSafety,
    ViewSelector,
    MapBtns,
  },
  setup() {
    const curViewType = computed(() => store.state.curView.type)
    const curTheme = computed(() => store.state.curTheme)
    const streetComponentList = computed(() => [
      {
        name: 'manage',
        component: PublicManage,
      },
      {
        name: 'service',
        component: PublicService,
      },
      {
        name: 'safety',
        component: PublicSafety,
      },
    ])
    const fullScreen = ref(false)
    const showDrawer = ref(false)
    return {
      curViewType,
      curTheme,
      streetComponentList,
      fullScreen,
      showDrawer,
    }
  },
})
</script>

<style lang="stylus" scoped></style>
