initWithRootViewController

initWithRootViewController:

Initializes and returns a newly created navigation controller.

- (id)initWithRootViewController:(UIViewController *)rootViewController

Parameters
rootViewController

The root view controller that is pushed on the stack with no animation. It cannot be an instance of tab bar controller.

Return Value

Newly initialized navigation controller.

Discussion

This is a convenience method for initializing the receiver and pushing a view controller on its stack.

Availability
  • Available in iPhone OS 2.0 and later.
Related Sample Code

 

整理SDNQuickSetupSetControllerInfoViewController的逻辑,找到与isAgreePrivacyPolicyOn与进入next的按钮相关的逻辑,并告诉我该怎么改? // // SDNQuickSetupSetControllerInfoViewController.h // Omada // // Created by PengXiaochuang on 2020/1/2. // Copyright © 2020 TP-Link. All rights reserve∂d. // #import "SDNQuickSetupBasicFrameViewController.h" #import "TPSDNTimeZoneInfoTool.h" NS_ASSUME_NONNULL_BEGIN @interface SDNQuickSetupSetControllerInfoViewController : SDNQuickSetupBasicFrameViewController @property (nonatomic, strong, readonly) NSString* countrollerName; @property (nonatomic, strong, readonly) NSString* selectedCountryName; @property (nonatomic, strong, readonly) NSString* selectedCountryKey; @property (nonatomic, strong, readonly) NSString* selectedTimezoneName; @property (nonatomic, strong, readonly) TPSDNTimeZoneItem* selectedTimeZoneItem; @property (nonatomic, assign, readonly) BOOL isAgreePrivacyPolicyOn; @property (nonatomic, assign, readonly) BOOL isAgreeUeipOn; -(void)gotoSelectCountryPage; -(void)gotoSelectTimezonePage; //-(void)gotoAgreementPage; @end NS_ASSUME_NONNULL_END // // SDNQuickSetupSetControllerInfoViewController.m // Omada // // Created by PengXiaochuang on 2020/1/2. // Copyright © 2020 TP-Link. All rights reserved. // #import "SDNQuickSetupSetControllerInfoViewController.h" #import "TPInputGroupView.h" #import "TPInputCheckTool.h" #import "TPSelectionGroupView.h" #import "TPSDNCountryInfoTool.h" #import "TPSDNTimeZoneInfoTool.h" #import "SDNQSSelectCountryTableViewController.h" #import "SDNQSSelectTimeZoneTableViewController.h" #import "ALSDNQuickSetup.h" #import "PrivacyPolicyViewController.h" #import "TermsOfServiceViewController.h" #import "UserExperienceImprovementProgramViewController.h" @interface SDNQuickSetupSetControllerInfoViewController ()<UITextFieldDelegate, TTTAttributedLabelDelegate, SDNQuickSetupSelectionTableViewControllerDelegate> @property(nonatomic, strong)TPInputGroupView *nameGroupView; @property(nonatomic, strong)TPSelectionGroupView *countryGroupView; @property(nonatomic, strong)TPSelectionGroupView *timezoneGroupView; @property (nonatomic, assign) BOOL isSupportedAgreePrivacyPolicy; @property (nonatomic, assign) BOOL isSupportedAgreeUeip; //4.2新增用户展示同意隐私政策Button @property (nonatomic, strong) UIButton *agreePrivacyPolicyButton; @property (nonatomic, assign, readwrite) BOOL isAgreePrivacyPolicyOn; @property (nonatomic, strong) TTTAttributedLabel *agreePrivacyPolicyLabel; //4.2新增用户是否同意参加体验计划Button @property (nonatomic, strong) UIButton *agreeUeipButton; @property (nonatomic, assign, readwrite) BOOL isAgreeUeipOn; @property (nonatomic, strong) TTTAttributedLabel *agreeUeipLabel; @property (nonatomic, strong, readwrite) NSString* selectedCountryName; @property (nonatomic, strong, readwrite) NSString* selectedCountryKey; @property (nonatomic, strong, readwrite) NSString* selectedTimezoneName; @property (nonatomic, strong, readwrite) TPSDNTimeZoneItem* selectedTimeZoneItem; @end @implementation SDNQuickSetupSetControllerInfoViewController - (instancetype)init { self = [super init]; if (self) { self.xTitle = gSDNQuickSetup.setupWizardTitle; self.xIsNeedShowPageControl = YES; self.xSubTitle = @""; self.xNextText = gSDNGlobal.next; self.selectedTimeZoneItem = [[TPSDNTimeZoneItem alloc] init]; self.selectedCountryKey = @""; self.selectedCountryName = @""; self.selectedTimezoneName = @""; self.isSupportedAgreePrivacyPolicy = TPSDNControllerClient.currentInstance.termsAndPolicyComponent.isSupported; self.isSupportedAgreeUeip = TPSDNControllerClient.currentInstance.explmproveComponent.isSupported; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self requestDataFromNetwork]; [self.pageControl setCurrentPage:0]; } - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; if (self.agreePrivacyPolicyButton) { self.agreePrivacyPolicyButton.accessibilityFrame = [TPBA11yHelper getEnlargedAccessibilityFrame:self.agreePrivacyPolicyButton]; } if (self.agreeUeipButton) { self.agreeUeipButton.accessibilityFrame = [TPBA11yHelper getEnlargedAccessibilityFrame:self.agreeUeipButton]; } } -(void)setupNav { [super setupNav]; } -(BOOL)checkQuickSetupSDNControllerName:(NSString*)name { if (![[TPSDNControllerClient currentInstance].systemComponent.controllerInfo isVersionLowerThanV5]) { return [TPInputCheckTool checkQuickSetupSDNControllerNameV3:name]; } else if ([[TPSDNControllerClient currentInstance].systemComponent.controllerInfo isVersionLowerThanV5]) { return [TPInputCheckTool checkQuickSetupSDNControllerName:name]; } else { return [TPInputCheckTool checkQuickSetupSDNControllerNameV2:name]; } } - (void)setupSubViews { [super setupSubViews]; [self.nextButton setEnabled:NO]; self.nextButton.hidden = NO; TPWeakSelf; TPInputGroupView *nameGroupView = [[TPInputGroupView alloc] initForUnderlineTextFieldWithInitBlock:^( TPInputGroupView * groupContentView, UILabel * titleLabel, TPUnderLineTextField* valueFiled, UILabel * tipsLabel, UILabel * errorLabel){ TPStrongSelf; titleLabel.text = gSDNGlobal.controllerName; valueFiled.returnKeyType = UIReturnKeyDefault; valueFiled.delegate = _self; valueFiled.text = @""; if ((![[TPSDNControllerClient currentInstance].systemComponent.controllerInfo isVersionLowerThanV5])) { valueFiled.keyboardType = UIKeyboardTypeDefault; }else{ valueFiled.keyboardType = UIKeyboardTypeASCIICapable; } }]; if (nameGroupView) { [nameGroupView updateUIStyle]; [nameGroupView tpbConfigAsTopCardStyle]; [self.frameView addSubview:nameGroupView]; [nameGroupView updateOnFocusBlock:^( TPInputGroupView * groupContentView, UILabel * titleLabel, TPUnderLineTextField* valueFiled, UILabel * tipsLabel, UILabel * errorLabel){ TPStrongSelf; // 监控状态焦点 [groupContentView changeToNormalState]; }]; [nameGroupView updateOnUnfocusBlock:^( TPInputGroupView * groupContentView, UILabel * titleLabel, TPUnderLineTextField* valueFiled, UILabel * tipsLabel, UILabel * errorLabel){ TPStrongSelf; //非焦点状态,一般用于检查 输入的内容是否合法 // 需要把文案首尾去除空白 NSString *name = valueFiled.text; name = [name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; valueFiled.text = name; if([self checkQuickSetupSDNControllerName:valueFiled.text]) { [groupContentView changeToNormalState]; } else { if (IsEmptyString(valueFiled.text)) { [groupContentView changeToWarningStateWithErrorMessage:gSDNQuickSetup.checkRequiredControllerName]; } else { [groupContentView changeToWarningStateWithErrorMessage:gSDNQuickSetup.checkControllerNameError]; } } [_self updateNextButtonStatus]; }]; [nameGroupView updateOnValueChangedBlock:^( TPInputGroupView * groupContentView, UILabel * titleLabel, TPUnderLineTextField* valueFiled, UILabel * tipsLabel, UILabel * errorLabel){ // 时刻检查内容是否合法并修正 TPStrongSelf; [_self updateNextButtonStatus]; }]; [nameGroupView mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.leading.equalTo(_self.frameView).offset(16); make.trailing.equalTo(_self.frameView).offset(-16); make.top.equalTo(_self.frameView); }]; self.nameGroupView = nameGroupView; } TPSelectionGroupView *countryGroupView = [[TPSelectionGroupView alloc] init]; if (countryGroupView) { [countryGroupView updateUIStyle]; [self.frameView addSubview:countryGroupView]; if ([[TPSDNControllerClient currentInstance].quickSetupComponent supportForComponent:DMSDNComponentIDMsp ForVersionCode:1]) { [countryGroupView updateSelectedKeyWithText:gMeshQuickSetup.sdnCountryOrRegion]; } else { [countryGroupView updateSelectedKeyWithText: gSDNGlobal.countryOrRegion]; } [countryGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [countryGroupView updateValueWithSelectedState:NO]; TPWeakSelf; [countryGroupView addSelectedBlock:^{ TPStrongSelf; DDLogDebug(@"进入选择国家列表"); [_self gotoSelectCountryPage]; }]; [countryGroupView mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.leading.trailing.equalTo(_self.nameGroupView); make.top.equalTo(nameGroupView.mas_bottom); }]; self.countryGroupView = countryGroupView; } TPSelectionGroupView *timezoneGroupView = [[TPSelectionGroupView alloc] init]; if (timezoneGroupView) { [timezoneGroupView updateUIStyle]; [timezoneGroupView tpbConfigAsBottomCardStyle]; [self.frameView addSubview:timezoneGroupView]; if ([[TPSDNControllerClient currentInstance].quickSetupComponent supportForComponent:DMSDNComponentIDMsp ForVersionCode:1]) { [timezoneGroupView updateSelectedKeyWithText:gMeshQuickSetup.sdnTimezone]; } else { [timezoneGroupView updateSelectedKeyWithText:gSDNGlobal.timezone]; } [timezoneGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [timezoneGroupView updateValueWithSelectedState:NO]; TPWeakSelf; [timezoneGroupView addSelectedBlock:^{ TPStrongSelf; DDLogDebug(@"进入选择时区列表"); [_self gotoSelectTimezonePage]; }]; [timezoneGroupView mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.leading.trailing.equalTo(_self.countryGroupView); make.top.equalTo(countryGroupView.mas_bottom); if (!_self.isSupportedAgreePrivacyPolicy && !_self.isSupportedAgreeUeip) { make.bottom.equalTo(_self.frameView); } }]; self.timezoneGroupView = timezoneGroupView; } if (self.isSupportedAgreePrivacyPolicy) { UIButton *agreePrivacyPolicyButton = [[UIButton alloc] init]; if (agreePrivacyPolicyButton) { [self.frameView addSubview:agreePrivacyPolicyButton]; self.agreePrivacyPolicyButton = agreePrivacyPolicyButton; self.isAgreePrivacyPolicyOn = NO; [self updateAgreePrivacyPolicyButtonImage]; [agreePrivacyPolicyButton addTarget:self action:@selector(didTapAgreePrivacyPolicyButton) forControlEvents:UIControlEventTouchUpInside]; TPWeakSelf; [agreePrivacyPolicyButton mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.width.height.mas_equalTo(24); make.leading.equalTo(_self.nameGroupView); make.top.equalTo(timezoneGroupView.mas_bottom).offset(20); }]; agreePrivacyPolicyButton.accessibilityLabel = [gAccount.sdnAcceptPolicyText replaceFormatPlaceHolders:@[ gSDNQuickSetup.agreeTermsOfUseLinkText,gSDNQuickSetup.agreePrivacyPolicyLinkText]]; self.agreePrivacyPolicyButton = agreePrivacyPolicyButton; } TTTAttributedLabel *agreePrivacyPolicyLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero]; if (agreePrivacyPolicyLabel) { [self.frameView addSubview:agreePrivacyPolicyLabel]; agreePrivacyPolicyLabel.isAccessibilityElement = YES; agreePrivacyPolicyLabel.delegate = self; agreePrivacyPolicyLabel.textColor = [UIColor tpbTextSecondaryContent]; agreePrivacyPolicyLabel.tpbDynamicFont = [UIFont tpr14Regular]; agreePrivacyPolicyLabel.lineBreakMode = NSLineBreakByWordWrapping; agreePrivacyPolicyLabel.textAlignment = NSTextAlignmentLeft; agreePrivacyPolicyLabel.numberOfLines = 0; agreePrivacyPolicyLabel.linkAttributes = @{NSForegroundColorAttributeName:[UIColor tpbTextLink]}; agreePrivacyPolicyLabel.activeLinkAttributes = @{NSForegroundColorAttributeName:[UIColor tpbTextLinkHover]}; NSString *termsStr = [TPBA11yHelper transToNOBreakStr:gAccount.accountTermsOfUse]; NSString *policyStr = [TPBA11yHelper transToNOBreakStr:gSDNQuickSetup.agreePrivacyPolicyLinkText]; NSString *fullText = [gAccount.sdnAcceptPolicyText replaceFormatPlaceHolders:@[ termsStr,policyStr]]; agreePrivacyPolicyLabel.text = fullText; NSDictionary *linkDict = @{@"target": termsStr}; [agreePrivacyPolicyLabel addLinkToTransitInformation:linkDict withRange: [fullText rangeOfString:termsStr]]; linkDict = @{@"target": policyStr}; [agreePrivacyPolicyLabel addLinkToTransitInformation:linkDict withRange: [fullText rangeOfString:policyStr]]; TPWeakSelf; [agreePrivacyPolicyLabel mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.top.equalTo(agreePrivacyPolicyButton); make.leading.equalTo(agreePrivacyPolicyButton.mas_trailing).offset(6); make.trailing.equalTo(_self.nameGroupView); make.height.greaterThanOrEqualTo(agreePrivacyPolicyButton); if (!_self.isSupportedAgreeUeip) { make.bottom.equalTo(_self.frameView); } }]; self.agreePrivacyPolicyLabel = agreePrivacyPolicyLabel; } } if (self.isSupportedAgreeUeip) { UIButton *agreeUeipButton = [[UIButton alloc] init]; if (agreeUeipButton) { [self.frameView addSubview:agreeUeipButton]; self.agreeUeipButton = agreeUeipButton; self.agreeUeipButton.hidden = self.coordinator.ecDevice.isCloudBasedController; self.isAgreeUeipOn = NO; [self updateAgreeUeipButtonImage]; [agreeUeipButton addTarget:self action:@selector(didTapAgreeUeipButton) forControlEvents:UIControlEventTouchUpInside]; TPWeakSelf; [agreeUeipButton mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.width.height.mas_equalTo(24); make.leading.equalTo(_self.nameGroupView); if (_self.isSupportedAgreePrivacyPolicy) { make.top.equalTo(_self.agreePrivacyPolicyLabel.mas_bottom).offset(16); } else { make.top.equalTo(timezoneGroupView.mas_bottom).offset(20); } }]; agreeUeipButton.accessibilityLabel = [gPrivacyAndTermsOfUse.policyUEIP replaceFormatPlaceHolders:@[gSDNQuickSetup.agreeUeipLinkText]]; self.agreeUeipButton = agreeUeipButton; } TTTAttributedLabel *agreeUeipLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero]; if (agreeUeipLabel) { [self.frameView addSubview:agreeUeipLabel]; agreeUeipLabel.delegate = self; agreeUeipLabel.textColor = [UIColor tpbTextSecondaryContent]; agreeUeipLabel.tpbDynamicFont = [UIFont tpr14Regular]; agreeUeipLabel.lineBreakMode = NSLineBreakByWordWrapping; agreeUeipLabel.textAlignment = NSTextAlignmentLeft; agreeUeipLabel.numberOfLines = 0; agreeUeipLabel.isAccessibilityElement = YES; agreeUeipLabel.linkAttributes = @{NSForegroundColorAttributeName:[UIColor tpbTextLink]}; agreeUeipLabel.activeLinkAttributes = @{NSForegroundColorAttributeName:[UIColor tpbTextLinkHover]}; NSString *fullText = [gPrivacyAndTermsOfUse.policyUEIP replaceFormatPlaceHolders:@[gSDNQuickSetup.agreeUeipLinkText]]; agreeUeipLabel.text = fullText; NSDictionary *linkDict = @{@"target": gSDNQuickSetup.agreeUeipLinkText}; [agreeUeipLabel addLinkToTransitInformation:linkDict withRange: [fullText rangeOfString:gSDNQuickSetup.agreeUeipLinkText]]; TPWeakSelf; [agreeUeipLabel mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.top.equalTo(agreeUeipButton); make.leading.equalTo(agreeUeipButton.mas_trailing).offset(6); make.trailing.equalTo(_self.nameGroupView); make.height.greaterThanOrEqualTo(agreeUeipButton); make.bottom.equalTo(_self.frameView); }]; self.agreeUeipLabel = agreeUeipLabel; self.agreeUeipLabel.hidden = self.coordinator.ecDevice.isCloudBasedController; } } [self updateNextButtonStatus]; } -(void)requestDataFromNetwork { DMSDNQuickSetupInfo *quickSetupInfo = [TPSDNControllerClient currentInstance].quickSetupComponent.quickSetupInfo; if (IsEmptyString(quickSetupInfo.controllerName)) { [self showWaitingToastView]; TPWeakSelf; [[[TPSDNControllerClient currentInstance].quickSetupComponent requestControllerInfo] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; [_self dismissToastViewWithCompleteBlock:^{ if (result.success) { DMSDNQuickSetupInfo *quickSetupInfo = [TPSDNControllerClient currentInstance].quickSetupComponent.quickSetupInfo; _self.nameGroupView.text = quickSetupInfo.controllerName; if (IsEmptyString(quickSetupInfo.country)) { _self.selectedCountryKey = @""; _self.selectedCountryName = @""; [_self.countryGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [_self.countryGroupView updateValueWithSelectedState:NO]; _self.selectedTimezoneName = @""; [_self.timezoneGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [_self.timezoneGroupView updateValueWithSelectedState:NO]; } else { _self.selectedCountryKey = quickSetupInfo.country; if (self.coordinator.ecDevice.isCloudBasedController) { _self.selectedCountryName = [[TPSDNCountryInfoTool shareInstanceQSForEs].countryKeyDictionary objectForKey:_self.selectedCountryKey]; } else { _self.selectedCountryName = [[TPSDNCountryInfoTool shareInstance].countryKeyDictionary objectForKey:_self.selectedCountryKey]; } [_self.countryGroupView updateSelectedValueWithText:_self.selectedCountryName]; [_self.countryGroupView updateValueWithSelectedState:YES]; _self.selectedTimeZoneItem = [[TPSDNTimeZoneInfoTool shareInstance].timezoneKeyDictionary objectForKey:quickSetupInfo.timeZone]; _self.selectedTimezoneName = _self.selectedTimeZoneItem.localName; [_self.timezoneGroupView updateSelectedValueWithText:_self.selectedTimezoneName]; [_self.timezoneGroupView updateValueWithSelectedState:YES]; } [_self updateNextButtonStatus]; } }]; }]; } else { self.nameGroupView.text = quickSetupInfo.controllerName; if (IsEmptyString(quickSetupInfo.country)) { self.selectedCountryKey = @""; self.selectedCountryName = @""; [self.countryGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [self.countryGroupView updateValueWithSelectedState:NO]; } else { self.selectedCountryKey = quickSetupInfo.country; if (self.coordinator.ecDevice.isCloudBasedController) { self.selectedCountryName = [[TPSDNCountryInfoTool shareInstanceQSForEs].countryKeyDictionary objectForKey:self.selectedCountryKey]; } else { self.selectedCountryName = [[TPSDNCountryInfoTool shareInstance].countryKeyDictionary objectForKey:self.selectedCountryKey]; } if (IsEmptyString(self.selectedCountryName)) { self.selectedCountryKey = @""; self.selectedCountryName = @""; [self.countryGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [self.countryGroupView updateValueWithSelectedState:NO]; } else { [self.countryGroupView updateSelectedValueWithText:self.selectedCountryName]; [self.countryGroupView updateValueWithSelectedState:YES]; } } if (IsEmptyString(quickSetupInfo.timeZone)) { self.selectedTimezoneName = @""; [self.timezoneGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [self.timezoneGroupView updateValueWithSelectedState:NO]; } else { self.selectedTimeZoneItem = [[TPSDNTimeZoneInfoTool shareInstance].timezoneKeyDictionary objectForKey:quickSetupInfo.timeZone]; if (self.selectedTimeZoneItem == nil) { self.selectedTimezoneName = @""; [self.timezoneGroupView updateSelectedValueWithText: gSDNGlobal.pleaseSelect]; [self.timezoneGroupView updateValueWithSelectedState:NO]; } else { self.selectedTimezoneName = self.selectedTimeZoneItem.localName; [self.timezoneGroupView updateSelectedValueWithText:self.selectedTimezoneName]; [self.timezoneGroupView updateValueWithSelectedState:YES]; } } [self updateNextButtonStatus]; } } // 仅首次显示的时候,才进行焦点处理。 - (void)firstViewDidAppear:(BOOL)animated { [super firstViewDidAppear:animated]; [self.nameGroupView focusOn]; } -(void)updateAgreePrivacyPolicyButtonImage { if (self.isAgreePrivacyPolicyOn) { [self.agreePrivacyPolicyButton setImage: [UIImage imageNamed: @"SDNSquareSelect"] forState:UIControlStateNormal]; } else { [self.agreePrivacyPolicyButton setImage: [UIImage imageNamed: @"SDNSquareUnselect"] forState:UIControlStateNormal]; } } -(void)updateAgreeUeipButtonImage { if (self.isAgreeUeipOn) { [self.agreeUeipButton setImage: [UIImage imageNamed: @"SDNSquareSelect"] forState:UIControlStateNormal]; } else { [self.agreeUeipButton setImage: [UIImage imageNamed: @"SDNSquareUnselect"] forState:UIControlStateNormal]; } } -(void)updateNextButtonStatus { BOOL isAgreePrivacyPolicyOn = YES; // 默认是同意的。 if (self.isSupportedAgreePrivacyPolicy) { // 在支持的情况下,则读取其具体的值。 isAgreePrivacyPolicyOn = self.isAgreePrivacyPolicyOn; } if ( !IsEmptyString(self.nameGroupView.text) && [self checkQuickSetupSDNControllerName:self.nameGroupView.text] && self.countryGroupView.isSelectedItem && self.timezoneGroupView.isSelectedItem && isAgreePrivacyPolicyOn) { [self.nextButton setEnabled:YES]; } else { [self.nextButton setEnabled:NO]; } } -(BOOL)textFieldShouldReturn:(UITextField *)textField { [self hideKeyboard]; return YES; } - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (range.length + range.location > textField.text.length) { return NO; } NSString* newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; // NSInteger stringLength = [newString dataUsingEncoding:NSUTF8StringEncoding].length; if (textField == self.nameGroupView.valueField) { if(![[TPSDNControllerClient currentInstance].systemComponent.controllerInfo isVersionLowerThanV5]) { if (newString.length > 32) { return NO; } } else { if ([newString dataUsingEncoding:NSUTF8StringEncoding].length > 32) { return NO; } } } return YES; } - (void) didTapAgreePrivacyPolicyButton { DDLogDebug(@"点击选择按钮"); self.isAgreePrivacyPolicyOn = !self.isAgreePrivacyPolicyOn; [self updateAgreePrivacyPolicyButtonImage]; [self updateNextButtonStatus]; } - (void) didTapAgreeUeipButton { DDLogDebug(@"点击选择按钮"); self.isAgreeUeipOn = !self.isAgreeUeipOn; [self updateAgreeUeipButtonImage]; [self updateNextButtonStatus]; } - (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTransitInformation:(NSDictionary *)components { DDLogDebug(@"点击文字链接"); NSString *linkText = [components objectForKey:@"target"]; DDLogDebug(@"点击文字链接 {%@}", linkText); NSString *termsStr = [TPBA11yHelper transToNOBreakStr:gAccount.accountTermsOfUse]; NSString *policyStr = [TPBA11yHelper transToNOBreakStr:gSDNQuickSetup.agreePrivacyPolicyLinkText]; if ([linkText isEqualToString:policyStr]) { [self gotoPrivacyPolicyPage]; } else if ([linkText isEqualToString:termsStr]) { [self gotoTermOfUsePage]; } else if ([linkText isEqualToString:gSDNQuickSetup.agreeUeipLinkText]) { [self gotoUEIPPage]; } } - (void)didTapNextButton { [self hideKeyboard]; [self gotoNextPage]; } // MARK: - 读取收集的数据 - (NSString *)countrollerName { return self.nameGroupView.text; } // MARK: - 页面切换 - (void)gotoSelectCountryPage { [self hideKeyboard]; NSArray *countryNameList = [NSArray new]; if (self.coordinator.ecDevice.isCloudBasedController) { countryNameList = [TPSDNCountryInfoTool shareInstanceQSForEs].countryNameDictionary.allKeys; } else { countryNameList = [TPSDNCountryInfoTool shareInstance].countryNameDictionary.allKeys; } SDNQSSelectCountryTableViewController *vc = [[SDNQSSelectCountryTableViewController alloc] initWithTitle:gSDNGlobal.countryOrRegion totalItems:countryNameList selectedItem:self.selectedCountryName]; vc.delegate = self; vc.tag = 101; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:vc]; [self.tpNavigationController presentViewController:navVC animated:YES completion:nil]; } - (void)gotoSelectTimezonePage { [self hideKeyboard]; NSArray *timezoneNameList = [TPSDNTimeZoneInfoTool shareInstance].timeZoneNameList; SDNQSSelectTimeZoneTableViewController *vc = [[SDNQSSelectTimeZoneTableViewController alloc] initWithTitle:gSDNGlobal.timezone totalItems:timezoneNameList selectedItem:self.selectedTimezoneName autoSort:NO]; vc.delegate = self; vc.tag = 102; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:vc]; [self.tpNavigationController presentViewController:navVC animated:YES completion:nil]; } -(void)gotoPrivacyPolicyPage { PrivacyPolicyViewController *viewController = [[PrivacyPolicyViewController alloc] init]; TPNavigationController *navVC = [[TPNavigationController alloc] initWithRootViewController:viewController]; [self.tpNavigationController presentViewController:navVC animated:YES completion:^{ }]; } -(void)gotoTermOfUsePage { TermsOfServiceViewController *viewController = [[TermsOfServiceViewController alloc] init]; TPNavigationController *navVC = [[TPNavigationController alloc] initWithRootViewController:viewController]; [self.tpNavigationController presentViewController:navVC animated:YES completion:^{ }]; } -(void)gotoUEIPPage { UserExperienceImprovementProgramViewController *viewController = [[UserExperienceImprovementProgramViewController alloc] init]; TPNavigationController *navVC = [[TPNavigationController alloc] initWithRootViewController:viewController]; [self.tpNavigationController presentViewController:navVC animated:YES completion:^{ }]; } // MARK: delegate - (void)didCompleteViewControllerWithTag:(NSInteger)vcTag andSelecteItem:(NSString *)selectedItem { if (vcTag == 101) { DDLogDebug(@"选择国家地区完毕,选择了名称为:[%@]", selectedItem); if (!IsEmptyString(selectedItem)) { self.selectedCountryName = selectedItem; if (self.coordinator.ecDevice.isCloudBasedController) { self.selectedCountryKey = [[TPSDNCountryInfoTool shareInstanceQSForEs].countryNameDictionary objectForKey:selectedItem]; } else { self.selectedCountryKey = [[TPSDNCountryInfoTool shareInstance].countryNameDictionary objectForKey:selectedItem]; } DDLogDebug(@"本地名称为:[%@]", self.selectedCountryName); DDLogDebug(@"标识码为:[%@]", self.selectedCountryKey); [self.countryGroupView updateSelectedValueWithText:selectedItem]; [self.countryGroupView updateValueWithSelectedState:YES]; } [self updateNextButtonStatus]; } else if(vcTag == 102) { DDLogDebug(@"选择时区完毕,选择了:[%@]", selectedItem); if (!IsEmptyString(selectedItem)) { self.selectedTimezoneName = selectedItem; self.selectedTimeZoneItem = [[TPSDNTimeZoneInfoTool shareInstance].timezoneNameDictionary objectForKey:selectedItem]; [self.timezoneGroupView updateSelectedValueWithText:selectedItem]; [self.timezoneGroupView updateValueWithSelectedState:YES]; } [self updateNextButtonStatus]; } } @end
12-10
#import <UIKit/UIKit.h> #import <ReactiveObjC/ReactiveObjC.h> NS_ASSUME_NONNULL_BEGIN #pragma mark - Model @interface StoryScene : NSObject @property (nonatomic, copy) NSString *sceneTitle; @property (nonatomic, copy) NSString *visualDescription; @property (nonatomic, strong) NSArray<NSString *> *symbolicElements; @end @implementation StoryScene @end @interface DigitalTool : NSObject @property (nonatomic, copy) NSString *toolName; @property (nonatomic, copy) NSString *usageDescription; @property (nonatomic, strong) NSArray<NSString *> *appliedScenes; @end @implementation DigitalTool @end @interface InteractionPlan : NSObject @property (nonatomic, copy) NSString *platform; @property (nonatomic, strong) NSArray<NSString *> *engagementMethods; @end @implementation InteractionPlan @end #pragma mark - ViewModel @interface StoryViewModel : NSObject @property (nonatomic, strong) NSArray<StoryScene *> *scenes; @property (nonatomic, strong) RACCommand *loadScenesCommand; @end @implementation StoryViewModel - (instancetype)init { self = [super init]; if (self) { @weakify(self); _loadScenesCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id _) { @strongify(self); return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { [self fetchScenesFromService]; [subscriber sendCompleted]; return nil; }]; }]; } return self; } - (void)fetchScenesFromService { StoryScene *scene1 = [StoryScene new]; scene1.sceneTitle = @"黑暗中的微光"; scene1.visualDescription = @"黑白基调牢房,霉变米饭特写"; StoryScene *scene2 = [StoryScene new]; scene2.sceneTitle = @"铁窗下的课堂"; scene2.symbolicElements = @[@"树枝笔", @"棉灰墨", @"半截铅笔"]; _scenes = @[scene1, scene2]; } @end @interface ToolViewModel : NSObject @property (nonatomic, strong) NSArray<DigitalTool *> *tools; @property (nonatomic, strong) RACSubject *toolSelectedSubject; @end @implementation ToolViewModel - (instancetype)init { self = [super init]; if (self) { _toolSelectedSubject = [RACSubject subject]; [self setupTools]; } return self; } - (void)setupTools { DigitalTool *tool1 = [DigitalTool new]; tool1.toolName = @"PikaLabs"; tool1.usageDescription = @"水墨晕染风格动画"; DigitalTool *tool2 = [DigitalTool new]; tool2.toolName = @"Runway Gen-3"; tool2.usageDescription = @"动态分镜特效"; _tools = @[tool1, tool2]; } @end #pragma mark - View @interface SceneCell : UICollectionViewCell @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UIImageView *symbolImageView; - (void)configureWithScene:(StoryScene *)scene; @end @implementation SceneCell - (void)configureWithScene:(StoryScene *)scene { _titleLabel.text = scene.sceneTitle; _symbolImageView.image = [UIImage imageNamed:scene.symbolicElements.firstObject]; } @end @interface MainViewController : UIViewController @property (nonatomic, strong) StoryViewModel *storyVM; @property (nonatomic, strong) ToolViewModel *toolVM; @property (nonatomic, strong) UICollectionView *collectionView; @end @implementation MainViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupCollectionView]; [self bindViewModels]; } - (void)setupCollectionView { UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new]; _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout]; [_collectionView registerClass:SceneCell.class forCellWithReuseIdentifier:@"SceneCell"]; [self.view addSubview:_collectionView]; } - (void)bindViewModels { @weakify(self); [[_storyVM.loadScenesCommand execute:nil] subscribeCompleted:^{ @strongify(self); [self.collectionView reloadData]; }]; [_toolVM.toolSelectedSubject subscribeNext:^(DigitalTool *tool) { NSLog(@"Selected tool: %@", tool.toolName); }]; } #pragma mark - UICollectionViewDataSource - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return _storyVM.scenes.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { SceneCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"SceneCell" forIndexPath:indexPath]; [cell configureWithScene:_storyVM.scenes[indexPath.item]]; return cell; } @end #pragma mark - Coordinator @interface AppCoordinator : NSObject @property (nonatomic, strong) UINavigationController *navigationController; - (void)start; @end @implementation AppCoordinator - (void)start { MainViewController *mainVC = [MainViewController new]; mainVC.storyVM = [StoryViewModel new]; mainVC.toolVM = [ToolViewModel new]; _navigationController = [[UINavigationController alloc] initWithRootViewController:mainVC]; } @end #pragma mark - AppDelegate @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (nonatomic, strong) UIWindow *window; @property (nonatomic, strong) AppCoordinator *coordinator; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { _window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; _coordinator = [AppCoordinator new]; [_coordinator start]; _window.rootViewController = _coordinator.navigationController; [_window makeKeyAndVisible]; return YES; } @end NS_ASSUME_NONNULL_END
08-23
快速分析页面代码 // // SDNWANSettingVC.m // Omada // // Created by qijiayue on 2022/12/19. // Copyright © 2022 TP-Link. All rights reserved. // #import "SDNWANSettingVC.h" #import "SDNWANSettingVCDataSource.h" #import "ALSDNSiteInternetSetting.h" #import "TPAlertViewFactory.h" #import "TPTextAlertView.h" #import "SDNPermissionTool.h" #import "TPListSelectIndexVC.h" #import "TPSDNControllerCommonMethod.h" #import "SLRegionISPInfo.h" #import "SLDSLDataModelTransformMethods.h" #import "SLDSLSelectISPViewController.h" #import "SLSelectDSLMudoViewController.h" #import "SDNQSSelectCountryTableViewController.h" #import "TPSLGatewayWanSettingAbstractLayer.h" #import "TPSimpleCountryTool.h" #import "TPDslIspTool.h" #import "TPBCommonTableHelper.h" #import "OMDListSelectPopUpView.h" #import "SDNV6PermissionTool.h" NSString *ipv4ConnectionTypeFlag = @"ipv4ConnectionTypeFlag"; NSString *ipv6ConnectionTypeFlag = @"ipv6ConnectionTypeFlag"; NSString *ipv4InternetVlanPriorityFlag = @"ipv4InternetVlanPriorityFlag"; NSString *ipv6GetAddressMethodFlag = @"ipv6GetAddressMethodFlag"; @interface SDNWANSettingVC ()<UITableViewDelegate, TPTextAlertViewDelegate, SDNWANSettingVCDataSourceDelegate, TPSelectIndexDelegate, SDNQuickSetupSelectionTableViewControllerDelegate> @property (nonatomic, strong) TPKeyboardAvoidingTableView *tableView; @property (nonatomic, strong) SDNWANSettingVCDataSource *dataSource; @property (nonatomic, strong) DMSDNWanPortInfo *currentWanSetting; @property (nonatomic, strong) DMSDNWanPortInfo *originalWanSetting; @property (nonatomic, strong) TPAlertViewFactory *alertViewFactory; @property (nonatomic, strong) TPTextAlertView *discardAlertView; @property (nonatomic, assign) BOOL isSupportReadonly; @property (nonatomic, copy) NSArray<DMSDNInternetSupportProtocolInfo *> *ipv4ConnectionTypeList; @property (nonatomic, copy) NSArray<DMSDNInternetSupportProtocolInfo *> *ipv6ConnectionTypeList; @property (nonatomic, copy) NSArray<NSNumber *> *ipv4InternetVlanPriorityList; @property (nonatomic, copy) NSArray<NSNumber *> *ipv6GetAddressMethodList; @property (nonatomic, strong) DMSDNInternetWanLanPortSetting *currentPortDetail; @end @implementation SDNWANSettingVC - (instancetype)initWithWanSetting:(DMSDNWanPortInfo *)wanPortInfo andPortDetail:(DMSDNInternetWanLanPortSetting *)portDetail { self = [super init]; if (self) { self.currentWanSetting = [wanPortInfo copy]; self.originalWanSetting = [wanPortInfo copy]; if ([self supportVLANIdRequired]) { self.originalWanSetting.ipv4Info.isInternetVlanEnable = YES; self.currentWanSetting.ipv4Info.isInternetVlanEnable = YES; } self.currentPortDetail = [portDetail copy]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.isSupportReadonly = ![SDNV6PermissionTool shareInstance].supportCompatibleSiteNetworkSaveConfig; [self buildNav]; [self buildView]; [self reloadView]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.tpbPrivacyProtectionEnabled = YES; } //MARK: - view - (void)buildView { self.dataSource = [[SDNWANSettingVCDataSource alloc] init]; //以下两种情况可以从json文件中读取vlanid,只读 NSInteger dslInfoNum = [[TPDslIspTool shareInstance] getCurrentDslInfoWithCountry:[[TPSimpleCountryTool shareInstance] getCountryDetailWithSimpleCountry:self.currentWanSetting.dslSettingInfo.location] andIspNum:self.currentWanSetting.dslSettingInfo.isp].count; self.dataSource.dslVlanIdReadOnly = dslInfoNum == 7 || dslInfoNum == 4; self.tableView.dataSource = self.dataSource; self.dataSource.delegate = self; [self.dataSource registerClassInTableView:self.tableView]; [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.leading.trailing.equalTo(self.mas_tpSafeAreaLayoutGuide); make.bottom.equalTo(self.view); }]; } - (void)buildNav { [self.tpNavigationController setNavigationBarTitleFont:[UIFont tpr20Regular] andColor:[UIColor tpbTextPrimary]]; [self setNavigationBarTitle:self.currentWanSetting.portName]; self.navigationItem.leftBarButtonItem = [self createBarButtonItemItemWithStyle:TPViewControllerBarButtonItemStyleBackInWhite andTarget:self andAction:@selector(clickBack)]; self.navigationItem.rightBarButtonItem = [self tpbCreateRightBarButtonItemWithText:gGlobal.textSave andTextColor:[UIColor tpbTextPrimary] andTarget:self andAction:@selector(clickSave)]; } //MARK: - tableviewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated: YES]; if ([kSDNInternetWanPortIpv4ConnectionTypeCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { if (!self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].isReadOnly) { [self clickIpv4ConnectionType]; } } if ([kSDNInternetWanPortIpv4VlanPriorityCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { if (DMSDNInternetIpv4ConnectionTypePPPoA != self.currentWanSetting.ipv4Info.connectionType && DMSDNInternetIpv4ConnectionTypeIPoA != self.currentWanSetting.ipv4Info.connectionType) { [self clickIpv4VlanPriority]; } } if ([kSDNInternetWanPortIpv6ConnectionTypeCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { [self clickIpv6ConnectionType]; } if ([kSDNInternetWanPortIpv6GetAddressMethodCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { [self clickIpv6GetAddressMethod]; } if ([kSDNInternetWanPortISPSelectionCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { [self didClickISP]; } if ([kSDNInternetWanPortLocationSelectionCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { [self didClickRegin]; } if ([kSDNInternetWanPortModuSelectionCellKey isEqualToString:self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].key]) { if (!self.dataSource.modelList[indexPath.section].cellModelList[indexPath.row].isReadOnly) { [self didClickDSLModuType]; } } } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if (IsEmptyString(self.dataSource.modelList[section].sectionTip)) { return [[UIView alloc] init]; } else { return [TPBCommonTableHelper createSectionFooterView:self.dataSource.modelList[section].sectionTip]; } } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (IsEmptyString(self.dataSource.modelList[section].sectionTitle)) { return [[UIView alloc] init]; } else { return [TPBCommonTableHelper createSectionHeaderView:self.dataSource.modelList[section].sectionTitle]; } } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { if (IsEmptyString(self.dataSource.modelList[section].sectionTip)) { return TPBDesign.list.sectionFooterHeight; } else { return UITableViewAutomaticDimension; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (section == 0) { return TPBDesign.list.sectionHeaderHeight; } else { if (IsEmptyString(self.dataSource.modelList[section].sectionTitle)) { return TPBDesign.list.sectionHeaderHeight; } else { return UITableViewAutomaticDimension; } } } //MARK: - 点击事件 - (void)clickSave { [self hideKeyboard]; self.tableView.editing = NO; if ([self.dataSource isCheckAllOk]) { [self.dataSource updateInputGroupViewData]; if (self.didClickSave) { self.didClickSave(self.currentWanSetting); } [self.navigationController popViewControllerAnimated:YES]; } } - (void)clickBack { [self hideKeyboard]; self.tableView.editing = NO; if (![self.originalWanSetting isEqual:self.currentWanSetting]) { [self.discardAlertView show]; } else { [self.navigationController popViewControllerAnimated:YES]; } } - (void)clickIpv4ConnectionType { NSMutableArray<NSString *> *ipv4ConnectionStringList = [[NSMutableArray alloc] init]; int index = 0; // for (int i = 0; i < self.ipv4ConnectionTypeList.count; i++) // { // [ipv4ConnectionStringList addObject:self.ipv4ConnectionTypeList[i].translateName]; // if (self.currentWanSetting.ipv4Info.connectionType == self.ipv4ConnectionTypeList[i].protocolId) // { // index = i; // } // } for (int i = 0; i < self.ipv4ConnectionTypeList.count; i++) { NSString *tempConnection = [TPSDNControllerCommonMethod transformToIpv4DslVDSLTranslateNameWithProtocolId: self.ipv4ConnectionTypeList[i].protocolId]; if (!IsEmptyString(tempConnection)){ [ipv4ConnectionStringList addObject:tempConnection]; } if (self.currentWanSetting.ipv4Info.connectionType == self.ipv4ConnectionTypeList[i].protocolId) { index = i; } } if (ModulationTypeADSL == self.currentWanSetting.dslSettingInfo.modulationType && self.currentPortDetail.type == DMSDNInternetPortTypeDsl) { for (int i = 0; i < self.ipv4ConnectionTypeList.count; i++) { NSString *tempConnection = [TPSDNControllerCommonMethod transformToIpv4PppoaAndIpoaTranslateNameWithProtocolId: self.ipv4ConnectionTypeList[i].protocolId]; if (!IsEmptyString(tempConnection)){ [ipv4ConnectionStringList addObject:tempConnection]; } if (self.currentWanSetting.ipv4Info.connectionType == self.ipv4ConnectionTypeList[i].protocolId) { index = i; } } } // TPListSelectIndexVC *vc = [[TPListSelectIndexVC alloc] initWithList:[ipv4ConnectionStringList copy] andIndex:index]; // vc.flag = ipv4ConnectionTypeFlag; // [vc updateTitle:gMeshQuickSetup.ipv4Connection]; // vc.delegate = self; // [self.tpNavigationController pushViewController:vc animated:YES]; OMDListSelectPopUpView *view = [OMDListSelectPopUpView new]; [view updateWithTitle:gMeshQuickSetup.ipv4Connection allItemStrArray:[ipv4ConnectionStringList copy] selectedStr:[ipv4ConnectionStringList copy][index]]; TPWeakSelf view.selectionDidChangeCallback = ^(NSUInteger selectedIndex, OMDSelectedItem * _Nonnull item) { TPStrongSelf if (selectedIndex < self.ipv4ConnectionTypeList.count && selectedIndex >= 0) { _self.currentWanSetting.ipv4Info.connectionType = self.ipv4ConnectionTypeList[selectedIndex].protocolId; [_self reloadView]; } }; [view show]; } - (void)clickIpv4VlanPriority { NSMutableArray<NSString *> *ipv4VlanPriorityStringList = [[NSMutableArray alloc] init]; int index = 0; for (int i = 0; i < self.ipv4InternetVlanPriorityList.count; i++) { [ipv4VlanPriorityStringList addObject:[NSString stringWithFormat:@"%@", self.ipv4InternetVlanPriorityList[i]]]; if (self.currentWanSetting.ipv4Info.vlanPriority == [self.ipv4InternetVlanPriorityList[i] integerValue]) { index = i; } } OMDListSelectPopUpView *view = [OMDListSelectPopUpView new]; [view updateWithTitle:gMeshQuickSetup.internetVlanPriority allItemStrArray:[ipv4VlanPriorityStringList copy] selectedStr:[ipv4VlanPriorityStringList copy][index]]; TPWeakSelf view.selectionDidChangeCallback = ^(NSUInteger selectedIndex, OMDSelectedItem * _Nonnull item) { TPStrongSelf if (selectedIndex >= 0 && selectedIndex < self.ipv4InternetVlanPriorityList.count) { _self.currentWanSetting.ipv4Info.vlanPriority = [_self.ipv4InternetVlanPriorityList[selectedIndex] integerValue]; [_self reloadView]; } }; [view show]; } - (void)clickIpv6ConnectionType { NSMutableArray<NSString *> *ipv6ConnectionStringList = [[NSMutableArray alloc] init]; int index = 0; for (int i = 0; i < self.ipv6ConnectionTypeList.count; i++) { [ipv6ConnectionStringList addObject:self.ipv6ConnectionTypeList[i].translateName]; if (self.currentWanSetting.ipv6Info.connectionType == self.ipv6ConnectionTypeList[i].protocolId) { index = i; } } // TPListSelectIndexVC *vc = [[TPListSelectIndexVC alloc] initWithList:[ipv6ConnectionStringList copy] andIndex:index]; // vc.flag = ipv6ConnectionTypeFlag; // [vc updateTitle:gMeshQuickSetup.ipv6Connection]; // vc.delegate = self; // [self.tpNavigationController pushViewController:vc animated:YES]; OMDListSelectPopUpView *view = [OMDListSelectPopUpView new]; [view updateWithTitle:gMeshQuickSetup.ipv6Connection allItemStrArray:[ipv6ConnectionStringList copy] selectedStr:[ipv6ConnectionStringList copy][index]]; TPWeakSelf view.selectionDidChangeCallback = ^(NSUInteger selectedIndex, OMDSelectedItem * _Nonnull item) { TPStrongSelf if (selectedIndex < self.ipv6ConnectionTypeList.count && selectedIndex >= 0) { _self.currentWanSetting.ipv6Info.connectionType = self.ipv6ConnectionTypeList[selectedIndex].protocolId; [_self reloadView]; } }; [view show]; } - (void)clickIpv6GetAddressMethod { [self updateIpv6GetMethodList]; NSMutableArray<NSString *> *ipv6GetAddressMethodStringList = [[NSMutableArray alloc] init]; int index = 0; for (int i = 0; i < self.ipv6GetAddressMethodList.count; i++) { [ipv6GetAddressMethodStringList addObject:[TPSDNControllerCommonMethod getIpv6AddressMethodWithMethod:[TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[self.ipv6GetAddressMethodList[i] integerValue]]]]; if (DMSDNInternetIpv6ConnectionTypePppoe == self.currentWanSetting.ipv6Info.connectionType) { if (self.currentWanSetting.ipv6Info.pppoeInfo.getIpv6AddressMethod == [TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[self.ipv6GetAddressMethodList[i] integerValue]]) { index = i; } } else if (DMSDNInternetIpv6ConnectionTypeDynamic == self.currentWanSetting.ipv6Info.connectionType) { if (self.currentWanSetting.ipv6Info.dynamicInfo.getIpv6AddressMethod == [TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[self.ipv6GetAddressMethodList[i] integerValue]]) { index = i; } } } // TPListSelectIndexVC *vc = [[TPListSelectIndexVC alloc] initWithList:[ipv6GetAddressMethodStringList copy] andIndex:index]; // vc.flag = ipv6GetAddressMethodFlag; // [vc updateTitle:gMeshQuickSetup.getIpv6Address]; // vc.delegate = self; // [self.tpNavigationController pushViewController:vc animated:YES]; OMDListSelectPopUpView *view = [OMDListSelectPopUpView new]; [view updateWithTitle:gMeshQuickSetup.getIpv6Address allItemStrArray:[ipv6GetAddressMethodStringList copy] selectedStr:[ipv6GetAddressMethodStringList copy][index]]; TPWeakSelf view.selectionDidChangeCallback = ^(NSUInteger selectedIndex, OMDSelectedItem * _Nonnull item) { TPStrongSelf if (selectedIndex < _self.ipv6GetAddressMethodList.count) { if (DMSDNInternetIpv6ConnectionTypePppoe == _self.currentWanSetting.ipv6Info.connectionType) { _self.currentWanSetting.ipv6Info.pppoeInfo.getIpv6AddressMethod = [TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[_self.ipv6GetAddressMethodList[selectedIndex] integerValue]]; } else if (DMSDNInternetIpv6ConnectionTypeDynamic == self.currentWanSetting.ipv6Info.connectionType) { _self.currentWanSetting.ipv6Info.dynamicInfo.getIpv6AddressMethod = [TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[_self.ipv6GetAddressMethodList[selectedIndex] integerValue]]; } } [_self reloadView]; }; [view show]; } - (void)didClickISP { NSString *countryDetail = [[TPSimpleCountryTool shareInstance] getCountryDetailWithSimpleCountry:self.currentWanSetting.dslSettingInfo.location]; NSArray *ispArr = [[TPDslIspTool shareInstance] getIspListWithCountry:countryDetail]; NSString *selectIsp = [[TPDslIspTool shareInstance] getCurrentIspWithCountry:countryDetail andIspNum:self.currentWanSetting.dslSettingInfo.isp]; TPBGeneralSelectionController *vc = [[TPBGeneralSelectionController alloc] initWithTitle:gMeshQuickSetup.sLGatewayIsp isPresented:YES confirmButtonTitle:gSDNGlobal.done allItemArray:[self filterIspArr:ispArr] selectedItem:selectIsp supportSearch:NO supportIndex:NO autoSort:NO checkInFront:NO]; TPWeakSelf vc.selectionDidChangeCallback = ^(NSUInteger selectedIndex, NSString * _Nonnull selectedItem) { TPStrongSelf DDLogDebug(@"选择运营商完毕,选择了名称为:[%@]", selectedItem); if (!IsEmptyString(selectedItem)) { NSString *countryDetail = [[TPSimpleCountryTool shareInstance] getCountryDetailWithSimpleCountry:_self.currentWanSetting.dslSettingInfo.location]; _self.currentWanSetting.dslSettingInfo.isp = [[TPDslIspTool shareInstance] getIspNumWithCountry:countryDetail andIsp:selectedItem]; NSArray *dslInfoArray = [[TPDslIspTool shareInstance] getCurrentDslInfoWithCountry:countryDetail andIspNum:_self.currentWanSetting.dslSettingInfo.isp]; if (dslInfoArray.count == 7) { _self.currentWanSetting.dslSettingInfo.modulationType = ModulationTypeADSL; if ([dslInfoArray[1] respondsToSelector:@selector(integerValue)]) { _self.currentWanSetting.dslSettingInfo.vpi = [dslInfoArray[1] integerValue]; } if ([dslInfoArray[2] respondsToSelector:@selector(integerValue)]) { _self.currentWanSetting.dslSettingInfo.vci = [dslInfoArray[2] integerValue]; } _self.currentWanSetting.ipv4Info.connectionType = [SLDSLDataModelTransformMethods getIpv4ConnectionWithStr:dslInfoArray[3]]; if (!IsEmptyString(dslInfoArray[4])) { _self.currentWanSetting.dslSettingInfo.encapMode = [SLDSLDataModelTransformMethods getEncapModeWithStr:dslInfoArray[4]]; } if ([dslInfoArray[5] respondsToSelector:@selector(integerValue)]) { _self.currentWanSetting.ipv4Info.vlanId = [dslInfoArray[5] integerValue]; _self.dataSource.dslVlanIdReadOnly = YES; } } else if (dslInfoArray.count == 6) { _self.currentWanSetting.dslSettingInfo.modulationType = ModulationTypeADSL; if ([dslInfoArray[1] respondsToSelector:@selector(integerValue)]) { _self.currentWanSetting.dslSettingInfo.vpi = [dslInfoArray[1] integerValue]; } if ([dslInfoArray[2] respondsToSelector:@selector(integerValue)]) { _self.currentWanSetting.dslSettingInfo.vci = [dslInfoArray[2] integerValue]; } _self.currentWanSetting.ipv4Info.connectionType = [SLDSLDataModelTransformMethods getIpv4ConnectionWithStr:dslInfoArray[3]]; if (!IsEmptyString(dslInfoArray[4])) { _self.currentWanSetting.dslSettingInfo.encapMode = [SLDSLDataModelTransformMethods getEncapModeWithStr:dslInfoArray[4]]; } _self.dataSource.dslVlanIdReadOnly = NO; } else if (dslInfoArray.count == 4) { if ([dslInfoArray[1] respondsToSelector:@selector(integerValue)]) { _self.currentWanSetting.ipv4Info.vlanId = [dslInfoArray[1] integerValue]; _self.dataSource.dslVlanIdReadOnly = YES; } _self.currentWanSetting.dslSettingInfo.modulationType = ModulationTypeVDSL; _self.currentWanSetting.ipv4Info.connectionType = [SLDSLDataModelTransformMethods getIpv4ConnectionWithStr:dslInfoArray[2]]; } else { _self.dataSource.dslVlanIdReadOnly = NO; } _self.currentWanSetting.dslSettingInfo.isp = [[TPDslIspTool shareInstance] getIspNumWithCountry:countryDetail andIsp:selectedItem]; [_self reloadView]; } }; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:vc]; [self.tpNavigationController presentViewController:navVC animated:YES completion:nil]; } - (void)didClickRegin { NSArray *reginArray = [TPDslIspTool getReginInternationalList]; NSString *countryDetail = [[TPSimpleCountryTool shareInstance] getCountryDetailWithSimpleCountry:self.currentWanSetting.dslSettingInfo.location]; SDNQSSelectCountryTableViewController *vc = [[SDNQSSelectCountryTableViewController alloc]initWithTitle:gMeshQuickSetup.location totalItems:reginArray selectedItem:countryDetail]; vc.delegate = self; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:vc]; [self.tpNavigationController presentViewController:navVC animated:YES completion:nil]; } - (void)didClickDSLModuType { // SLSelectDSLMudoViewController *vc = [[SLSelectDSLMudoViewController alloc] init]; // vc.selectType = self.currentWanSetting.dslSettingInfo.modulationType; // TPWeakSelf // vc.handleSourceBlock = ^(ModulationType selectType) { // TPStrongSelf // if (_self.currentWanSetting.dslSettingInfo.modulationType != selectType) // { // _self.currentWanSetting.ipv4Info.connectionType = DMSDNInternetIpv4ConnectionTypeDhcp; // } // _self.currentWanSetting.dslSettingInfo.modulationType = selectType; // [_self reloadView]; // }; // [self.tpNavigationController pushViewController:vc animated:YES]; NSArray *allStrArray = @[gMeshQuickSetup.dSLModulationTypeVDSL, gMeshQuickSetup.dSLModulationTypeADSL]; NSString *selectedStr = self.currentWanSetting.dslSettingInfo.modulationType == ModulationTypeVDSL? gMeshQuickSetup.dSLModulationTypeVDSL : gMeshQuickSetup.dSLModulationTypeADSL; OMDListSelectPopUpView *view = [OMDListSelectPopUpView new]; [view updateWithTitle:gMeshQuickSetup.dSLModulationType allItemStrArray:allStrArray selectedStr:selectedStr]; TPWeakSelf view.selectionDidChangeCallback = ^(NSUInteger selectedIndex, OMDSelectedItem * _Nonnull item) { TPStrongSelf ModulationType selectType = [item.title isEqualToString:gMeshQuickSetup.dSLModulationTypeVDSL]? ModulationTypeVDSL : ModulationTypeADSL; if (_self.currentWanSetting.dslSettingInfo.modulationType != selectType) { _self.currentWanSetting.ipv4Info.connectionType = DMSDNInternetIpv4ConnectionTypeDhcp; } _self.currentWanSetting.dslSettingInfo.modulationType = selectType; [_self reloadView]; }; [view show]; } //MARK: - Lazy - (UITableView *)tableView { if (_tableView == nil) { _tableView = [TPBCommonTableHelper createKeyboardAvoidingTableViewWithDelegate:self andDataSource:self.dataSource]; } return _tableView; } - (TPAlertViewFactory *)alertViewFactory { if (_alertViewFactory == nil) { _alertViewFactory = [[TPAlertViewFactory alloc] init]; } return _alertViewFactory; } - (TPTextAlertView *)discardAlertView { if (_discardAlertView == nil) { _discardAlertView = [self.alertViewFactory discardAlertViewForSDN]; _discardAlertView.alertViewDelegate = self; } return _discardAlertView; } - (NSArray<DMSDNInternetSupportProtocolInfo *> *)ipv4ConnectionTypeList { if (_ipv4ConnectionTypeList == nil) { _ipv4ConnectionTypeList = [[ALSDNSiteInternetSetting currentInstance].supportInfo.ipv4ProtocalInfoList copy]; } return _ipv4ConnectionTypeList; } - (NSArray<DMSDNInternetSupportProtocolInfo *> *)ipv6ConnectionTypeList { if (_ipv6ConnectionTypeList == nil) { _ipv6ConnectionTypeList = [[ALSDNSiteInternetSetting currentInstance].supportInfo.ipv6ProtocalInfoList copy]; } return _ipv6ConnectionTypeList; } - (NSArray<NSNumber *> *)ipv6GetAddressMethodList { if (_ipv6GetAddressMethodList == nil) { _ipv6GetAddressMethodList = [[NSArray alloc] init]; } return _ipv6GetAddressMethodList; } - (NSArray<NSNumber *> *)ipv4InternetVlanPriorityList { if (_ipv4InternetVlanPriorityList == nil) { NSMutableArray<NSNumber *> *ipv4VlanPriorityList = [[NSMutableArray alloc] init]; for (int i = 0; i < 8; i++) { [ipv4VlanPriorityList addObject:@(i)]; } _ipv4InternetVlanPriorityList = [ipv4VlanPriorityList copy]; } return _ipv4InternetVlanPriorityList; } //MARK: - alertViewDelegate - (void)alertView:(TPAlertView *)alertView clickedButtonAtIndex:(NSInteger)index { if (index == 1) { self.currentWanSetting = self.originalWanSetting; [self.navigationController popViewControllerAnimated:YES]; } } //MARK: - 页面刷新 - (void)reloadView { [self hideKeyboard]; self.tableView.editing = NO; [self.dataSource updateModelWithWanSetting:self.currentWanSetting andPortDetail:self.currentPortDetail]; [self.tableView reloadData]; if (![self.originalWanSetting isEqual:self.currentWanSetting]) { [self.navigationItem.rightBarButtonItem setEnabled:YES]; } else { [self.navigationItem.rightBarButtonItem setEnabled:NO]; } } - (void)isNeedRefreshSaveButton { if (![self.originalWanSetting isEqual:self.currentWanSetting]) { [self.navigationItem.rightBarButtonItem setEnabled:YES]; } else { [self.navigationItem.rightBarButtonItem setEnabled:NO]; } } //MARK: - SDNWANSettingVCDataSourceDelegate - (void)isNeedRefreshView { [self reloadView]; } //MARK: - SDNSelectIndexDelegate - (void)didSelectIndex:(NSInteger)index andFlag:(NSString *)flag { [self.dataSource updateInputGroupViewData]; if ([ipv4ConnectionTypeFlag isEqualToString:flag]) { if (index < self.ipv4ConnectionTypeList.count) { self.currentWanSetting.ipv4Info.connectionType = self.ipv4ConnectionTypeList[index].protocolId; } } else if ([ipv4InternetVlanPriorityFlag isEqualToString:flag]) { if (index < self.ipv4InternetVlanPriorityList.count) { self.currentWanSetting.ipv4Info.vlanPriority = [self.ipv4InternetVlanPriorityList[index] integerValue]; } } else if ([ipv6ConnectionTypeFlag isEqualToString:flag]) { if (index < self.ipv6ConnectionTypeList.count) { self.currentWanSetting.ipv6Info.connectionType = self.ipv6ConnectionTypeList[index].protocolId; } } else if ([ipv6GetAddressMethodFlag isEqualToString:flag]) { if (index < self.ipv6GetAddressMethodList.count) { if (DMSDNInternetIpv6ConnectionTypePppoe == self.currentWanSetting.ipv6Info.connectionType) { self.currentWanSetting.ipv6Info.pppoeInfo.getIpv6AddressMethod = [TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[self.ipv6GetAddressMethodList[index] integerValue]]; } else if (DMSDNInternetIpv6ConnectionTypeDynamic == self.currentWanSetting.ipv6Info.connectionType) { self.currentWanSetting.ipv6Info.dynamicInfo.getIpv6AddressMethod = [TPSDNControllerCommonMethods transformToDMSDNInternetGetIpv6AddressMethodWithMethod:[self.ipv6GetAddressMethodList[index] integerValue]]; } } } [self reloadView]; } //MARK: UIGestureRecognizerDelegate - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if(TPISRTL!=TPISSYSTEMRTL){ return NO; } [self clickBack]; return NO; } //MARK: Location iSP点击事件代理 - (void)didCompleteViewControllerWithTag:(NSInteger)vcTag andSelecteItem:(NSString*)selectedItem { DDLogDebug(@"选择国家地区完毕,选择了名称为:[%@]", selectedItem); if (!IsEmptyString(selectedItem)) { NSString *location = [[TPSimpleCountryTool shareInstance] getSimpleCountryWithCountryDetail:selectedItem]; if (![self.currentWanSetting.dslSettingInfo.location isEqualToString:location]) { self.currentWanSetting.dslSettingInfo.location = location; self.currentWanSetting.dslSettingInfo.isp = 0; self.dataSource.dslVlanIdReadOnly = NO; [self reloadView]; } } } //MARK: - tool - (void)updateIpv6GetMethodList { NSMutableArray<NSNumber *> *ipv6GetAddressMethodIdList = [[NSMutableArray alloc] init]; [ipv6GetAddressMethodIdList addObject:@(DMSDNInternetGetIpv6AddressMethodAuto)]; [ipv6GetAddressMethodIdList addObject:@(DMSDNInternetGetIpv6AddressMethodSlaac)]; [ipv6GetAddressMethodIdList addObject:@(DMSDNInternetGetIpv6AddressMethodDhcpv6)]; if (self.isSupportIpv6NonAddress) { [ipv6GetAddressMethodIdList addObject:@(DMSDNInternetGetIpv6AddressMethodNon_address)]; } if (DMSDNInternetIpv6ConnectionTypePppoe == self.currentWanSetting.ipv6Info.connectionType) { [ipv6GetAddressMethodIdList addObject:@(DMSDNInternetGetIpv6AddressMethodSpecified)]; } self.ipv6GetAddressMethodList = [ipv6GetAddressMethodIdList copy]; } - (void)dealloc { DDLogDebug(@"SDNWANSettingVC dealloc"); } - (BOOL)supportVLANIdRequired { return [[TPSDNControllerClient currentInstance].currentSite.componentNegotiate supportForSiteComponent:DMSDNComponentIdInternetVlanIdRequired ForVersionCode:1]; } - (NSArray *)filterIspArr:(NSArray *)array { NSArray *sortedArray = [array sortedArrayUsingSelector:@selector(compare:)]; NSMutableArray *ispArr = sortedArray.mutableCopy; if ([ispArr containsObject:gMeshQuickSetup.dslISPOther]) { [ispArr removeObject:gMeshQuickSetup.dslISPOther]; } [ispArr addObject:gMeshQuickSetup.dslISPOther]; return ispArr.copy; } @end
最新发布
12-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值