-
Notifications
You must be signed in to change notification settings - Fork 151
/
index.d.ts
33 lines (30 loc) · 1.46 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as RN from 'react-native';
declare module 'react-native-size-matters' {
export function scale(size: number): number;
export function verticalScale(size: number): number;
export function moderateScale(size: number, factor?: number): number;
export function moderateVerticalScale(size: number, factor?: number): number;
export function s(size: number): number;
export function vs(size: number): number;
export function ms(size: number, factor?: number): number;
export function mvs(size: number, factor?: number): number;
type Scale = `${number}@s${'r' | ''}`;
type VerticalScale = `${number}@vs${'r' | ''}`;
type ModerateScale = `${number}@ms${number | ''}${'r' | ''}`;
type ModerateVerticalScale = `${number}@mvs${number | ''}${'r' | ''}`;
type Size = Scale | VerticalScale | ModerateScale | ModerateVerticalScale;
type WithSize<T> = { [P in keyof T]: number extends T[P] ? Size | T[P] : T[P] };
type ViewStyle = WithSize<RN.ViewStyle>;
type TextStyle = WithSize<RN.TextStyle>;
type ImageStyle = WithSize<RN.ImageStyle>;
type NamedStyles<T> = { [P in keyof T]: ViewStyle | TextStyle | ImageStyle };
export namespace ScaledSheet {
export function create<T extends NamedStyles<T> | NamedStyles<any>>(
stylesObject: T,
): {
[P in keyof T]: RN.RegisteredStyle<{
[S in keyof T[P]]: T[P][S] extends Size ? number : T[P][S];
}>;
};
}
}