Skip to content

Commit

Permalink
fix: make it possible to make header absolute (own use-case)
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLindhout committed Aug 2, 2023
1 parent 1c15e32 commit 3c14473
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Swiper.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function SwiperNative(props: SwiperProps) {
mode,
showLeadingSpace,
disableSwipe,
tabHeaderStyle,
} = props;
const { index, goTo } = React.useContext(TabsContext);
const indexRef = React.useRef<number>(index || 0);
Expand Down Expand Up @@ -75,6 +76,7 @@ function SwiperNative(props: SwiperProps) {
showLeadingSpace,
uppercase,
mode,
tabHeaderStyle,
};
return (
<>
Expand Down
2 changes: 2 additions & 0 deletions src/Swiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function Swiper(props: SwiperProps) {
showLeadingSpace,
uppercase,
mode,
tabHeaderStyle,
} = props;

const index = useTabIndex();
Expand All @@ -37,6 +38,7 @@ function Swiper(props: SwiperProps) {
showLeadingSpace,
uppercase,
mode,
tabHeaderStyle,
};

return (
Expand Down
3 changes: 3 additions & 0 deletions src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function Tabs({
showTextLabel = true,
showLeadingSpace = true,
disableSwipe = false,
tabHeaderStyle,
}: {
children: any;
theme: typeof MD3LightTheme;
Expand All @@ -28,6 +29,7 @@ function Tabs({
uppercase?: boolean;
mode?: Mode;
disableSwipe?: boolean;
tabHeaderStyle?: ViewStyle | undefined;
}) {
return (
<Swiper
Expand All @@ -40,6 +42,7 @@ function Tabs({
showLeadingSpace={showLeadingSpace}
mode={mode}
disableSwipe={disableSwipe}
tabHeaderStyle={tabHeaderStyle}
>
{children}
</Swiper>
Expand Down
5 changes: 3 additions & 2 deletions src/TabsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function TabsHeader({
showLeadingSpace,
uppercase,
mode,
tabHeaderStyle,
...rest
}: SwiperRenderProps) {
const children = React.Children.toArray(rest.children).filter(Boolean);
Expand Down Expand Up @@ -166,7 +167,7 @@ export default function TabsHeader({
const SurfaceComponent = theme.isV3 ? View : Surface;

return (
<View style={styles.relative}>
<Animated.View style={[styles.relative, tabHeaderStyle]}>
<SurfaceComponent
style={[
{ backgroundColor, elevation },
Expand Down Expand Up @@ -241,7 +242,7 @@ export default function TabsHeader({
/>
)}
</SurfaceComponent>
</View>
</Animated.View>
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface SwiperRenderProps {
showLeadingSpace?: boolean;
uppercase: boolean;
mode: Mode;
tabHeaderStyle: ViewStyle | undefined;
}

export interface SwiperProps {
Expand All @@ -38,6 +39,7 @@ export interface SwiperProps {
uppercase: boolean;
mode: Mode;
disableSwipe?: boolean;
tabHeaderStyle: ViewStyle | undefined;
}

export interface OffsetScrollArgs {
Expand Down

0 comments on commit 3c14473

Please sign in to comment.