51 lines
2.4 KiB
TypeScript
51 lines
2.4 KiB
TypeScript
// Metro module 6683 (f6684).
|
|
import { forwardRef, isValidElement } from "react";
|
|
import { createStyles } from "../../Styles/native/createStyles";
|
|
import * as _ButtonConstants_native from "./ButtonConstants.native";
|
|
import { SMALL_BUTTON_PADDING, MEDIUM_BUTTON_PADDING, LARGE_BUTTON_PADDING, DEFAULT_BUTTON_SIZE, SMALL_BUTTON_HEIGHT, MEDIUM_BUTTON_HEIGHT, MINIMUM_HIT_AREA } from "./ButtonConstants.native";
|
|
import ReanimatedRexport, { useSharedValue } from "../../../../modules/reanimated/ReanimatedRexport";
|
|
import Icon from "../../../void/Icon/native/Icon";
|
|
import { useIconTintStyles, useIconSizeStyles } from "./ButtonHooks.native";
|
|
import { BaseButton } from "./BaseButton.native";
|
|
import { ButtonPill } from "./ButtonPill.native";
|
|
let AnimatedComponent;
|
|
const useStyles = createStyles((a0, a1) => ({
|
|
button: {
|
|
flexShrink: 0,
|
|
flexGrow: 0,
|
|
alignSelf: "center"
|
|
},
|
|
pill: {
|
|
...a1 === "sm" ? {
|
|
paddingHorizontal: SMALL_BUTTON_PADDING,
|
|
paddingVertical: SMALL_BUTTON_PADDING
|
|
} : a1 === "md" ? {
|
|
paddingHorizontal: MEDIUM_BUTTON_PADDING,
|
|
paddingVertical: MEDIUM_BUTTON_PADDING
|
|
} : a1 === "lg" ? {
|
|
paddingHorizontal: LARGE_BUTTON_PADDING,
|
|
paddingVertical: LARGE_BUTTON_PADDING
|
|
} : {}
|
|
}
|
|
}));
|
|
AnimatedComponent = ReanimatedRexport.createAnimatedComponent(Icon);
|
|
const r31 = forwardRef(function(a0, a1) {
|
|
const { style, pillStyle, variant: variant2 = "primary", size = DEFAULT_BUTTON_SIZE, maxFontSizeMultiplier, loading, icon, scaleAmountInPx: scaleAmountInPx2 = 4 } = a0;
|
|
const styles3 = useStyles(variant2, size);
|
|
const sharedValue = useSharedValue(0);
|
|
const styles2 = useIconTintStyles(variant2);
|
|
const styles = useIconSizeStyles(size, true, maxFontSizeMultiplier);
|
|
let LARGE_BUTTON_HEIGHT = _ButtonConstants_native.LARGE_BUTTON_HEIGHT;
|
|
if (size === "sm") {
|
|
LARGE_BUTTON_HEIGHT = SMALL_BUTTON_HEIGHT;
|
|
} else if (size === "md") {
|
|
LARGE_BUTTON_HEIGHT = MEDIUM_BUTTON_HEIGHT;
|
|
}
|
|
return <BaseButton {...a0} ref={a1} style={[styles3.button, style]} pressed={sharedValue} scaleAmountInPx={scaleAmountInPx2} hitSlop={Math.max((MINIMUM_HIT_AREA - LARGE_BUTTON_HEIGHT) / 2, 0)}>
|
|
<ButtonPill style={[styles3.pill, pillStyle]} variant={variant2} size={size} loading={loading} loaderSize={size === "lg" ? "sm" : "xs"} pressed={sharedValue}>
|
|
{isValidElement(icon) ? icon : <AnimatedComponent source={icon} style={[styles2, styles]} />}
|
|
</ButtonPill>
|
|
</BaseButton>;
|
|
});
|
|
export { r31 as BaseIconButton };
|