Skip to content

Commit

Permalink
fix: format"
Browse files Browse the repository at this point in the history
  • Loading branch information
Naturalclar committed Nov 7, 2024
1 parent cace18a commit c0ebbe0
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import React, { forwardRef, useMemo } from "react";
import { forwardRef, useMemo } from "react";
import { processColor } from "react-native";

import UIMenuView from "./UIMenuView";
import type {
MenuComponentProps,
MenuAction,
ProcessedMenuAction,
NativeActionEvent,
MenuComponentRef,
MenuComponentProps,
MenuAction,
ProcessedMenuAction,
NativeActionEvent,
MenuComponentRef,
} from "./types";
import { objectHash } from "./utils";

function processAction(action: MenuAction): ProcessedMenuAction {
return {
...action,
imageColor: processColor(action.imageColor),
titleColor: processColor(action.titleColor),
subactions: action.subactions?.map((subAction) => processAction(subAction)),
};
return {
...action,
imageColor: processColor(action.imageColor),
titleColor: processColor(action.titleColor),
subactions: action.subactions?.map((subAction) => processAction(subAction)),
};
}

const defaultHitslop = { top: 0, left: 0, bottom: 0, right: 0 };

const MenuView = forwardRef<MenuComponentRef, MenuComponentProps>(
({ actions, hitSlop = defaultHitslop, ...props }, ref) => {
const processedActions = actions.map<ProcessedMenuAction>((action) =>
processAction(action),
);
const hash = useMemo(() => {
return objectHash(processedActions);
}, [processedActions]);
({ actions, hitSlop = defaultHitslop, ...props }, ref) => {
const processedActions = actions.map<ProcessedMenuAction>((action) =>
processAction(action),
);
const hash = useMemo(() => {
return objectHash(processedActions);
}, [processedActions]);

return (
<UIMenuView
{...props}
hitSlop={hitSlop}
actions={processedActions}
actionsHash={hash}
ref={ref}
/>
);
},
return (
<UIMenuView
{...props}
hitSlop={hitSlop}
actions={processedActions}
actionsHash={hash}
ref={ref}
/>
);
},
);

export { MenuView };
export type {
MenuComponentProps,
MenuComponentRef,
MenuAction,
NativeActionEvent,
MenuComponentProps,
MenuComponentRef,
MenuAction,
NativeActionEvent,
};

0 comments on commit c0ebbe0

Please sign in to comment.