diff --git a/examples/SampleApp/src/components/MessageSearch/MessageSearchList.tsx b/examples/SampleApp/src/components/MessageSearch/MessageSearchList.tsx index 6786a47e85..ef48f22cfc 100644 --- a/examples/SampleApp/src/components/MessageSearch/MessageSearchList.tsx +++ b/examples/SampleApp/src/components/MessageSearch/MessageSearchList.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { FlatList, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import dayjs from 'dayjs'; -import { Avatar, Spinner, useTheme, vw } from 'stream-chat-react-native'; +import { Avatar, Spinner, useTheme, useViewport } from 'stream-chat-react-native'; import { MESSAGE_SEARCH_LIMIT } from '../../hooks/usePaginatedSearchedMessages'; @@ -43,9 +43,6 @@ const styles = StyleSheet.create({ paddingLeft: 8, }, title: { fontSize: 14, fontWeight: '700' }, - titleContainer: { - maxWidth: vw(80) - 16 - 40, - }, }); export type MessageSearchListProps = { @@ -73,6 +70,7 @@ export const MessageSearchList: React.FC = React.forward colors: { black, border, grey, white_snow }, }, } = useTheme(); + const { vw } = useViewport(); const navigation = useNavigation(); if (loading && !refreshing && (!messages || messages.length === 0)) { @@ -134,7 +132,10 @@ export const MessageSearchList: React.FC = React.forward /> - + {`${item.user?.name} `} {!!item.channel?.name && ( diff --git a/examples/SampleApp/src/components/UserSearch/UserSearchResults.tsx b/examples/SampleApp/src/components/UserSearch/UserSearchResults.tsx index 68ce09de2d..f856f86c64 100644 --- a/examples/SampleApp/src/components/UserSearch/UserSearchResults.tsx +++ b/examples/SampleApp/src/components/UserSearch/UserSearchResults.tsx @@ -9,7 +9,7 @@ import { } from 'react-native'; import dayjs from 'dayjs'; import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg'; -import { Avatar, CheckSend, Close, useTheme, vw } from 'stream-chat-react-native'; +import { Avatar, CheckSend, Close, useTheme, useViewport } from 'stream-chat-react-native'; import { useUserSearchContext } from '../../context/UserSearchContext'; @@ -103,6 +103,7 @@ export const UserSearchResults: React.FC = ({ }, }, } = useTheme(); + const { vw } = useViewport(); const results = resultsProp || resultsContext; const resultsLength = results.length; diff --git a/examples/SampleApp/src/components/UserSearch/UserSearchResultsGrid.tsx b/examples/SampleApp/src/components/UserSearch/UserSearchResultsGrid.tsx index 3f97d79d80..840438257a 100644 --- a/examples/SampleApp/src/components/UserSearch/UserSearchResultsGrid.tsx +++ b/examples/SampleApp/src/components/UserSearch/UserSearchResultsGrid.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { ActivityIndicator, FlatList, StyleSheet, Text, View } from 'react-native'; -import { vw } from 'stream-chat-react-native'; +import { useViewport } from 'stream-chat-react-native'; import { UserGridItem } from './UserGridItem'; @@ -10,8 +10,6 @@ import type { UserResponse } from 'stream-chat'; import type { StreamChatGenerics } from '../../types'; -const totalUserSpace = vw(100) - 56; // 36 = outside margin 8 * 2 + inner padding 20 * 2; - const styles = StyleSheet.create({ container: { flex: 1, @@ -47,48 +45,53 @@ export const UserSearchResultsGrid: React.FC = ({ onPress, results, searchText, -}) => ( - - {loading && results.length === 0 && searchText === '' ? ( - - ) : ( - `${item.id}-${index}`} - ListEmptyComponent={() => ( - - - No user matches these keywords - {loading ? 'true' : 'false'} - {results.length} - - )} - numColumns={gridSize} - onEndReached={loadMore} - renderItem={({ index, item: user }) => ( - - { - onPress(user); - }} - removeButton={false} - user={user} - /> - - )} - showsVerticalScrollIndicator={false} - style={styles.flex} - /> - )} - -); +}) => { + const { vw } = useViewport(); + const totalUserSpace = vw(100) - 56; // 36 = outside margin 8 * 2 + inner padding 20 * 2; + + return ( + + {loading && results.length === 0 && searchText === '' ? ( + + ) : ( + `${item.id}-${index}`} + ListEmptyComponent={() => ( + + + No user matches these keywords + {loading ? 'true' : 'false'} + {results.length} + + )} + numColumns={gridSize} + onEndReached={loadMore} + renderItem={({ index, item: user }) => ( + + { + onPress(user); + }} + removeButton={false} + user={user} + /> + + )} + showsVerticalScrollIndicator={false} + style={styles.flex} + /> + )} + + ); +}; diff --git a/examples/SampleApp/src/screens/NewGroupChannelAssignNameScreen.tsx b/examples/SampleApp/src/screens/NewGroupChannelAssignNameScreen.tsx index fa62c65f3b..a4229e2f77 100644 --- a/examples/SampleApp/src/screens/NewGroupChannelAssignNameScreen.tsx +++ b/examples/SampleApp/src/screens/NewGroupChannelAssignNameScreen.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { StyleSheet, Text, TextInput, View } from 'react-native'; import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg'; -import { Check, generateRandomId, useTheme, vw } from 'stream-chat-react-native'; +import { Check, generateRandomId, useTheme, useViewport } from 'stream-chat-react-native'; import { RoundButton } from '../components/RoundButton'; import { ScreenHeader } from '../components/ScreenHeader'; @@ -89,6 +89,7 @@ export const NewGroupChannelAssignNameScreen: React.FC