import { isWeixinBrowser } from "@/controllers/wxController";
import { EditorModule } from "..";
import PreviewImagesModal from "../../components/PreviewImagesModal";

export const ImgCompActions = EditorModule.action({
  handleImageHotKey(key: string) {
    if (!this.store.isEditMode) return;
    if (this.store.currComp?.compKey !== "Image") return;

    const value = this.store.currComp.value;

    return;
    // if (key == "w") {
    //   value.y = (parseFloat(value.y) - 0.5).toFixed(2);
    //   return;
    // }
    // if (key == "s") {
    //   value.y = (parseFloat(value.y) + 0.5).toFixed(2);
    //   return;
    // }
    // if (key == "a") {
    //   value.x = (parseFloat(value.x) - 0.5).toFixed(2);
    //   return;
    // }
    // if (key == "d") {
    //   value.x = (parseFloat(value.x) + 0.5).toFixed(2);
    //   return;
    // }
    // if (key == "q") {
    //   value.s = (parseFloat(value.s) - 0.05).toFixed(2);
    //   return;
    // }
    // if (key == "e") {
    //   value.s = (parseFloat(value.s) + 0.05).toFixed(2);
    //   return;
    // }
  },
  previewImage(url, previewImageList) {
    if (this.controls.screenCtrl.state.screen.useFor == "pc") return;
    if (isWeixinBrowser()) {
      this.controls.wxCtrl.setPreviewData(url, previewImageList);
    } else {
      this.showModal(
        <PreviewImagesModal data={previewImageList} current={url} />,
        {
          fullscreen: true,
        }
      );
    }
  },
});
