feat(ui): implement keyword highlighting and improve search experience
- Add keyword highlighting in `PostCard` and `PostContentRenderer` using `HighlightText`. - Implement smart excerpt logic in `PostCard` to show relevant context around search keywords. - Update `SearchBar` styles for better visual feedback and consistency. - Enhance `SearchScreen` with modern tab variants and improved tag styling. - Add support for updating group descriptions in `GroupInfoScreen` and `GroupService`. - Refactor various UI components for improved layout stability and typography.
This commit is contained in:
@@ -265,7 +265,7 @@ export const SearchScreen: React.FC<SearchScreenProps> = ({ onBack }) => {
|
||||
post={post}
|
||||
onAction={(action) => handlePostAction(post, action)}
|
||||
variant="list"
|
||||
features={isMobile ? 'compact' : 'full'}
|
||||
features="full"
|
||||
highlightKeyword={currentKeyword}
|
||||
/>
|
||||
))}
|
||||
@@ -288,7 +288,7 @@ export const SearchScreen: React.FC<SearchScreenProps> = ({ onBack }) => {
|
||||
post={item}
|
||||
onAction={(action) => handlePostAction(item, action)}
|
||||
variant="list"
|
||||
features="compact"
|
||||
features="full"
|
||||
highlightKeyword={currentKeyword}
|
||||
/>
|
||||
)}
|
||||
@@ -542,11 +542,12 @@ export const SearchScreen: React.FC<SearchScreenProps> = ({ onBack }) => {
|
||||
activeIndex={activeIndex}
|
||||
onTabChange={(index) => {
|
||||
setActiveIndex(index);
|
||||
// 如果已经搜索过,切换Tab时重新搜索
|
||||
if (currentKeyword && hasSearched) {
|
||||
performSearch(currentKeyword);
|
||||
}
|
||||
}}
|
||||
variant="modern"
|
||||
icons={['file-document-outline', 'account-outline']}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@@ -571,22 +572,12 @@ function createSearchScreenStyles(colors: AppColors) {
|
||||
},
|
||||
searchShell: {
|
||||
flex: 1,
|
||||
borderRadius: borderRadius.xl,
|
||||
backgroundColor: `${colors.primary.main}08`,
|
||||
paddingHorizontal: spacing.xs,
|
||||
paddingVertical: spacing.xs,
|
||||
// 移除阴影效果
|
||||
shadowColor: 'transparent',
|
||||
shadowOffset: { width: 0, height: 0 },
|
||||
shadowOpacity: 0,
|
||||
shadowRadius: 0,
|
||||
elevation: 0,
|
||||
},
|
||||
cancelButton: {
|
||||
backgroundColor: `${colors.primary.main}14`,
|
||||
backgroundColor: `${colors.primary.main}12`,
|
||||
borderRadius: borderRadius.full,
|
||||
paddingHorizontal: spacing.md,
|
||||
paddingVertical: spacing.xs,
|
||||
paddingVertical: spacing.sm,
|
||||
},
|
||||
cancelText: {
|
||||
fontSize: fontSizes.md,
|
||||
@@ -610,7 +601,7 @@ function createSearchScreenStyles(colors: AppColors) {
|
||||
marginBottom: spacing.sm,
|
||||
},
|
||||
sectionTitle: {
|
||||
fontWeight: '600',
|
||||
fontWeight: '700',
|
||||
color: colors.text.primary,
|
||||
},
|
||||
tagContainer: {
|
||||
@@ -620,13 +611,14 @@ function createSearchScreenStyles(colors: AppColors) {
|
||||
tag: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
backgroundColor: colors.background.paper,
|
||||
borderRadius: borderRadius.lg,
|
||||
borderWidth: 1,
|
||||
borderColor: colors.divider,
|
||||
backgroundColor: `${colors.primary.main}10`,
|
||||
borderRadius: borderRadius.full,
|
||||
borderWidth: 0,
|
||||
},
|
||||
tagText: {
|
||||
marginLeft: spacing.xs,
|
||||
color: colors.primary.main,
|
||||
fontWeight: '500',
|
||||
},
|
||||
userCard: {
|
||||
backgroundColor: colors.background.paper,
|
||||
|
||||
Reference in New Issue
Block a user