JLChen
2021-10-28 e96683081abd5c1a94608dd33d092d8f45371cd6
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
//  Copyright © 2019 dahua. All rights reserved.
//
 
#import "LCAccountJointViewController.h"
#import "LCSegmentController.h"
#import "LCInputTextField.h"
#import "LCLivePreviewViewController.h"
#import "LCAccountPresenter.h"
#import "LCUIKit.h"
 
@interface LCAccountJointViewController ()
 
/// API HOST
@property (strong, nonatomic) LCInputTextField *apiHost;
 
/// APPID
@property (strong, nonatomic) LCInputTextField *appID;
 
/// APPSecret
@property (strong, nonatomic) LCInputTextField *appSecret;
 
/// titleLab
@property (strong, nonatomic) UILabel *titleLab;
 
/// presenter
@property (strong, nonatomic) LCAccountPresenter *present;
 
/// lab
@property (strong, nonatomic) UILabel *lab;
 
/// bottomBtn
@property (strong, nonatomic) UIButton *bottomBtn;
 
@end
 
@implementation LCAccountJointViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self lcCreatNavigationBarWith:LCNAVIGATION_STYLE_CLEARWITHLINE buttonClickBlock:nil];
    [LCApplicationDataManager setCurrentMode:0];
    UIViewController *vc = [UIViewController new];
    vc.view.backgroundColor = UIColor.yellowColor;
    [self drawSegment];
    [self setUpView];
    [self fixlayoutConstant:self.view];
}
 
- (LCAccountPresenter *)present {
    if (!_present) {
        _present = [LCAccountPresenter new];
        _present.container = self;
    }
    return _present;
}
 
- (void)drawSegment {
    LCSegmentController *segment = [LCSegmentController segmentWithFrame:CGRectMake(0,kStatusBarHeight, 150, 30) DefaultSelect:0 Items:@[@"Choose_Plantform_PageControl_Inland".lc_T,@"Choose_Plantform_PageControl_Oversea".lc_T] SelectedBlock:^(NSUInteger index) {
        [LCApplicationDataManager setCurrentMode:index];
        if (index == 0) {
            //选择国内
            self.titleLab.text = @"Choose_Plantform_Injoint_Inland".lc_T;
            self.lab.text = @"Choose_Plantform_Alert".lc_T;
        } else {
            //选择国海外
            self.titleLab.text = @"Choose_Plantform_Injoint_Oversea".lc_T;
            self.lab.text = @"Choose_Plantform_Alert_oversea".lc_T;
        }
        self.apiHost.textField.text = [LCApplicationDataManager hostApi];
        self.appID.textField.text = [LCApplicationDataManager appId];
        self.appSecret.textField.text = [LCApplicationDataManager appSecret];
    }];
    [self.view addSubview:segment];
    segment.center = CGPointMake(SCREEN_WIDTH/2.0, segment.center.y);
}
 
- (void)setUpView {
    weakSelf(self);
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viewTap:)];
    [self.view addGestureRecognizer:tap];
    
    UILabel *titleLab = [[UILabel alloc]init];
    NSLog(@"%f",kNavBarAndStatusBarHeight);
    titleLab.text = @"Choose_Plantform_Injoint_Inland".lc_T;
    titleLab.textColor = [UIColor blackColor];
    titleLab.font = [UIFont lcFont_t1];
    [self.view addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).offset(15);
        make.top.mas_equalTo(kNavBarAndStatusBarHeight + 15);
    }];
    self.titleLab = titleLab;
    
    LCInputTextField *apiHost = [LCInputTextField creatTextFieldWithResult:^(NSString * _Nonnull result) {
        
    }];
    self.apiHost = apiHost;
    [self.view addSubview:apiHost];
    apiHost.titleLable.text = @"Choose_Plantform_Host_Api".lc_T;
    apiHost.textField.text = [LCApplicationDataManager hostApi];
    apiHost.textField.keyboardType = UIKeyboardTypeURL;
    [apiHost updateFocusIfNeeded];
    [apiHost mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(titleLab.mas_bottom).offset(25);
        make.left.mas_equalTo(titleLab);
        make.right.mas_equalTo(self.view).offset(-15);
    }];
    
    LCInputTextField *appID = [LCInputTextField creatTextFieldWithResult:^(NSString * _Nonnull result) {
        
    }];
    self.appID = appID;
    [self.view addSubview:appID];
    [appID.textField becomeFirstResponder];
    appID.titleLable.text = @"Choose_Plantform_APPID".lc_T;
    appID.textField.text = [LCApplicationDataManager appId];
    appID.textField.placeholder =  @"Choose_Plantform_APPID_Placeholder".lc_T;
    [appID updateFocusIfNeeded];
    [appID mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(apiHost.mas_bottom).offset(15);
        make.left.mas_equalTo(titleLab);
        make.right.mas_equalTo(self.view).offset(-15);
    }];
    
    LCInputTextField *appSecret = [LCInputTextField creatTextFieldWithResult:^(NSString * _Nonnull result) {
    
    }];
    self.appSecret = appSecret;
    [self.view addSubview:appSecret];
    appSecret.titleLable.text = @"Choose_Plantform_APPSecret".lc_T;
    appSecret.textField.text = [LCApplicationDataManager appSecret];
    appSecret.textField.placeholder = @"Choose_Plantform_APPSecret_Placeholder".lc_T;
    [appSecret updateFocusIfNeeded];
    [appSecret mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(appID.mas_bottom).offset(15);
        make.left.mas_equalTo(titleLab);
        make.right.mas_equalTo(self.view).offset(-15);
    }];
    
    
    LCButton *confirmBtn = [LCButton lcButtonWithType:LCButtonTypePrimary];
    [confirmBtn setTitle:@"Button_Confirm".lc_T forState:UIControlStateNormal];
    confirmBtn.tag = 1000;
    [self.view addSubview:confirmBtn];
    [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_lessThanOrEqualTo(appSecret.mas_bottom).offset(50);
    }];
    confirmBtn.touchUpInsideblock = ^(LCButton * _Nonnull btn) {
        weakself.present.appSecret= appSecret.textField.text;
        weakself.present.appId= appID.textField.text;
        weakself.present.hostApi= apiHost.textField.text;
        [weakself.present accountJointClickAction:btn];
    };
    
    UILabel *lab = [[UILabel alloc] init];
    self.lab = lab;
    lab.numberOfLines = 0;
    lab.text = @"Choose_Plantform_Alert".lc_T;
    lab.lineBreakMode = NSLineBreakByWordWrapping;
    lab.textColor = [UIColor dhcolor_c41];
    lab.font = [UIFont lcFont_t5];
    [self.view addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(confirmBtn.mas_bottom).offset(15);
        make.left.mas_equalTo(self.view).offset(15);
        make.right.mas_equalTo(self.view).offset(-15);
    }];
    
}
 
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden:YES];
}
 
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [self.navigationController.navigationBar setHidden:NO];
}
 
@end