/*
绘制一级目录列表
*/
//获取手机屏幕大小信息
const screenWidth  = window.innerWidth
const screenHeight = window.innerHeight


export default class FLD {
  drawFLD(context, image, status, index, text) {
    //console.log(index)
    //当未被选中时
    if (status == false) {
      //根据是第几个一级目录画图标
      image.onload = function () {
        context.drawImage(image, screenWidth - 48, index * 50, 50, 35)
      }
      //把目录名字加上
      //drawText(text, index)
      context.fillStyle = '#000'
      context.font = "1px Arial"
      if (text.length == 2) {
        context.fillText(text, screenWidth - 37, (index + 2) * 50 - 2)
      }
      if (text.length == 3) {
        context.fillText(text, screenWidth - 43, (index + 2) * 50 - 2)
      }
      if (text.length == 4) {
        context.fillText(text, screenWidth - 50, (index + 2) * 50 - 2)
      }
    }
    else {
      //将选项背景换成白色，左边界变成红色
      context.fillStyle = '#fff'
      context.fillRect(screenWidth - 48, index * 50+50, 50, 50)
      context.fillStyle = 'red'
      context.fillRect(screenWidth - 50, index * 50+50, 2, 50)
      image.onload = function () {
        context.drawImage(image, screenWidth - 48, index * 50, 50, 35)
      }
      //drawText(text, index)
      context.fillStyle = '#000'
      context.font = "1px Arial"
      if (text.length == 2) {
        context.fillText(text, screenWidth - 37, (index + 2) * 50 - 2)
      }
      if (text.length == 3) {
        context.fillText(text, screenWidth - 43, (index + 2) * 50 - 2)
      }
      if (text.length == 4) {
        context.fillText(text, screenWidth - 50, (index + 2) * 50 - 2)
      }
    }
    index++
    //console.log(index)
  }
  //目录名字长度不同情况下居中对齐，暂时考虑2，3，4个字
  /* drawText(text, index) {
     context.fillStyle = '#000'
     context.font = "1px Arial"
     if (text.length == 2) {
       context.fillText(text, screenWidth - 37, (index + 1) * 50 - 2)
     }
     if (text.length == 3) {
       context.fillText(text, screenWidth - 46, (index + 1) * 50 - 2)
     }
     if (text.length == 4) {
       context.fillText(text, screenWidth - 50, (index + 1) * 50 - 2)
     }
   }*/

}
