Skip to content

Commit

Permalink
Improve exported types
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Mar 15, 2022
1 parent 446add0 commit ccce005
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
14 changes: 4 additions & 10 deletions src/SafeArea.types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import type * as React from 'react';
import type {
NativeSyntheticEvent,
StyleProp,
ViewProps,
ViewStyle,
} from 'react-native';
import type { NativeSyntheticEvent, ViewProps } from 'react-native';

export type Edge = 'top' | 'right' | 'bottom' | 'left';

Expand All @@ -31,14 +26,13 @@ export type InsetChangedEvent = NativeSyntheticEvent<Metrics>;

export type InsetChangeNativeCallback = (event: InsetChangedEvent) => void;

export interface NativeSafeAreaProviderProps {
export interface NativeSafeAreaProviderProps extends ViewProps {
children?: React.ReactNode;
style?: StyleProp<ViewStyle>;
onInsetsChange: InsetChangeNativeCallback;
}

export type NativeSafeAreaViewProps = ViewProps & {
export interface NativeSafeAreaViewProps extends ViewProps {
children?: React.ReactNode;
mode?: 'padding' | 'margin';
edges?: ReadonlyArray<Edge>;
};
}
4 changes: 2 additions & 2 deletions src/SafeAreaContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SafeAreaInsetsContext.displayName = 'SafeAreaInsetsContext';
export const SafeAreaFrameContext = React.createContext<Rect | null>(null);
SafeAreaFrameContext.displayName = 'SafeAreaFrameContext';

export interface SafeAreaViewProps extends ViewProps {
export interface SafeAreaProviderProps extends ViewProps {
children?: React.ReactNode;
initialMetrics?: Metrics | null;
/**
Expand All @@ -31,7 +31,7 @@ export function SafeAreaProvider({
initialSafeAreaInsets,
style,
...others
}: SafeAreaViewProps) {
}: SafeAreaProviderProps) {
const parentInsets = useParentSafeAreaInsets();
const parentFrame = useParentSafeAreaFrame();
const [insets, setInsets] = React.useState<EdgeInsets | null>(
Expand Down
4 changes: 3 additions & 1 deletion src/SafeAreaView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import NativeSafeAreaView from './specs/NativeSafeAreaView';

type NativeSafeAreaViewInstance = InstanceType<typeof NativeSafeAreaView>;

export type SafeAreaViewProps = NativeSafeAreaViewProps;

export const SafeAreaView = React.forwardRef<
NativeSafeAreaViewInstance,
NativeSafeAreaViewProps
SafeAreaViewProps
>(({ edges, ...props }, ref) => {
return (
<NativeSafeAreaView
Expand Down

0 comments on commit ccce005

Please sign in to comment.