cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/QMUIComponents/QMUISearchController.h

146 lines
6.7 KiB
C
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// QMUISearchController.h
//
// Created by QMUI Team on 16/5/25.
//
#import <UIKit/UIKit.h>
#import "QMUICommonViewController.h"
#import "QMUICommonTableViewController.h"
@class QMUIEmptyView;
@class QMUISearchController;
/**
* QMUISearchController 使 protocol
*
* 1. searchController:updateResultsForSearchString: [searchController.tableView reloadData]
* 2. UITableView tableView delegatedataSource protocol
*/
@protocol QMUISearchControllerDelegate <QMUITableViewDataSource, QMUITableViewDelegate>
@required
/**
* `[tableView reloadData]`
* @warning ×searchString为@""UISearchController保持一致
*/
- (void)searchController:(QMUISearchController *)searchController updateResultsForSearchString:(NSString *)searchString;
@optional
- (void)willPresentSearchController:(QMUISearchController *)searchController;
- (void)didPresentSearchController:(QMUISearchController *)searchController;
- (void)willDismissSearchController:(QMUISearchController *)searchController;
- (void)didDismissSearchController:(QMUISearchController *)searchController;
- (void)searchController:(QMUISearchController *)searchController didLoadSearchResultsTableView:(UITableView *)tableView;
- (void)searchController:(QMUISearchController *)searchController willShowEmptyView:(QMUIEmptyView *)emptyView;
@end
/**
* launchView
* 使
* 1. 使 initWithContentsViewController:
* 2. searchBar 使 `tableHeaderView = searchController.searchBar`
* 3. searchResultsDelegate searchController:updateResultsForSearchString:
* 4. @c qmui_preferredStatusBarStyleBlock
*
* @note QMUICommonTableViewController QMUISearchController shouldShowSearchBar YES QMUISearchController
*/
@interface QMUISearchController : QMUICommonViewController<UISearchResultsUpdating, UISearchControllerDelegate>
/**
* UIViewController searchController style
* @param viewController viewController上添加搜索功能
*/
- (instancetype)initWithContentsViewController:(UIViewController *)viewController resultsTableViewStyle:(UITableViewStyle)resultsTableViewStyle;
/**
* UIViewController searchController
* @param viewController viewController上添加搜索功能
*/
- (instancetype)initWithContentsViewController:(UIViewController *)viewController;
@property(nonatomic, weak) id<QMUISearchControllerDelegate> searchResultsDelegate;
/// 搜索框
@property(nonatomic, strong, readonly) UISearchBar *searchBar;
/// 搜索结果列表
@property(nonatomic, strong, readonly) QMUITableView *tableView;
/// 在搜索文字为空时会展示的一个 view通常用于实现“最近搜索”之类的功能。launchView 最终会被布局为撑满搜索框以下的所有空间。
@property(nonatomic, strong) UIView *launchView;
/// 升起键盘时的半透明遮罩nil 表示用系统的,非 nil 则用自己的。默认为 nil。
/// @note 如果使用了 launchView 则该属性无效。
@property(nonatomic, strong) UIColor *dimmingColor;
/// 控制以无动画的形式进入/退出搜索状态
@property(nonatomic, assign, getter=isActive) BOOL active;
/**
* /退
* @param active YES NO 退
* @param animated
*/
- (void)setActive:(BOOL)active animated:(BOOL)animated;
/// 进入搜索状态时是否要把原界面的 navigationBar 推走,默认为 YES
@property(nonatomic, assign) BOOL hidesNavigationBarDuringPresentation;
@end
@interface QMUICommonTableViewController (Search) <QMUISearchControllerDelegate>
/**
* YES viewDidLoad searchBar tableHeaderView NO searchBar searchController
* NO
* @note viewDidLoad YES viewDidLoad
*/
@property(nonatomic, assign) BOOL shouldShowSearchBar;
/**
* searchController `shouldShowSearchBar` `YES`
*
* `nil`
*
* @see QMUITableViewDelegate
*/
@property(nonatomic, strong, readonly) QMUISearchController *searchController;
/**
* searchBar `shouldShowSearchBar` `YES`
*
* `nil`
*
* @see QMUITableViewDelegate
*/
@property(nonatomic, strong, readonly) UISearchBar *searchBar;
/**
*
*
* `NO`
*/
- (BOOL)shouldHideSearchBarWhenEmptyViewShowing;
/**
* searchController和searchBarinitSubViews的时候被自动调用
*
* `self.shouldShowSearchBar` `YES` searchBar `tableHeaderView` `NO` `tableHeaderView` nil
*
* @warning `self.shouldShowSearchBar` NO searchBar `YES`
*/
- (void)initSearchController;
@end