BBASearchTextField.h 3.69 KB
//
//  BBASearchTextField.h
//  BaiduBoxApp
//
//  Created by Haoyang XIN on 13/06/2017.
//  Copyright © 2017 Baidu. All rights reserved.
//

#import <BBAUIKit/BBATextField.h>

#define SearchTextFieldViewFrame			CGRectMake(0.f, 25, [BBACommonUIParams applicationFrameWidth], 49)
#define SearchTextFieldLeftLogoBaiduImage   [UIImage imageNamed:@"search_text_field_baidu_logo"]
#define SearchTextFieldLeftLogoFeedImage	SearchTextFieldLeftLogoBaiduImage

extern const CGFloat kBBASearchTextFieldRightViewMarginLeftSide;
extern const CGFloat kBBASearchTextFieldRightViewMarginRightSide;
extern const CGFloat kBBASearchTextFieldRightViewMarginRightBound;
extern const CGFloat kBBASearchTextFieldRightViewExtraImageOffset;

extern NSString *const BBARedPointShouldUpdateNotification;

typedef NS_OPTIONS(NSUInteger, TSearchTextFieldRightViewOption)
{
    ESearchTextFieldRightViewOptionNone                     = 0,
    ESearchTextFieldRightViewContentVoiceSearch             = 1 << 0,
    ESearchTextFieldRightViewContentImageSearch             = 1 << 1,
    ESearchTextFieldRightViewContentRefreshSearch           = 1 << 2,
//    ESearchTextFieldRightViewContentMoreMenu				= 1 << 2,
};

@protocol BBASearchBoxProtocol <NSObject>

@optional
/*!
 * @description 根据业务调用插件(插件需要一些业务相关的参数)并生成语音按钮实例.
 * @return 语音按钮的实例(Browser/首页组件使用)
 */
- (UIView *)generateVoiceButton;

/// 调起多模图搜插件,Browser/首页组件使用 是否需要"点击后去除飘新红点"的UBC打点
- (void)imageSearchButtonClicked:(id)sender needPoint:(BOOL)needPoint;
/// 调起更多按钮点击事件,Browser组件使用
- (void)moreMenuButtonClicked:(id)sender;
/// 调起刷新按钮点击事件,Browser组件使用
- (void)refreshButtonClicked:(id)sender;
/// 调起停止按钮点击事件,Browser组件使用
- (void)stopButtonClicked:(id)sender;

/// 激活搜索框.
- (void)activeTextField;

@end


@interface BBASearchTextField : BBATextField
/// 搜索框Delegate
@property (nonatomic, weak) id<BBASearchBoxProtocol> searchBoxDelegate;
/// 搜索框左侧图标
@property (nonatomic, strong, readonly) UIImageView *leftLogoImageView;
/// 搜索框图搜图标
@property (nonatomic, strong, readonly) UIButton *imageSearchButton;
/// 设置搜索框左侧图标
- (UIImageView *)setUpLeftLogoViewWithImage:(UIImage *)image;
/// 设置搜索框左侧logo
- (void)setLeftLogoWithImageURL:(NSString *)imageURL;
/// 移除搜索框左侧图标,首页组件使用
- (void)removeLeftLogoImage;

/**
 更新框图搜图标(适用于首页皮肤更改时)

 @param skinMode 是否在使用皮肤模式下
*/
- (void)updateSearchButtonImageInUISkinMode:(BOOL)skinMode;

/**
 初始化搜索框方法

 @param searchTextFieldViewRightViewOption 搜索框右侧视图类型
 @param rightMargin 右侧间距
 @param extraImageIconLeftPadding 左边填充距离
 @param shouldShowRedPoint 是否展示红点
 @return 搜索框
 */
- (UIView *)buildTextFieldRightViewWithOption:(TSearchTextFieldRightViewOption)searchTextFieldViewRightViewOption
								  rightMargin:(CGFloat)rightMargin
					extraImageIconLeftPadding:(CGFloat)extraImageIconLeftPadding
                           shouldShowRedPoint:(BOOL)shouldShowRedPoint;
/**
 初始化搜索框便捷方法

 @param searchTextFieldViewRightViewOption 搜索框右侧视图类型
 @param shouldShowRedPoint 是否展示红点
 @return 搜索框
 */
- (UIView *)buildTextFieldRightViewWithOption:(TSearchTextFieldRightViewOption)searchTextFieldViewRightViewOption
                           shouldShowRedPoint:(BOOL)shouldShowRedPoint;

/// 更新刷新按钮的状态
- (void)showRefreshBtn;
/// 显示停止加载按钮
- (void)showStopBtn;

@end