ifish/Ifish/controllers/ConnectAauariumVC/ConAquarMethodVC.m

175 lines
6.3 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ConAquarMethodVC.m
// Ifish
//
// Created by wbzhan on 2019/9/20.
// Copyright © 2019 lianlian. All rights reserved.
//
#import "ConAquarMethodVC.h"
#import "SecondConnectWifiController.h"
#import "ConAquarNowWiFiPwdVC.h"
#import <CoreLocation/CoreLocation.h>
@interface ConAquarMethodVC ()
Strong UILabel *subTitleLabel;
@end
@implementation ConAquarMethodVC
- (void)viewDidLoad {
[super viewDidLoad];
[self addTitleViewWithTitle:self.titleString];
[self.view addSubview:self.subTitleLabel];
NSArray *imageArr = @[@"icons_con_01",@"icons_con_02"];
NSArray *titleArr = @[@"智能连接",@"热点连接"];
for (int i=0; i<2; i++) {
UIButton *contentView = InitObject(UIButton);
[contentView addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
contentView.tag = i;
[self.view addSubview:contentView];
contentView.backgroundColor = XWhite;
contentView.layer.cornerRadius = kSizeFrom750(10);
contentView.layer.masksToBounds = YES;
[contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.width.mas_equalTo(kSizeFrom750(650));
make.height.mas_equalTo(kSizeFrom750(140));
make.top.mas_equalTo(self.subTitleLabel.mas_bottom).offset(kSizeFrom750(60)+i*kSizeFrom750(200));
}];
UIImageView *iconImage = InitObject(UIImageView);
[iconImage setImage:IMAGEBYENAME(imageArr[i])];
[contentView addSubview:iconImage];
[iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(contentView);
make.left.mas_equalTo(kSizeFrom750(50));
make.width.height.mas_equalTo(kSizeFrom750(84));
}];
UILabel *titleL = InitObject(UILabel);
titleL.text = titleArr[i];
titleL.textColor = RGB(130, 130, 130);
titleL.font = FontSize(18);
[contentView addSubview:titleL];
[titleL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(iconImage.mas_right).offset(kSizeFrom750(30));
make.centerY.mas_equalTo(iconImage);
}];
UIImageView *rightArrow = InitObject(UIImageView);
[rightArrow setImage:IMAGEBYENAME(@"right_arrow")];
[contentView addSubview:rightArrow];
[rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(titleL);
make.right.mas_equalTo(-kSizeFrom750(30));
make.width.height.mas_equalTo(kSizeFrom750(44));
}];
}
self.view.backgroundColor = COLOR_Background;
if ([CLLocationManager locationServicesEnabled] && ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)) {
//定位功能可用
}else if ([CLLocationManager authorizationStatus] ==kCLAuthorizationStatusDenied) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"需要定位权限才能获取wifi信息给设备配网来添加设备" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"打开定位" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if([[UIApplication sharedApplication] canOpenURL:url]) {
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}else {
[[UIApplication sharedApplication] openURL:url];
}
}
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
[self.navigationController popViewControllerAnimated:YES];
}];
[alert addAction:ok];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];
}else if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined){
CLLocationManager* locationManager = [[CLLocationManager alloc] init];
[locationManager requestWhenInUseAuthorization];
}
// Do any additional setup after loading the view.
}
-(void)buttonClick:(UIButton *)sender{
self.hidesBottomBarWhenPushed = YES;
if (sender.tag==0) {
//智能连接
if (self.deviceType==DEVICECAMERA)
{
YooseeNextConnectViewController *nextvc=[[YooseeNextConnectViewController alloc] init];
nextvc.conectType = conectType_Intelligent;
[self.navigationController pushViewController:nextvc animated:YES];
}
else
{
SecondConnectWifiController *wifivc=[[SecondConnectWifiController alloc]init];
wifivc.deviceType=self.deviceType;
wifivc.vcTitle=self.titleString;
[self.navigationController pushViewController:wifivc animated:YES];
}
//热点链接
}else{
ConAquarNowWiFiPwdVC *vc = InitObject(ConAquarNowWiFiPwdVC);
vc.deviceType=self.deviceType;
NSDictionary *netInfo = [CommonUtils getSSIDInfo];
vc.ssid = [netInfo objectForKey:@"SSID"];
vc.bssid = [netInfo objectForKey:@"BSSID"];
vc.deviceType=self.deviceType;
[self.navigationController pushViewController:vc animated:YES];
}
}
- (UILabel *)subTitleLabel
{
if (!_subTitleLabel) {
_subTitleLabel = InitObject(UILabel);
_subTitleLabel.font = FontSize(16);
_subTitleLabel.text = @"请选择合适的连接方式";
_subTitleLabel.textColor = RGB_92;
}
return _subTitleLabel;
}
/*
#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