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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import { ViewStyle } from "react-native"
import { color } from "../../theme"
/**
* All screen keyboard offsets.
*/
export const offsets = {
none: 0,
}
/**
* The variations of keyboard offsets.
*/
export type KeyboardOffsets = keyof typeof offsets
/**
* All the variations of screens.
*/
export const presets = {
/**
* No scrolling. Suitable for full-screen carousels and components
* which have built-in scrolling like FlatList.
*/
fixed: {
outer: {
backgroundColor: color.background,
flex: 1,
height: "100%",
} as ViewStyle,
inner: {
justifyContent: "flex-start",
alignItems: "stretch",
height: "100%",
width: "100%",
} as ViewStyle,
},
/**
* Scrolls. Suitable for forms or other things requiring a keyboard.
*
* Pick this one if you don't know which one you want yet.
*/
scroll: {
outer: {
backgroundColor: color.background,
flex: 1,
height: "100%",
} as ViewStyle,
inner: { justifyContent: "flex-start", alignItems: "stretch" } as ViewStyle,
},
}
/**
* The variations of screens.
*/
export type ScreenPresets = keyof typeof presets
/**
* Is this preset a non-scrolling one?
*
* @param preset The preset to check
*/
export function isNonScrolling(preset?: ScreenPresets) {
// any of these things will make you scroll
return !preset || !presets[preset] || preset === "fixed"
}
|