<template>
  <div class="scene-list">
    <div class="header">
      <p>场景列表（{{ sceneList.length }}）</p>
      <span class="icon" @click="emit('close')">
        <Icon type="cross@2x" />
      </span>
    </div>
    <div class="content">
      <div
        class="sign"
        v-for="scene in sceneList"
        :key="scene.id"
        @click="emit('changeScene', scene)"
        :class="{ active: currentScene === scene }"
      >
        <div class="info">
          <img :src="scene.thumb" />
          <p>{{ scene.sceneName }}</p>
        </div>
        <span class="icon">
          <Icon type="arrow@2x" v-if="currentScene !== scene" />
        </span>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { unref } from "vue";
import Icon from "/@/components/basic/icon/index.vue";
import { useRoom } from "/@/hooks/useRoom";
// import { currentScene } from "@/store/room";
const { currentScene, sceneList } = useRoom();

console.log("sceneList", unref(sceneList));

const emit = defineEmits(["close", "changeScene"]);
</script>

<style scoped lang="scss">
.scene-list {
  max-height: 80%;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 10px 10px 0px 0px;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 99999;
  position: absolute;
}

.header {
  flex: none;
  text-align: center;
  height: 46px;
  line-height: 46px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);

  p {
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
  }

  .icon {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 14px;
    padding: 0 20px;
  }
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 11px;

  .sign {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;

    .info {
      flex: 1;
      display: flex;
      align-items: center;

      img {
        flex: none;
        width: 60px;
        height: 60px;
        border-radius: 4px;
      }

      p {
        font-size: 14px;
        font-weight: 400;
        color: #ffffff;
        line-height: 20px;
        margin-left: 10px;
      }
    }

    &.active .info p {
      color: #ed6155;
    }

    .icon {
      flex: none;
      font-size: 10px;
      margin-left: 20px;
    }
  }
}
</style>
