Skip to content

Commit 6bf541a

Browse files
committed
feat: implement suggestions list
1 parent 0dec251 commit 6bf541a

File tree

6 files changed

+62
-57
lines changed

6 files changed

+62
-57
lines changed

package/src/components/AutoCompleteInput/AutoCompleteSuggestionHeader.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { StyleSheet, Text, View } from 'react-native';
33

44
import { useTheme } from '../../contexts/themeContext/ThemeContext';
55

6-
import { Lightning } from '../../icons/Lightning';
76
import { Smile } from '../../icons/Smile';
7+
import { primitives } from '../../theme';
88

99
export type AutoCompleteSuggestionHeaderProps = {
1010
queryText?: string;
@@ -14,7 +14,7 @@ export type AutoCompleteSuggestionHeaderProps = {
1414
export const CommandsHeader: React.FC<AutoCompleteSuggestionHeaderProps> = () => {
1515
const {
1616
theme: {
17-
colors: { accent_blue, grey },
17+
semantics,
1818
messageInput: {
1919
suggestions: {
2020
header: { container, title },
@@ -25,8 +25,10 @@ export const CommandsHeader: React.FC<AutoCompleteSuggestionHeaderProps> = () =>
2525

2626
return (
2727
<View style={[styles.container, container]}>
28-
<Lightning fill={accent_blue} size={32} />
29-
<Text style={[styles.title, { color: grey }, title]} testID='commands-header-title'>
28+
<Text
29+
style={[styles.title, { color: semantics.textTertiary }, title]}
30+
testID='commands-header-title'
31+
>
3032
{'Instant Commands'}
3133
</Text>
3234
</View>
@@ -107,7 +109,9 @@ const styles = StyleSheet.create({
107109
padding: 8,
108110
},
109111
title: {
110-
fontSize: 14,
112+
fontSize: primitives.typographyFontSizeSm,
113+
lineHeight: primitives.typographyLineHeightNormal,
114+
fontWeight: primitives.typographyFontWeightMedium,
111115
paddingLeft: 8,
112116
},
113117
});

package/src/components/AutoCompleteInput/AutoCompleteSuggestionItem.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { AutoCompleteSuggestionCommandIcon } from './AutoCompleteSuggestionComma
77

88
import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
99
import { useTheme } from '../../contexts/themeContext/ThemeContext';
10-
import { AtMentions } from '../../icons/AtMentions';
1110
import { primitives } from '../../theme';
1211
import type { Emoji } from '../../types/types';
1312

@@ -22,7 +21,7 @@ export const MentionSuggestionItem = (item: UserSuggestion) => {
2221
const { id, name, online } = item;
2322
const {
2423
theme: {
25-
colors: { accent_blue, black },
24+
colors: { black },
2625
messageInput: {
2726
suggestions: {
2827
mention: { column, container: mentionContainer, name: nameStyle },
@@ -40,7 +39,6 @@ export const MentionSuggestionItem = (item: UserSuggestion) => {
4039
{name || id}
4140
</Text>
4241
</View>
43-
<AtMentions pathFill={accent_blue} />
4442
</View>
4543
);
4644
};
@@ -203,8 +201,9 @@ const useStyles = () => {
203201
paddingVertical: primitives.spacingXs,
204202
},
205203
name: {
206-
fontSize: 14,
207-
fontWeight: 'bold',
204+
fontSize: primitives.typographyFontSizeMd,
205+
lineHeight: primitives.typographyLineHeightNormal,
206+
color: semantics.textPrimary,
208207
paddingBottom: 2,
209208
},
210209
tag: {

package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useCallback, useMemo } from 'react';
2-
import { FlatList, StyleSheet, View } from 'react-native';
2+
import { FlatList, StyleSheet } from 'react-native';
3+
4+
import Animated, { LinearTransition, ZoomIn, ZoomOut } from 'react-native-reanimated';
35

46
import { SearchSourceState, TextComposerState, TextComposerSuggestion } from 'stream-chat';
57

@@ -12,7 +14,7 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
1214
import { useStableCallback } from '../../hooks';
1315
import { useStateStore } from '../../hooks/useStateStore';
1416

15-
export const DEFAULT_LIST_HEIGHT = 200;
17+
export const DEFAULT_LIST_HEIGHT = 208;
1618

1719
export type AutoCompleteSuggestionListProps = Partial<
1820
Pick<MessageInputContextValue, 'AutoCompleteSuggestionHeader' | 'AutoCompleteSuggestionItem'>
@@ -63,10 +65,10 @@ export const AutoCompleteSuggestionList = ({
6365
colors: { black, white },
6466
messageInput: {
6567
container: { maxHeight },
66-
suggestionsListContainer: { flatlist },
6768
},
6869
},
6970
} = useTheme();
71+
const styles = useStyles();
7072

7173
const renderItem = useCallback(
7274
({ item }: { item: TextComposerSuggestion }) => {
@@ -90,7 +92,12 @@ export const AutoCompleteSuggestionList = ({
9092
}
9193

9294
return (
93-
<View style={[styles.container]}>
95+
<Animated.View
96+
entering={ZoomIn.duration(200)}
97+
exiting={ZoomOut.duration(200)}
98+
layout={LinearTransition.duration(200)}
99+
style={styles.container}
100+
>
94101
<FlatList
95102
data={items}
96103
keyboardShouldPersistTaps='always'
@@ -99,33 +106,47 @@ export const AutoCompleteSuggestionList = ({
99106
onEndReached={loadMore}
100107
onEndReachedThreshold={0.1}
101108
renderItem={renderItem}
102-
style={[
103-
styles.flatlist,
104-
flatlist,
105-
{ backgroundColor: white, maxHeight, shadowColor: black },
106-
]}
109+
style={[styles.flatlist, { backgroundColor: white, maxHeight, shadowColor: black }]}
107110
testID={'auto-complete-suggestion-list'}
108111
/>
109-
</View>
112+
</Animated.View>
110113
);
111114
};
112115

113-
const styles = StyleSheet.create({
114-
container: {
115-
maxHeight: DEFAULT_LIST_HEIGHT,
116-
},
117-
flatlist: {
118-
borderRadius: 8,
119-
elevation: 3,
120-
marginHorizontal: 8,
121-
shadowOffset: {
122-
height: 1,
123-
width: 0,
116+
const useStyles = () => {
117+
const {
118+
theme: {
119+
semantics,
120+
messageInput: {
121+
suggestionsListContainer: { flatlist },
122+
},
124123
},
125-
shadowOpacity: 0.22,
126-
shadowRadius: 2.22,
127-
},
128-
});
124+
} = useTheme();
125+
return useMemo(
126+
() =>
127+
StyleSheet.create({
128+
container: {
129+
maxHeight: DEFAULT_LIST_HEIGHT,
130+
backgroundColor: semantics.composerBg,
131+
borderTopWidth: 1,
132+
borderColor: semantics.borderCoreDefault,
133+
},
134+
flatlist: {
135+
borderRadius: 8,
136+
elevation: 3,
137+
marginHorizontal: 8,
138+
shadowOffset: {
139+
height: 1,
140+
width: 0,
141+
},
142+
shadowOpacity: 0.22,
143+
shadowRadius: 2.22,
144+
...flatlist,
145+
},
146+
}),
147+
[semantics, flatlist],
148+
);
149+
};
129150

130151
AutoCompleteSuggestionList.displayName =
131152
'AutoCompleteSuggestionList{messageInput{suggestions{List}}}';

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { Modal, StyleSheet, TextInput, TextInputProps, View } from 'react-native
44
import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import Animated, {
66
Extrapolation,
7-
FadeIn,
8-
FadeOut,
97
interpolate,
108
LinearTransition,
119
useAnimatedStyle,
@@ -133,6 +131,7 @@ const useStyles = () => {
133131
shadowRadius: 12,
134132
},
135133
suggestionsListContainer: {
134+
backgroundColor: semantics.composerBg,
136135
position: 'absolute',
137136
width: '100%',
138137
},
@@ -454,14 +453,9 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
454453
<MessageComposerTrailingView />
455454
)}
456455

457-
<Animated.View
458-
entering={FadeIn.duration(200)}
459-
exiting={FadeOut.duration(200)}
460-
layout={LinearTransition.duration(200)}
461-
style={[styles.suggestionsListContainer, { bottom: height }, suggestionListContainer]}
462-
>
456+
<View style={[styles.suggestionsListContainer, { bottom: height }, suggestionListContainer]}>
463457
<AutoCompleteSuggestionList />
464-
</Animated.View>
458+
</View>
465459

466460
{showPollCreationDialog ? (
467461
<View style={styles.pollModalWrapper}>

package/src/icons/AtMentions.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

package/src/icons/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * from './Archive';
44
export * from './ArrowRight';
55
export * from './ArrowLeft';
66
export * from './ArrowUp';
7-
export * from './AtMentions';
87
export * from './Attach';
98
export * from './Audio';
109
export * from './Camera';

0 commit comments

Comments
 (0)