zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
//  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