diff --git a/apps/src/tests/issue-tests/Test4089.tsx b/apps/src/tests/issue-tests/Test4089.tsx new file mode 100644 index 0000000000..726d9d9ff3 --- /dev/null +++ b/apps/src/tests/issue-tests/Test4089.tsx @@ -0,0 +1,198 @@ +import { NavigationContainer } from '@react-navigation/native'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; +import type { NativeStackScreenProps } from '@react-navigation/native-stack'; +import React, { useLayoutEffect, useState } from 'react'; +import { Button, ScrollView, StyleSheet, Text, View } from 'react-native'; +import type { SearchBarPlacement, SearchBarProps } from 'react-native-screens'; + +type StackParamList = { + Home: undefined; + SearchBar: undefined; +}; + +type PlaceholderMode = 'default' | 'custom' | 'empty'; +type HintColorMode = 'default' | 'red' | 'blue'; + +type SearchBarConfig = { + placement: SearchBarPlacement; + placeholderMode: PlaceholderMode; + hintColorMode: HintColorMode; + allowToolbarIntegration: boolean; +}; + +const Stack = createNativeStackNavigator(); + +const placements: SearchBarPlacement[] = [ + 'automatic', + 'inline', + 'stacked', + 'integrated', + 'integratedButton', + 'integratedCentered', +]; + +const placeholderModes: PlaceholderMode[] = ['default', 'custom', 'empty']; +const hintColorModes: HintColorMode[] = ['default', 'red', 'blue']; + +const defaultConfig: SearchBarConfig = { + placement: 'automatic', + placeholderMode: 'default', + hintColorMode: 'default', + allowToolbarIntegration: true, +}; + +function getNextValue(values: readonly T[], currentValue: T): T { + const currentIndex = values.indexOf(currentValue); + return values[(currentIndex + 1) % values.length]; +} + +function getPlaceholder(mode: PlaceholderMode): SearchBarProps['placeholder'] { + switch (mode) { + case 'custom': + return 'Custom placeholder'; + case 'empty': + return ''; + default: + return undefined; + } +} + +function getHintTextColor( + mode: HintColorMode, +): SearchBarProps['hintTextColor'] { + switch (mode) { + case 'red': + return 'red'; + case 'blue': + return 'blue'; + default: + return undefined; + } +} + +function Home({ navigation }: NativeStackScreenProps) { + return ( + + Test4089 +