Няма описание

FKRecommendPageController.m 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. //
  2. // FKRecommendController.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/11/30.
  6. // Copyright © 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKRecommendPageController.h"
  9. #import "FKRecommendController.h"
  10. #import "FKRecommendRequest.h"
  11. #import "FKRecommendReform.h"
  12. #import "GuideViewController.h"
  13. #import "FKExploreKeywordController.h"
  14. #import "FKExploreListController.h"
  15. #import "FKEntireCategoryController.h"
  16. #import "FKMyBookController.h"
  17. #import <HMSegmentedControl/HMSegmentedControl.h>
  18. #import "FKGuideManager.h"
  19. #import "FLControllerHelper.h"
  20. #import "UserDefaultManager.h"
  21. #import "FKWindowViewManager.h"
  22. #import "FKRemoteConfigManager.h"
  23. #import "FKLaunchAnimation.h"
  24. #import "FLControllerHelper.h"
  25. #import "FKBrandEntryBtn.h"
  26. #import "FLImageHelper.h"
  27. #import "FKNavigtionCustomTitleView.h"
  28. @protocol FKUIScrollViewDelegate <NSObject>
  29. - (BOOL)fk_gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
  30. @end
  31. @interface FKUIScrollView : UIScrollView
  32. @property (nonatomic, weak) id <FKUIScrollViewDelegate> gestureDelegate;
  33. @end
  34. @implementation FKUIScrollView
  35. - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
  36. if ([self.delegate respondsToSelector:@selector(fk_gestureRecognizerShouldBegin:)]){
  37. return [self.gestureDelegate fk_gestureRecognizerShouldBegin:gestureRecognizer];
  38. }
  39. return YES;
  40. }
  41. @end
  42. static NSInteger const SEARCHBAR_NORMAL_STATE_LEFT_MARGIN = 60;
  43. static NSInteger const SEARCHBAR_NORMAL_STATE_RIGHT_MARGIN = 60;
  44. @interface FKRecommendPageController () <FLNetworkDelegate, UIScrollViewDelegate, UISearchBarDelegate>
  45. @property (nonatomic, strong) FKNavigtionCustomTitleView *searchBarContainer;
  46. @property (nonatomic, strong) UISearchBar *searchBar;
  47. @property (nonatomic, strong) UIImageView *searchIcon;
  48. @property (nonatomic, strong) UILabel *searchLabel;
  49. @property (nonatomic, strong) FKBrandEntryBtn *brandBtn;
  50. @property (nonatomic, strong) HMSegmentedControl *segmentedControl;
  51. @property (nonatomic, strong) UIImageView *segmentedBgImgView;
  52. @property (nonatomic, strong) FKUIScrollView *scrollView;
  53. @property (nonatomic, strong) FKRecommendController *recommendController;
  54. @property (nonatomic, strong) NSMutableArray *webviewControllers;
  55. @property (nonatomic, strong) FKRecommendPageViewModel *viewModel;
  56. @end
  57. @implementation FKRecommendPageController
  58. - (void)viewDidLoad {
  59. [super viewDidLoad];
  60. [self addAllSubviews];
  61. [self configErrorTipView];
  62. [self configBarButtonItem];
  63. [self configSegmentControl];
  64. [self requestPageTabData];
  65. }
  66. - (void)viewWillAppear:(BOOL)animated {
  67. [super viewWillAppear:animated];
  68. [self.navigationController setNavigationBarHidden:NO animated:YES];
  69. self.searchLabel.text = [FKRemoteConfigManager searchPlaceholder];
  70. [self configNaviBarAndTabBar];
  71. [self requestBookBrandInfo];
  72. [self setupNaviControllerBgImage];
  73. self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
  74. }
  75. - (void)viewWillDisappear:(BOOL)animated {
  76. [super viewWillDisappear:animated];
  77. self.navigationController.navigationBar.barStyle = UIStatusBarStyleDefault;
  78. [self cancelNaviControllerBgImage];
  79. }
  80. - (void)viewDidDisappear:(BOOL)animated {
  81. [super viewDidDisappear:animated];
  82. }
  83. - (void)viewDidAppear:(BOOL)animated {
  84. [super viewDidAppear:animated];
  85. // 请求当前是否有活动,App生命周期内最多跳转一次到活动页面
  86. BOOL needShowGuide = [FKGuideManager isNeedShowGuideController];
  87. if (!needShowGuide) {
  88. if ([FKLaunchAnimation isFinished]) {
  89. [self flushFloatViewManager];
  90. }
  91. [FKRecommendRequest requestActivityURL:REC_REQUEST_ACTIVITY_URL
  92. deleagate:self];
  93. }
  94. // 当Tab请求回来后,精选首页发生页面切换事件需要通知当前显示页面
  95. if (self.scrollView.contentOffset.x == 0) {
  96. if (self.viewModel.pageItemArray && [self.recommendController isKindOfClass:[UIViewController class]]) {
  97. [self.recommendController beginAppearanceTransition:YES animated:NO];
  98. [self.recommendController endAppearanceTransition];
  99. }
  100. }
  101. }
  102. //- (BOOL)fk_gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
  103. // FKRecommendCollectionViewCell * cell = (FKRecommendCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
  104. // if (![cell isKindOfClass:[FKRecommendCollectionViewCell class]]) return YES;
  105. //
  106. // CGPoint point = [gestureRecognizer locationInView:cell.recommendController.limitCell];
  107. // return !CGRectContainsPoint(cell.recommendController.limitCell.bounds, point);
  108. // return NO;
  109. //}
  110. #pragma mark - Request
  111. - (void)requestPageTabData {
  112. [self.statusView removeFromSuperview];
  113. [FKRecommendRequest requestTabPagesWithIdentify:REC_TAB_PAGE_REQ delegate:self];
  114. }
  115. - (void)requestBookBrandInfo {
  116. if ([FKUserManager isUserLogin]) {
  117. NSString *lastTime = [[NSUserDefaults standardUserDefaults] objectForKey:FK_BOOK_BRAND_SERVER_TIME_KEY];
  118. [FKRecommendRequest requestBookInfoWithServeTime:lastTime
  119. identify:REC_BOOK_BRAND_INFO
  120. deleagate:self];
  121. }
  122. }
  123. #pragma mark - response
  124. - (void)networkDidReceiveError:(NSError *)error identify:(int)identify header:(MSGHeader *)header{
  125. [self showSystemErrorTipInView:self.view];
  126. }
  127. - (void)networkDidSuccessResponse:(NSDictionary *)response identify:(int)identify header:(MSGHeader *)header {
  128. if (header.code.intValue == RESPONSE_MSG_NORMAL) {
  129. if (identify == REC_TAB_PAGE_REQ) {
  130. self.viewModel = [FKRecommendReform parserPageViewModelWithDict:response];
  131. self.segmentedBgImgView.hidden = NO;
  132. self.segmentedControl.sectionTitles = self.viewModel.sectionTitlesArray;
  133. [self.segmentedControl setNeedsDisplay];
  134. [self addRecommendController];
  135. } else if (identify == REC_REQUEST_ACTIVITY_URL) {
  136. NSString *url = [FKRecommendReform parserH5Url:response];
  137. if ([self shouldPushWebViewController:url]) {
  138. [self pushWebViewController:url];
  139. [[UserDefaultManager sharedManager] setUserDefaultObject:url key:LAST_ACTIVITY_URL_KEY];
  140. }
  141. return;
  142. } else if (identify == REC_BOOK_BRAND_INFO){
  143. BOOL hasInfo = [FKRecommendReform parserHasBookInfoWithDict:response];
  144. self.brandBtn.redPoint.hidden = !hasInfo;
  145. }
  146. } else {
  147. [self showSystemErrorTipInView:self.view];
  148. }
  149. }
  150. - (BOOL)shouldPushWebViewController:(NSString *)urlString {
  151. NSString *lastActivityURL = [[UserDefaultManager sharedManager] getUserDefaultObject:LAST_ACTIVITY_URL_KEY];
  152. if (urlString.length > 0 && ![urlString isEqualToString:lastActivityURL]) {
  153. return YES;
  154. }
  155. return NO;
  156. }
  157. - (void)pushWebViewController:(NSString *)urlString {
  158. WebViewController *newViewController = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:@"WebViewController"];
  159. newViewController.url = urlString;
  160. newViewController.hidesBottomBarWhenPushed = YES;
  161. [self.navigationController pushViewController:newViewController animated:YES];
  162. }
  163. #pragma mark - UISearchBarDelegate
  164. - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
  165. WeakSelf(weakSelf);
  166. FKExploreKeywordController *controller = [[FKExploreKeywordController alloc] initWithKeyword:nil type:FKExploreControllerTypeRemoteKeyword];
  167. controller.executeSearchHandler = ^(FKExploreConditionType type, NSString *itemID, NSString *keyword) {
  168. if (keyword.length > 0) {
  169. FKExploreListController *listController = [[FKExploreListController alloc] initWithSource:FKExploreListSourceKeyword];
  170. if (type == FKExploreConditionTypeKeyword) {
  171. NSArray *keywords = [keyword componentsSeparatedByString:@" "];
  172. for (NSString *value in keywords) {
  173. [listController.conditionManager addConditionWithType:FKExploreConditionTypeKeyword
  174. itemID:nil
  175. value:value];
  176. }
  177. [[FKPageRouterUtil sharedInstance] pushPageRefer:PRPageSearchKeyword values:@[keyword]];
  178. } else if (type == FKExploreConditionTypeBrand) {
  179. [listController.conditionManager addConditionWithType:FKExploreConditionTypeBrand
  180. itemID:nil
  181. value:keyword];
  182. [[FKPageRouterUtil sharedInstance] pushPageRefer:PRPageSearchKeyword values:@[keyword]];
  183. }
  184. listController.hidesBottomBarWhenPushed = YES;
  185. [weakSelf.navigationController pushViewController:listController animated:YES];
  186. }
  187. };
  188. [self.navigationController presentViewController:controller
  189. animated:NO
  190. completion:^{}];
  191. return NO;
  192. }
  193. #pragma mark - UIScrollViewDelegate
  194. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  195. [self addWebController];
  196. }
  197. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  198. CGFloat offsetX = scrollView.contentOffset.x;
  199. int index = (int)((offsetX + 1)/UISCREENWIDTH);
  200. [self.segmentedControl setSelectedSegmentIndex:index animated:YES];
  201. [self enableScrollToTopAtIndex:index];
  202. }
  203. #pragma mark - Action
  204. - (void)configSegmentControl {
  205. WeakSelf(weakSelf);
  206. self.segmentedControl.indexChangeBlock = ^(NSInteger index) {
  207. if (index < (weakSelf.viewModel.pageItemArray.count + 1)) {
  208. [weakSelf addWebController];
  209. [weakSelf.scrollView setContentOffset:CGPointMake(UISCREENWIDTH*index, 0) animated:YES];
  210. [weakSelf enableScrollToTopAtIndex:index];
  211. }
  212. };
  213. }
  214. - (void)configErrorTipView {
  215. [self.statusView.actionButton addTarget:self action:@selector(requestPageTabData) forControlEvents:UIControlEventTouchUpInside];
  216. }
  217. - (void)pushEntireCategoryController {
  218. FKEntireCategoryController *controller = [[FKEntireCategoryController alloc] init];
  219. controller.hidesBottomBarWhenPushed = YES;
  220. controller.isShowLeftBarItem = YES;
  221. [self.navigationController pushViewController:controller animated:YES];
  222. }
  223. - (void)clickBrandEntryBtn {
  224. if (![FKUserManager isUserLogin]){
  225. [self showLoginActionMenu];
  226. return;
  227. }
  228. FKMyBookController *book = [[FKMyBookController alloc]init];
  229. book.hidesBottomBarWhenPushed = YES;
  230. [self.navigationController pushViewController:book animated:YES];
  231. }
  232. #pragma mark - method
  233. - (void)addAllSubviews {
  234. self.searchBarContainer.frame = CGRectMake(SEARCHBAR_NORMAL_STATE_LEFT_MARGIN
  235. ,6
  236. ,(UISCREENWIDTH - SEARCHBAR_NORMAL_STATE_LEFT_MARGIN - SEARCHBAR_NORMAL_STATE_RIGHT_MARGIN)
  237. ,32);
  238. self.searchBarContainer.backgroundColor = [UIColor colorWithWhite:1 alpha:0.39];
  239. self.navigationItem.titleView = self.searchBarContainer;
  240. [self.searchBarContainer addSubview:self.searchLabel];
  241. [self.searchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  242. make.centerY.equalTo(self.searchBarContainer);
  243. make.centerX.equalTo(self.searchBarContainer).offset(8);
  244. }];
  245. [self.searchBarContainer addSubview:self.searchIcon];
  246. [self.searchIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  247. make.right.equalTo(self.searchLabel.mas_left).offset(-4);
  248. make.centerY.equalTo(self.searchBarContainer);
  249. make.size.mas_equalTo(CGSizeMake(15, 15));
  250. }];
  251. [self.view addSubview:self.segmentedBgImgView];
  252. [self.segmentedBgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  253. make.left.right.equalTo(self.view);
  254. make.top.equalTo(self.view);
  255. make.height.mas_equalTo(44);
  256. }];
  257. [self.view addSubview:self.segmentedControl];
  258. [self.segmentedControl mas_makeConstraints:^(MASConstraintMaker *make) {
  259. make.edges.equalTo(self.segmentedBgImgView);
  260. }];
  261. CGFloat height = (UISCREENHEIGH - 44
  262. - CGRectGetHeight([UIApplication sharedApplication].statusBarFrame)
  263. - CGRectGetHeight(self.navigationController.navigationBar.frame)
  264. - CGRectGetHeight(self.tabBarController.tabBar.frame));
  265. self.scrollView.frame = CGRectMake(0, 44, UISCREENWIDTH, height);
  266. self.scrollView.contentSize = CGSizeMake(UISCREENWIDTH, height);
  267. [self.view addSubview:self.scrollView];
  268. }
  269. - (void)addRecommendController {
  270. if (_recommendController == nil) {
  271. WeakSelf(weakSelf);
  272. self.recommendController.view.frame = CGRectMake(0, 0, UISCREENWIDTH, CGRectGetHeight(self.scrollView.frame));
  273. self.recommendController.handlePageRefreshEvent = ^() {
  274. [weakSelf removeWebController];
  275. [weakSelf requestPageTabData];
  276. };
  277. [self.scrollView addSubview:self.recommendController.view];
  278. }
  279. self.scrollView.contentSize = CGSizeMake(UISCREENWIDTH*2, CGRectGetHeight(self.scrollView.frame));
  280. }
  281. - (void)removeWebController {
  282. [self.scrollView.subviews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
  283. if (idx != 0) {
  284. [obj performSelector:@selector(removeFromSuperview)];
  285. }
  286. }];
  287. [self.webviewControllers removeAllObjects];
  288. }
  289. - (void)addWebController {
  290. if (self.scrollView.subviews.count < (self.viewModel.pageItemArray.count + 1)) {
  291. FKRecommendPageItem *pageItem;
  292. WebViewController *webviewController;
  293. for (int idx = 0; idx < self.viewModel.pageItemArray.count; idx++) {
  294. pageItem = [self.viewModel pageItemAtIndex:idx];
  295. webviewController = [[WebViewController alloc] init];
  296. webviewController.url = pageItem.targetUrl;
  297. webviewController.view.frame = CGRectMake(UISCREENWIDTH*(idx+1), 0, UISCREENWIDTH, CGRectGetHeight(self.scrollView.frame));
  298. [self.scrollView addSubview:webviewController.view];
  299. [self.webviewControllers addObject:webviewController];
  300. }
  301. self.scrollView.contentSize = CGSizeMake(UISCREENWIDTH*(self.viewModel.pageItemArray.count + 1), CGRectGetHeight(self.scrollView.frame));
  302. }
  303. }
  304. - (void)hideDefaultLeftNaviItem {
  305. self.navigationItem.leftBarButtonItem = nil;
  306. }
  307. - (void)configNaviBarAndTabBar {
  308. [self.tabBarController.tabBar setHidden:NO];
  309. [UIApplication sharedApplication].statusBarHidden = NO;
  310. [self.navigationController setNavigationBarHidden:NO animated:YES];
  311. self.navigationController.navigationBar.barStyle = UIStatusBarStyleDefault;
  312. }
  313. - (void)configBarButtonItem {
  314. UIImage *leftImage = [[UIImage imageNamed:@"EntireCategoryIcon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  315. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:leftImage
  316. style:UIBarButtonItemStylePlain
  317. target:self
  318. action:@selector(pushEntireCategoryController)];
  319. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.brandBtn];
  320. [[self.brandBtn.widthAnchor constraintEqualToConstant:35] setActive:YES];
  321. [[self.brandBtn.heightAnchor constraintEqualToConstant:44] setActive:YES];
  322. }
  323. // 点击Statusbar置顶
  324. - (void)enableScrollToTopAtIndex:(NSInteger)index{
  325. if (index < 0) return;
  326. self.recommendController.tableView.scrollsToTop = NO;
  327. for (WebViewController *web in self.webviewControllers) {
  328. if ([web isKindOfClass:[WebViewController class]]){
  329. web.webview.scrollView.scrollsToTop = NO;
  330. }
  331. }
  332. if (index == 0) {
  333. self.recommendController.tableView.scrollsToTop = YES;
  334. }else if (index - 1 < self.webviewControllers.count){
  335. WebViewController *web = self.webviewControllers[index - 1];
  336. if ([web isKindOfClass:[WebViewController class]]){
  337. web.webview.scrollView.scrollsToTop = YES;
  338. }
  339. }
  340. FKRecommendPageItem *item = [self.viewModel pageItemAtIndex:index];
  341. if (item) {
  342. [FKRecommendRequest requestBehavior:@"index_menu"
  343. objType:@"menu"
  344. objID:item.pageID
  345. positionV1:[NSString stringWithFormat:@"%ld", (long)index]
  346. positionV2:nil];
  347. }
  348. }
  349. - (void)flushFloatViewManager {
  350. [[FKWindowViewManager sharedManager] showFloatView:nil];
  351. }
  352. - (void)setupNaviControllerBgImage {
  353. UIImage *image = [UIImage imageNamed:@"navigationcontrollerbgicon"];
  354. UIImage *bgImage = [FLImageHelper generateThumbnailFromBottom:image frame:CGSizeMake(UISCREENWIDTH, IS_IPHONE_X ? 88 : 64)];
  355. [self.navigationController.navigationBar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
  356. }
  357. - (void)cancelNaviControllerBgImage {
  358. [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  359. }
  360. #pragma mark - property
  361. - (FKNavigtionCustomTitleView *)searchBarContainer {
  362. if (!_searchBarContainer) {
  363. _searchBarContainer = [FKNavigtionCustomTitleView new];
  364. _searchBarContainer.layer.cornerRadius = 6;
  365. _searchBarContainer.clipsToBounds = YES;
  366. _searchBarContainer.backgroundColor = [UIColor clearColor];//UIColorFromRGB(0xf1f1f1);
  367. _searchBarContainer.userInteractionEnabled = YES;
  368. [_searchBarContainer addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(searchBarShouldBeginEditing:)]];
  369. }
  370. return _searchBarContainer;
  371. }
  372. - (UISearchBar *)searchBar {
  373. if (!_searchBar) {
  374. _searchBar = [UISearchBar new];
  375. _searchBar.delegate = self;
  376. _searchBar.returnKeyType = UIReturnKeyDone;
  377. _searchBar.searchBarStyle = UISearchBarStyleMinimal;
  378. _searchBar.backgroundColor = [UIColor clearColor];//UIColorFromRGB(0xf1f1f1);
  379. // [_searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"SearchBarBackground"] forState:UIControlStateNormal];
  380. }
  381. return _searchBar;
  382. }
  383. - (UIImageView *)searchIcon {
  384. if (!_searchIcon) {
  385. _searchIcon = [UIImageView new];
  386. _searchIcon.image = [UIImage imageNamed:@"searchBarIcon"];
  387. }
  388. return _searchIcon;
  389. }
  390. - (UILabel *)searchLabel {
  391. if (!_searchLabel) {
  392. _searchLabel = [[UILabel alloc] init];
  393. _searchLabel.textAlignment = NSTextAlignmentCenter;
  394. _searchLabel.textColor = UIColorFromRGB(0xffffff);
  395. _searchLabel.font = [UIFont systemFontOfSize:13];
  396. }
  397. return _searchLabel;
  398. }
  399. - (HMSegmentedControl *)segmentedControl {
  400. if (!_segmentedControl) {
  401. _segmentedControl = [HMSegmentedControl new];
  402. _segmentedControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
  403. _segmentedControl.selectionIndicatorHeight = 2;
  404. _segmentedControl.segmentEdgeInset = UIEdgeInsetsMake(0, 15, -8, 15);
  405. _segmentedControl.selectionIndicatorEdgeInsets = UIEdgeInsetsMake(0, 15, -8, 15);
  406. _segmentedControl.selectionIndicatorColor = UIColorFromRGB(0xffc66e);
  407. _segmentedControl.selectionStyle = HMSegmentedControlSelectionStyleTextWidthStripe;
  408. _segmentedControl.selectedTitleTextAttributes = @{NSForegroundColorAttributeName : UIColorFromRGB(0xffc66e),
  409. NSFontAttributeName : [UIFont systemFontOfSize:15]};
  410. _segmentedControl.titleTextAttributes = @{NSForegroundColorAttributeName : UIColorFromRGB(0xffffff),
  411. NSFontAttributeName : [UIFont systemFontOfSize:15]};
  412. // _segmentedControl.borderType = HMSegmentedControlBorderTypeBottom;
  413. // _segmentedControl.borderColor = UIColorFromRGB(0xe5e5e5);
  414. // _segmentedControl.borderWidth = 0.5;
  415. _segmentedControl.backgroundColor = [UIColor clearColor];
  416. _segmentedControl.type = HMSegmentedControlTypeText;
  417. _segmentedControl.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleDynamic;
  418. }
  419. return _segmentedControl;
  420. }
  421. - (UIImageView *)segmentedBgImgView {
  422. if (!_segmentedBgImgView) {
  423. _segmentedBgImgView = [UIImageView new];
  424. UIImage *image = [UIImage imageNamed:@"segmentedcontrollerbgicon"];
  425. UIImage *bgImage = [FLImageHelper generateThumbnailFromTop:image frame:CGSizeMake(UISCREENWIDTH, 44)];
  426. _segmentedBgImgView.image = bgImage;
  427. _segmentedBgImgView.hidden = YES;
  428. }
  429. return _segmentedBgImgView;
  430. }
  431. - (FKUIScrollView *)scrollView{
  432. if (_scrollView == nil) {
  433. _scrollView = [[FKUIScrollView alloc] init];
  434. _scrollView.pagingEnabled = YES;
  435. _scrollView.delegate = self;
  436. _scrollView.showsHorizontalScrollIndicator = NO;
  437. _scrollView.showsVerticalScrollIndicator = NO;
  438. _scrollView.translatesAutoresizingMaskIntoConstraints = NO;
  439. _scrollView.scrollsToTop = NO;
  440. if (@available(iOS 11.0, *)) {
  441. _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  442. }
  443. }
  444. return _scrollView;
  445. }
  446. - (FKRecommendController *)recommendController {
  447. if (!_recommendController) {
  448. _recommendController = [FKRecommendController new];
  449. }
  450. return _recommendController;
  451. }
  452. - (NSMutableArray *)webviewControllers {
  453. if (!_webviewControllers) {
  454. _webviewControllers = [NSMutableArray array];
  455. }
  456. return _webviewControllers;
  457. }
  458. - (FKRecommendPageViewModel *)viewModel{
  459. if (!_viewModel) {
  460. _viewModel = [[FKRecommendPageViewModel alloc]init];
  461. }
  462. return _viewModel;
  463. }
  464. - (FKBrandEntryBtn *)brandBtn {
  465. if (_brandBtn == nil) {
  466. _brandBtn = [[FKBrandEntryBtn alloc]initWithFrame:CGRectMake(0, 0, 35, 44)];
  467. [_brandBtn addTarget:self action:@selector(clickBrandEntryBtn) forControlEvents:UIControlEventTouchUpInside];
  468. }
  469. return _brandBtn;
  470. }
  471. @end