touch operation

This commit is contained in:
Gabe Yuan
2023-11-11 16:59:38 +08:00
parent 46428b7c7f
commit 4b23ee733f
11 changed files with 58 additions and 168 deletions

View File

@@ -1,19 +0,0 @@
import { useCallback } from "react";
import { DEFAULT_TOUCH_OPERATION } from "../config";
import { useSetting } from "./Setting";
export function useTouch(action) {
const { setting, updateSetting } = useSetting();
const touchOperations = setting?.touchOperations || DEFAULT_TOUCH_OPERATION;
const touchOperation = touchOperations[action];
const setTouchOperation = useCallback(
async (val, idx) => {
touchOperations[action][idx] = val;
await updateSetting({ touchOperations: { ...touchOperations } });
},
[action, touchOperations, updateSetting]
);
return { touchOperation, setTouchOperation };
}