From 85012eab784dfa01554a748f4ce9eb9ed05b98be Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Wed, 17 Dec 2025 20:37:53 +0800 Subject: [PATCH] 2 --- keyBoard/Class/Search/VC/KBSearchResultVC.m | 12 ++++++++++++ keyBoard/Class/Search/VC/KBSearchVC.m | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/keyBoard/Class/Search/VC/KBSearchResultVC.m b/keyBoard/Class/Search/VC/KBSearchResultVC.m index ce82611..a8934e7 100644 --- a/keyBoard/Class/Search/VC/KBSearchResultVC.m +++ b/keyBoard/Class/Search/VC/KBSearchResultVC.m @@ -8,6 +8,7 @@ #import "KBSkinCardCell.h" #import "KBSearchVM.h" #import "KBSearchThemeModel.h" +#import "KBSkinDetailVC.h" static NSString * const kResultCellId = @"KBSkinCardCell"; @@ -113,6 +114,17 @@ static NSString * const kResultCellId = @"KBSkinCardCell"; return cell; } +#pragma mark - UICollectionViewDelegate + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + KBSearchThemeModel *model = self.resultItems[indexPath.item]; + NSString *themeId = [model.themeId stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if (themeId.length == 0) { return; } + KBSkinDetailVC *vc = [[KBSkinDetailVC alloc] init]; + vc.themeId = themeId; + [self.navigationController pushViewController:vc animated:YES]; +} + #pragma mark - UICollectionViewDelegateFlowLayout - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { diff --git a/keyBoard/Class/Search/VC/KBSearchVC.m b/keyBoard/Class/Search/VC/KBSearchVC.m index c015bec..a95a0b0 100644 --- a/keyBoard/Class/Search/VC/KBSearchVC.m +++ b/keyBoard/Class/Search/VC/KBSearchVC.m @@ -15,6 +15,7 @@ #import "UICollectionViewLeftAlignedLayout.h" #import "KBSearchVM.h" #import "KBShopThemeModel.h" +#import "KBSkinDetailVC.h" static NSString * const kTagCellId = @"KBTagCell"; @@ -137,6 +138,15 @@ typedef NS_ENUM(NSInteger, KBSearchSection) { [self.navigationController pushViewController:vc animated:YES]; } +/// 打开皮肤详情页 +- (void)openDetailForThemeId:(NSString *)themeId { + NSString *trim = [themeId stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if (trim.length == 0) { return; } + KBSkinDetailVC *vc = [[KBSkinDetailVC alloc] init]; + vc.themeId = trim; + [self.navigationController pushViewController:vc animated:YES]; +} + /// 计算“最多两行展示”的历史数据,若超出则在第二行尾部添加一个“更多”按钮(向下箭头)。 - (NSArray *)currentDisplayHistory { if (self.historyExpanded) { return self.historyWords; } @@ -367,6 +377,11 @@ typedef NS_ENUM(NSInteger, KBSearchSection) { [self performSearch:kw]; [self openResultForKeyword:kw]; } + return; + } + if (indexPath.section == KBSearchSectionRecommend) { + KBShopThemeModel *model = self.recommendedThemes[indexPath.item]; + [self openDetailForThemeId:model.themeId ?: @""]; } }