Skip to content

Commit

Permalink
Fixing actions type for GradientBottomActions
Browse files Browse the repository at this point in the history
  • Loading branch information
drmarro committed Nov 6, 2023
1 parent db6bf51 commit 556b1a7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
37 changes: 22 additions & 15 deletions src/components/layout/GradientBottomActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,31 @@ import LinearGradient from "react-native-linear-gradient";
import Animated from "react-native-reanimated";
import { IOColors, IOSpacer, IOVisualCostants, hexToRgba } from "../../core";
import { WithTestID } from "../../utils/types";
import { ButtonLink, ButtonSolid } from "../buttons";
import {
ButtonLink,
ButtonLinkProps,
ButtonSolid,
ButtonSolidProps
} from "../buttons";
import { VSpacer } from "../spacer";
import { GradientBottomAction } from "./common";

export interface ButtonLinkAction {
type: "ButtonLink";
actionProps: ButtonLinkProps;
}

export interface ButtonSolidAction {
type: "ButtonSolid";
actionProps: ButtonSolidProps;
}

export type GradientBottomActions = WithTestID<{
transitionAnimStyle: Animated.AnimateStyle<StyleProp<ViewStyle>>;
dimensions: GradientBottomActionsDimensions;
// Accepted components: ButtonSolid, ButtonLink
// Don't use any components other than this, please.
primaryAction?: GradientBottomAction;
secondaryAction?: GradientBottomAction;
primaryAction?: ButtonSolidAction;
secondaryAction?: ButtonLinkAction;
// Debug mode
debugMode?: boolean;
}>;
Expand Down Expand Up @@ -101,12 +115,9 @@ export const GradientBottomActions = ({
]}
/>
<View style={styles.buttonContainer} pointerEvents="box-none">
{primaryAction &&
(primaryAction.type === "ButtonLink" ? (
<ButtonLink {...primaryAction.actionProps}></ButtonLink>
) : (
<ButtonSolid {...primaryAction.actionProps}></ButtonSolid>
))}
{primaryAction && (
<ButtonSolid {...primaryAction.actionProps}></ButtonSolid>
)}

{secondaryAction && (
<View
Expand All @@ -116,11 +127,7 @@ export const GradientBottomActions = ({
}}
>
<VSpacer size={dimensions.spaceBetweenActions} />
{secondaryAction.type === "ButtonLink" ? (
<ButtonLink {...secondaryAction.actionProps}></ButtonLink>
) : (
<ButtonSolid {...secondaryAction.actionProps}></ButtonSolid>
)}
{<ButtonLink {...secondaryAction.actionProps}></ButtonLink>}
</View>
)}
</View>
Expand Down
10 changes: 6 additions & 4 deletions src/components/layout/GradientScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ import {
buttonSolidHeight
} from "../../core";
import { WithTestID } from "../../utils/types";
import GradientBottomActions from "./GradientBottomActions";
import { GradientBottomAction } from "./common";
import GradientBottomActions, {
ButtonLinkAction,
ButtonSolidAction
} from "./GradientBottomActions";

export type GradientScrollView = WithTestID<{
children: React.ReactNode;
excludeSafeAreaMargins?: boolean;
debugMode?: boolean;
// Accepted components: ButtonSolid, ButtonLink
// Don't use any components other than this, please.
primaryAction: GradientBottomAction;
secondaryAction?: GradientBottomAction;
primaryAction: ButtonSolidAction;
secondaryAction?: ButtonLinkAction;
}>;

// Extended gradient area above the actions
Expand Down
14 changes: 1 addition & 13 deletions src/components/layout/common.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import * as React from "react";
import { ButtonLinkProps, ButtonSolidProps, IconButton } from "../buttons";
import { IconButton } from "../buttons";

export type ActionProp = Pick<
React.ComponentProps<typeof IconButton>,
"icon" | "onPress" | "accessibilityLabel" | "accessibilityHint" | "testID"
>;

interface ButtonLinkAction {
type: "ButtonLink";
actionProps: ButtonLinkProps;
}

interface ButtonSolidAction {
type: "ButtonSolid";
actionProps: ButtonSolidProps;
}

export type GradientBottomAction = ButtonLinkAction | ButtonSolidAction;

0 comments on commit 556b1a7

Please sign in to comment.