//
|
// PBPanoramaListViewController.m
|
// IphoneBIMe
|
//
|
// Created by ZhangJF on 2022/10/18.
|
// Copyright © 2022 ProBIM. All rights reserved.
|
//
|
|
#import "PBPanoramaListViewController.h"
|
#import "PBAddPanoramaViewController.h"
|
#import "PBDropdownMenu.h"
|
|
@interface PBPanoramaListViewController ()<PBDropdownMenuDelegate, UISearchBarDelegate, UITextFieldDelegate>
|
|
@end
|
|
@implementation PBPanoramaListViewController
|
|
- (void)viewWillAppear:(BOOL)animated {
|
[super viewWillAppear:animated];
|
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
|
}
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
[self setupNav];
|
[self loadTags];
|
[self.tableView.mj_header beginRefreshing];
|
}
|
- (void)setupNav {
|
self.title = self.projectModel.fullname;
|
PBBackNavItem *backNav = [PBBackNavItem backNacItem];
|
backNav.title = @" ";
|
[backNav addTarget:self action:@selector(backItemAction) forControlEvents:UIControlEventTouchUpInside];
|
UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithCustomView:backNav];
|
self.navigationItem.leftBarButtonItem = backNavItem;
|
UIBarButtonItem *addIssueItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Issue_list_add"] style:UIBarButtonItemStylePlain target:self action:@selector(addPanorama)];
|
self.navigationItem.rightBarButtonItem = addIssueItem;
|
}
|
- (void)addPanorama {
|
PBAddPanoramaViewController *addPanoramaVC = [[PBAddPanoramaViewController alloc] init];
|
addPanoramaVC.projectModel = self.projectModel;
|
addPanoramaVC.tagList = self.tagList;
|
addPanoramaVC.SaveSuccessBlock = ^{
|
[self.tableView.mj_header beginRefreshing];
|
};
|
[self.navigationController pushViewController:addPanoramaVC animated:YES];
|
}
|
- (void)backItemAction {
|
[self.navigationController popViewControllerAnimated:YES];
|
}
|
- (void)loadTags {
|
[[PBNetworkTools sharedTools] GetLabelListWithOrganizeId:self.projectModel.organizeid AndCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
|
if (error) {
|
[YJProgressHUD showFailed:@"加载标签失败" inview:self.view];
|
return;
|
}
|
NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
|
PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
|
if (networkModel.Ret == 1){
|
self.tagList = networkModel.Data;
|
NSMutableArray *statusArrM = [[NSMutableArray alloc] init];
|
for (NSDictionary *obj in networkModel.Data) {
|
PBIssueNavModel *issueNavModel = [[PBIssueNavModel alloc] init];
|
issueNavModel.ItemName = [obj valueForKey:@"LabelName"];
|
issueNavModel.ItemDetailId = [obj valueForKey:@"LabelId"];
|
[statusArrM addObject:issueNavModel];
|
}
|
PBIssueNavModel *issueNavModel1 = [[PBIssueNavModel alloc] init];
|
issueNavModel1.ItemName = @"全部";
|
issueNavModel1.ItemDetailId = @"";
|
[statusArrM insertObject:issueNavModel1 atIndex:0];
|
[self.dropdownMenuArrM addObject:statusArrM];
|
[self setupDropdownMenuView];
|
[self.tableView.mj_header beginRefreshing];
|
}else {
|
[YJProgressHUD showMessage:@"加载列表失败" inView:self.view];
|
}
|
}];
|
}
|
- (void)setupDropdownMenuView {
|
float dropdownMenuW = MainScreenWidth / (self.dropdownMenuArrM.count + 1);
|
PBDropdownMenu *dropdownMenu = [[PBDropdownMenu alloc] initWithFrame:CGRectMake(0, 0, self.dropdownMenuArrM.count * dropdownMenuW, 40) andArr:self.dropdownMenuArrM];
|
dropdownMenu.delegate = self;
|
[self.view addSubview:dropdownMenu];
|
|
UITextField *searchTF = [[UITextField alloc] initWithFrame:CGRectMake(dropdownMenuW * self.dropdownMenuArrM.count, 0, dropdownMenuW, 40)];
|
searchTF.placeholder = @"查找全景图";
|
searchTF.textAlignment= NSTextAlignmentLeft;
|
searchTF.clearButtonMode = UITextFieldViewModeAlways;
|
searchTF.textColor = TitleColor;
|
searchTF.font = [UIFont fontWithName:Conventional size:16.0];
|
searchTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
|
searchTF.delegate = self;
|
searchTF.returnKeyType=UIReturnKeySearch;
|
searchTF.backgroundColor = PBColor(242, 242, 242);
|
searchTF.leftViewMode = UITextFieldViewModeAlways;
|
UIImageView *leftImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 13, 15, 15)];
|
leftImageV.image = [UIImage imageNamed:@"searchTF"];
|
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)];
|
[leftView addSubview:leftImageV];
|
searchTF.leftView = leftView;
|
[self.view addSubview:searchTF];
|
}
|
#pragma mark - PBDropdownMenuDelegate
|
- (void)dropdownMenu:(UIButton *)clickBtn selectedCellNumber:(NSInteger)number {
|
NSInteger index = clickBtn.tag -100;
|
switch (index) {
|
case 0:
|
self.statusSelectIndex = number;
|
[self.tableView.mj_header beginRefreshing];
|
break;
|
default:
|
break;
|
}
|
}
|
|
#pragma mark - UITextFieldDelegate
|
- (BOOL)textFieldShouldClear:(UITextField *)textField {
|
[textField performSelector: @selector(resignFirstResponder)
|
withObject: nil
|
afterDelay: 0];
|
self.searchText = @"";
|
[self.tableView.mj_header beginRefreshing];
|
return YES;
|
}
|
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
|
self.searchText = textField.text;
|
[textField resignFirstResponder];
|
[self.tableView.mj_header beginRefreshing];
|
return YES;
|
}
|
|
/*
|
#pragma mark - Navigation
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
// Get the new view controller using [segue destinationViewController].
|
// Pass the selected object to the new view controller.
|
}
|
*/
|
|
@end
|