Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32197717
D6466.1765103979.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D6466.1765103979.diff
View Options
diff --git a/native/chat/settings/thread-settings-media-gallery.react.js b/native/chat/settings/thread-settings-media-gallery.react.js
new file mode 100644
--- /dev/null
+++ b/native/chat/settings/thread-settings-media-gallery.react.js
@@ -0,0 +1,74 @@
+// @flow
+
+import * as React from 'react';
+import {
+ View,
+ TouchableOpacity,
+ Image,
+ FlatList,
+ useWindowDimensions,
+} from 'react-native';
+
+import type { Media } from 'lib/types/media-types';
+
+import { useStyles } from '../../themes/colors';
+
+function ThreadSettingsMediaGallery(): React.Node {
+ const styles = useStyles(unboundStyles);
+ const galleryItemGap = 8;
+ const { width } = useWindowDimensions();
+
+ const galleryItemWidth = (width - galleryItemGap * 3) / 3;
+ const mediaInfos = [];
+
+ const memoizedStyles = React.useMemo(() => {
+ return {
+ mediaContainer: {
+ marginTop: galleryItemGap,
+ marginLeft: galleryItemGap,
+ width: galleryItemWidth,
+ ...styles.mediaContainer,
+ },
+ media: {
+ width: galleryItemWidth,
+ ...styles.media,
+ },
+ };
+ }, [galleryItemGap, galleryItemWidth, styles.media, styles.mediaContainer]);
+
+ const renderItem = React.useCallback(
+ ({ item }) => {
+ return <GalleryItem item={item} memoizedStyles={memoizedStyles} />;
+ },
+ [memoizedStyles],
+ );
+
+ return <FlatList data={mediaInfos} numColumns={3} renderItem={renderItem} />;
+}
+
+const GalleryItem: React.ComponentType<{
+ item: Media,
+ memoizedStyles: Object,
+}> = React.memo(({ item, memoizedStyles }) => {
+ return (
+ <View key={item.id} style={memoizedStyles.mediaContainer}>
+ <TouchableOpacity>
+ <Image source={item.uri} style={memoizedStyles.media} />
+ </TouchableOpacity>
+ </View>
+ );
+});
+GalleryItem.displayName = 'GalleryItem';
+
+const unboundStyles = {
+ mediaContainer: {
+ height: 180,
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ media: {
+ height: 180,
+ },
+};
+
+export default ThreadSettingsMediaGallery;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 10:39 AM (20 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5843776
Default Alt Text
D6466.1765103979.diff (2 KB)
Attached To
Mode
D6466: [native] Create a component for the media gallery on native
Attached
Detach File
Event Timeline
Log In to Comment