about summary refs log tree commit diff
path: root/src/view/com/util/Views.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-11-26 15:55:27 +0000
committerGitHub <noreply@github.com>2024-11-26 15:55:27 +0000
commitce1b04b9250d25ec781c7e1ee046ea6358a81a83 (patch)
tree952bc4c73345de774157dd6f9269493dcdaa31be /src/view/com/util/Views.tsx
parent56a88098d2ef8e271c7d63cb7d73cc220a787658 (diff)
downloadvoidsky-ce1b04b9250d25ec781c7e1ee046ea6358a81a83.tar.zst
Fix `<List>` types (#6756)
* fix List and ScrollView types

* add comment

* rm omitting ref
Diffstat (limited to 'src/view/com/util/Views.tsx')
-rw-r--r--src/view/com/util/Views.tsx28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/view/com/util/Views.tsx b/src/view/com/util/Views.tsx
new file mode 100644
index 000000000..0d3f63794
--- /dev/null
+++ b/src/view/com/util/Views.tsx
@@ -0,0 +1,28 @@
+import {forwardRef} from 'react'
+import {FlatListComponent} from 'react-native'
+import {View, ViewProps} from 'react-native'
+import Animated from 'react-native-reanimated'
+import {FlatListPropsWithLayout} from 'react-native-reanimated'
+
+// If you explode these into functions, don't forget to forwardRef!
+
+/**
+ * Avoid using `FlatList_INTERNAL` and use `List` where possible.
+ * The types are a bit wrong on `FlatList_INTERNAL`
+ */
+export const FlatList_INTERNAL = Animated.FlatList
+export type FlatList_INTERNAL<ItemT = any> = Omit<
+  FlatListComponent<ItemT, FlatListPropsWithLayout<ItemT>>,
+  'CellRendererComponent'
+>
+export const ScrollView = Animated.ScrollView
+export type ScrollView = typeof Animated.ScrollView
+
+export const CenteredView = forwardRef<
+  View,
+  React.PropsWithChildren<
+    ViewProps & {sideBorders?: boolean; topBorder?: boolean}
+  >
+>(function CenteredView(props, ref) {
+  return <View ref={ref} {...props} />
+})