Skip to content

Commit

Permalink
[KAN-145] 검색 > 자동완성 highlight 처리 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok authored Jun 1, 2024
1 parent de3c96e commit 668919d
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 668919d

Please sign in to comment.