萤石云 iOSSDK,移植跨平台相关工程
JLChen
2021-02-02 9100afbe1805413504840e6957097be638579045
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
 
//
//  YSWifiTipsViewController.m
//  VideoGo
//
//  Created by DeJohn Dong on 15/7/30.
//  Copyright (c) 2015年 Ezviz. All rights reserved.
//
 
#import "EZWifiTipsViewController.h"
#import "Masonry.h"
#import "DDKit.h"
#import "EZWifiInfoViewController.h"
#import "EZDeviceRestartTipsViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "EZLocationAlertVCViewController.h"
 
 
@interface EZWifiTipsViewController ()
{
    BOOL _isRestart;
}
 
@property (nonatomic, strong) UIImageView *deviceImageView;
@property (nonatomic, strong) UIButton *nextButton;
@property (nonatomic, strong) UIButton *exceptionButton;
@property (nonatomic, strong) UILabel *tipsLabel;
 
@end
 
@implementation EZWifiTipsViewController
 
- (void)dealloc
{
    
}
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = NSLocalizedString(@"wifi_prepare_title", @"第一步,准备好设备");
    
    [self.view addSubview:self.tipsLabel];
    [self.tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(@10);
        make.trailing.mas_equalTo(@-10);
        if([UIScreen mainScreen].bounds.size.height == 480.0){
            make.top.mas_equalTo(@10);
        }else{
            make.top.mas_equalTo(@99);
        }
        make.height.mas_equalTo(@50);
    }];
    
    [self.view addSubview:self.deviceImageView];
    [self.deviceImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.tipsLabel.mas_bottom).offset(19);
        make.width.mas_equalTo(@174);
        make.height.mas_equalTo(@199);
        make.centerX.mas_equalTo(self.view.mas_centerX);
    }];
    
    [self.view addSubview:self.nextButton];
    [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.deviceImageView.mas_bottom).offset(31);
        make.height.mas_equalTo(@38);
        make.width.mas_equalTo(@285);
        make.centerX.mas_equalTo(self.view.mas_centerX);
    }];
    
    [self.view addSubview:self.exceptionButton];
    [self.exceptionButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nextButton.mas_bottom).offset(15);
        make.height.mas_equalTo(@38);
        make.width.mas_equalTo(@285);
        make.centerX.mas_equalTo(self.view.mas_centerX);
    }];
    
    [self checkDevice];
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
/*
#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.
}
*/
 
#pragma mark - Custom Methods
 
- (void)checkDevice
{
    self.tipsLabel.text = NSLocalizedString(@"wifi_device_power_tip", @"请将设备插上电后等待大约30秒,直到设备启动完成");
    [self.nextButton setTitle:NSLocalizedString(@"wifi_device_start_ready", @"设备已启动好,且是第一次配置网络") forState:UIControlStateNormal];
    [self.exceptionButton setTitle:NSLocalizedString(@"wifi_config_wifi_ago", @"这台设备以前配过网络") forState:UIControlStateNormal];
    
    NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:self.tipsLabel.text];
    [attributeStr addAttributes:@{NSForegroundColorAttributeName:[UIColor dd_hexStringToColor:@"0xff4000"],NSFontAttributeName:[UIFont boldSystemFontOfSize:16.0f]} range:[self.tipsLabel.text rangeOfString:@"30"]];
    self.tipsLabel.attributedText = attributeStr;
}
 
- (void)nextButtonClicked:(id)sender
{
    if (@available(iOS 13.0, *))
    {
        if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied
            || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted
            || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {
            
            [self pushToLocationAlertVC];
        }
        else {
            [self performSegueWithIdentifier:@"go2WifiInfo" sender:nil];
        }
    } else {
    
        [self performSegueWithIdentifier:@"go2WifiInfo" sender:nil];
    }
}
 
