Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KAN-145] 검색 > 자동완성 highlight 처리 #54

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/screens/detail/SearchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ import AppContext from '../../components/AppContext';

const windowWidth = Dimensions.get('window').width;

const parseHighlightedText = (text) => {
const parts = text.split(/(<strong>|<\/strong>)/g);
return parts.map((part, index) => {
if (part === '<strong>') return <Text key={index} style={{ fontFamily: 'NanumSquareRoundEB' }}>{parts[index + 1]}</Text>;
if (part === '</strong>') return null;
if (parts[index - 1] === '<strong>') return null;
return <Text key={index}>{part}</Text>;
});
};


export default function SearchScreen(props) {
const navigation = useNavigation();
const context = useContext(AppContext);
Expand Down Expand Up @@ -251,7 +262,7 @@ export default function SearchScreen(props) {
navigation.goBack();
}}>
<SvgXml xml={svgXml.icon.search} width="18" height="18" />
<Text style={styles.buttonText}>{item.org_display}</Text>
<Text style={styles.buttonText}>{parseHighlightedText(item.highlighted_display)}</Text>
<View style={{flex: 1}} />
<Text style={styles.categoryText}>{item.category}</Text>
</AnimatedButton>
Expand Down
Loading