|
1 | 1 | import type { JSX } from "react"; |
2 | 2 | import { useMemo, useState, useEffect } from "react"; |
3 | 3 | import { |
4 | | - FlatList, |
5 | 4 | Modal, |
6 | 5 | Pressable, |
7 | 6 | ScrollView, |
@@ -210,45 +209,46 @@ export function RunSettingsSheet(props: RunSettingsSheetProps): JSX.Element { |
210 | 209 | </View> |
211 | 210 | )} |
212 | 211 |
|
213 | | - <FlatList |
214 | | - data={filteredModels} |
215 | | - keyExtractor={(item) => item.id} |
216 | | - nestedScrollEnabled |
217 | | - style={{ maxHeight: 320 }} |
218 | | - renderItem={({ item }) => ( |
219 | | - <Pressable |
220 | | - onPress={() => handleSelectModel(item.id)} |
221 | | - style={({ pressed }) => [ |
222 | | - styles.listItem, |
223 | | - { |
224 | | - backgroundColor: pressed |
225 | | - ? theme.colors.surfaceSecondary |
226 | | - : theme.colors.background, |
227 | | - }, |
228 | | - ]} |
229 | | - > |
230 | | - <View style={{ flex: 1 }}> |
231 | | - <ThemedText weight="semibold">{getModelDisplayName(item.id)}</ThemedText> |
232 | | - <ThemedText variant="caption" style={{ color: theme.colors.foregroundMuted }}> |
233 | | - {formatModelSummary(item.id)} |
234 | | - </ThemedText> |
235 | | - </View> |
236 | | - {props.selectedModel === item.id && ( |
237 | | - <Ionicons name="checkmark-circle" size={20} color={theme.colors.accent} /> |
238 | | - )} |
239 | | - </Pressable> |
240 | | - )} |
241 | | - ItemSeparatorComponent={() => ( |
242 | | - <View style={{ height: StyleSheet.hairlineWidth, backgroundColor: theme.colors.border }} /> |
243 | | - )} |
244 | | - ListEmptyComponent={() => ( |
| 212 | + <View style={styles.modelList}> |
| 213 | + {filteredModels.length === 0 ? ( |
245 | 214 | <View style={{ padding: 24 }}> |
246 | 215 | <ThemedText variant="caption" style={{ textAlign: "center" }}> |
247 | 216 | No models match "{query}" |
248 | 217 | </ThemedText> |
249 | 218 | </View> |
| 219 | + ) : ( |
| 220 | + filteredModels.map((item, index) => ( |
| 221 | + <View key={item.id}> |
| 222 | + <Pressable |
| 223 | + onPress={() => handleSelectModel(item.id)} |
| 224 | + style={({ pressed }) => [ |
| 225 | + styles.listItem, |
| 226 | + { |
| 227 | + backgroundColor: pressed |
| 228 | + ? theme.colors.surfaceSecondary |
| 229 | + : theme.colors.background, |
| 230 | + }, |
| 231 | + ]} |
| 232 | + > |
| 233 | + <View style={{ flex: 1 }}> |
| 234 | + <ThemedText weight="semibold">{getModelDisplayName(item.id)}</ThemedText> |
| 235 | + <ThemedText variant="caption" style={{ color: theme.colors.foregroundMuted }}> |
| 236 | + {formatModelSummary(item.id)} |
| 237 | + </ThemedText> |
| 238 | + </View> |
| 239 | + {props.selectedModel === item.id && ( |
| 240 | + <Ionicons name="checkmark-circle" size={20} color={theme.colors.accent} /> |
| 241 | + )} |
| 242 | + </Pressable> |
| 243 | + {index < filteredModels.length - 1 ? ( |
| 244 | + <View |
| 245 | + style={{ height: StyleSheet.hairlineWidth, backgroundColor: theme.colors.border }} |
| 246 | + /> |
| 247 | + ) : null} |
| 248 | + </View> |
| 249 | + )) |
250 | 250 | )} |
251 | | - /> |
| 251 | + </View> |
252 | 252 | </SectionCard> |
253 | 253 |
|
254 | 254 | <SectionCard |
@@ -391,6 +391,9 @@ const styles = StyleSheet.create({ |
391 | 391 | gap: 8, |
392 | 392 | marginTop: 8, |
393 | 393 | }, |
| 394 | + modelList: { |
| 395 | + maxHeight: 320, |
| 396 | + }, |
394 | 397 | chip: { |
395 | 398 | paddingVertical: 6, |
396 | 399 | paddingHorizontal: 12, |
|
0 commit comments