Skip to content

Commit

Permalink
Apply changes to HeaderFirstLevel from io-app repo
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnplb committed Dec 13, 2024
1 parent 38ecd11 commit 6aea8db
Showing 1 changed file with 10 additions and 65 deletions.
75 changes: 10 additions & 65 deletions src/components/layout/HeaderFirstLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,16 @@ import { HStack } from "../stack";
import { H3 } from "../typography";
import { HeaderActionProps } from "./common";

type CommonProps = WithTestID<{
export type HeaderFirstLevel = WithTestID<{
title: string;
// This Prop will be removed once all the screens on the first level routing will be refactored
backgroundColor?: "light" | "dark";
ignoreSafeAreaMargin?: boolean;
firstAction: HeaderActionProps;
secondAction: HeaderActionProps;
thirdAction?: HeaderActionProps;
animatedRef?: AnimatedRef<Animated.ScrollView>;
animatedFlatListRef?: AnimatedRef<Animated.FlatList<any>>;
ignoreSafeAreaMargin?: boolean;
}>;

interface Base extends CommonProps {
type: "base";
firstAction?: never;
secondAction?: never;
thirdAction?: never;
}

interface OneAction extends CommonProps {
type: "singleAction";
firstAction: HeaderActionProps;
secondAction?: never;
thirdAction?: never;
}

interface TwoActions extends CommonProps {
type: "twoActions";
firstAction: HeaderActionProps;
secondAction: HeaderActionProps;
thirdAction?: never;
}

interface ThreeActions extends CommonProps {
type: "threeActions";
firstAction: HeaderActionProps;
secondAction: HeaderActionProps;
thirdAction: HeaderActionProps;
}

export type HeaderFirstLevel = Base | OneAction | TwoActions | ThreeActions;

const HEADER_BG_COLOR_DARK: IOColors = "bluegrey";

const styles = StyleSheet.create({
headerInner: {
paddingHorizontal: IOVisualCostants.appMarginDefault,
Expand All @@ -88,9 +57,7 @@ const styles = StyleSheet.create({

export const HeaderFirstLevel = ({
title,
type,
testID,
backgroundColor = "light",
firstAction,
secondAction,
thirdAction,
Expand Down Expand Up @@ -135,12 +102,7 @@ export const HeaderFirstLevel = ({
return (
<Animated.View
style={[
{
backgroundColor:
backgroundColor === "light"
? IOColors[theme["appBackground-primary"]]
: IOColors[HEADER_BG_COLOR_DARK]
},
{ backgroundColor: IOColors[theme["appBackground-primary"]] },
animatedStyle
]}
accessibilityRole="header"
Expand All @@ -165,32 +127,15 @@ export const HeaderFirstLevel = ({
weight="Bold"
style={{ flexShrink: 1 }}
numberOfLines={1}
color={
backgroundColor === "dark" ? "white" : theme["textBody-default"]
}
color={theme["textHeading-default"]}
>
{title}
</H3>
</View>
<HStack space={16} style={{ flexShrink: 0 }}>
{type === "threeActions" && (
<IconButton
{...thirdAction}
color={backgroundColor === "dark" ? "contrast" : "primary"}
/>
)}
{(type === "twoActions" || type === "threeActions") && (
<IconButton
{...secondAction}
color={backgroundColor === "dark" ? "contrast" : "primary"}
/>
)}
{type !== "base" && (
<IconButton
{...firstAction}
color={backgroundColor === "dark" ? "contrast" : "primary"}
/>
)}
{thirdAction && <IconButton {...thirdAction} color={"primary"} />}
<IconButton {...secondAction} color={"primary"} />
<IconButton {...firstAction} color={"primary"} />
</HStack>
</View>
</Animated.View>
Expand Down

0 comments on commit 6aea8db

Please sign in to comment.