- (void)exceptionButtonClicked:(id)sender
{
    if (@available(iOS 13.0, *))
    {
        if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied
            || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted
            || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) {
            
            [self pushToLocationAlertVC];
        }
        else {
            [self performSegueWithIdentifier:@"go2DeviceRestart" sender:nil];
        }
    }
    else
    {
        [self performSegueWithIdentifier:@"go2DeviceRestart" sender:nil];
    }
}
 
- (void) pushToLocationAlertVC {
 
    [self performSegueWithIdentifier:@"LocationAlertVC" sender:nil];
}
 
#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 {
    if ([[segue destinationViewController] isKindOfClass:[EZWifiInfoViewController class]]) {
        EZWifiInfoViewController *vc = (EZWifiInfoViewController *)[segue destinationViewController];
        vc.supportApMode = self.supportApMode;
        vc.supportSmartMode = self.supportSmartMode;
        vc.supportSoundMode = self.supportSoundMode;
    }
    else if ([[segue destinationViewController] isKindOfClass:[EZDeviceRestartTipsViewController class]]) {
        EZDeviceRestartTipsViewController *vc = (EZDeviceRestartTipsViewController *)[segue destinationViewController];
        vc.supportApMode = self.supportApMode;
        vc.supportSmartMode = self.supportSmartMode;
        vc.supportSoundMode = self.supportSoundMode;
    }
    else {
        EZLocationAlertVCViewController *vc = (EZLocationAlertVCViewController *)[segue destinationViewController];
        vc.supportApMode = self.supportApMode;
        vc.supportSmartMode = self.supportSmartMode;
        vc.supportSoundMode = self.supportSoundMode;
    }
}
 
#pragma mark - Super Methods
 
- (void)popBack:(id)sender {
    if(_isRestart){
        _isRestart = NO;
        
        self.exceptionButton.hidden = NO;
        
        self.title = NSLocalizedString(@"wifi_prepare_title", @"第一步,准备好设备");
        
        [self checkDevice];
 
        return;
    }
    [self.navigationController popViewControllerAnimated:YES];
}
 
#pragma mark - Set & Get Methods
 
- (UILabel *)tipsLabel
{
    if(!_tipsLabel)
    {
        _tipsLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _tipsLabel.backgroundColor = [UIColor clearColor];
        _tipsLabel.font = [UIFont systemFontOfSize:16.0f];
        _tipsLabel.textColor = [UIColor dd_hexStringToColor:@"0x333333"];
        _tipsLabel.numberOfLines = 2;
        _tipsLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _tipsLabel;
}
 
- (UIImageView *)deviceImageView
{
    if(!_deviceImageView)
    {
        _deviceImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"device"]];
    }
    return _deviceImageView;
}
 
- (UIButton *)nextButton
{
    if(!_nextButton)
    {
        _nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_nextButton addTarget:self action:@selector(nextButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
        [_nextButton setBackgroundImage:[UIImage imageNamed:@"blue_button"] forState:UIControlStateNormal];
        [_nextButton setBackgroundImage:[UIImage imageNamed:@"blue_button_sel"] forState:UIControlStateHighlighted];
        _nextButton.titleLabel.font = [UIFont systemFontOfSize:15.0f];
    }
    return _nextButton;
}
 
- (UIButton *)exceptionButton
{
    if(!_exceptionButton)
    {
        _exceptionButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_exceptionButton addTarget:self action:@selector(exceptionButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
        [_exceptionButton setBackgroundImage:[UIImage imageNamed:@"white_button"] forState:UIControlStateNormal];
        [_exceptionButton setBackgroundImage:[UIImage imageNamed:@"white_button_sel"] forState:UIControlStateHighlighted];
        [_exceptionButton setTitleColor:[UIColor dd_hexStringToColor:@"0x1b9ee2"] forState:UIControlStateNormal];
        _exceptionButton.titleLabel.font = [UIFont systemFontOfSize:15.0f];
    }
    return _exceptionButton;
}
 
@end