summaryrefslogtreecommitdiff
path: root/app/components/screen/screen.presets.ts
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-07-14 15:10:31 +0200
committerThomas F. K. Jorna <[email protected]>2021-07-14 15:10:31 +0200
commite5021187e96b78b53203bd95d08d6818aea47d17 (patch)
tree37ec45d00eb963db53cd4bb4f04a770414b351cc /app/components/screen/screen.presets.ts
New Ignite 7.0.6 app
Diffstat (limited to 'app/components/screen/screen.presets.ts')
-rw-r--r--app/components/screen/screen.presets.ts66
1 files changed, 66 insertions, 0 deletions
diff --git a/app/components/screen/screen.presets.ts b/app/components/screen/screen.presets.ts
new file mode 100644
index 0000000..a016b77
--- /dev/null
+++ b/app/components/screen/screen.presets.ts
@@ -0,0 +1,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"
+}