| | |
| | | |
| | | /// |
| | | - (void)addAllChildView{ |
| | | self.backgroundColor = [UIColor clearColor]; |
| | | self.contentView.backgroundColor = [UIColor clearColor]; |
| | | [self.contentView addSubview:self.bgView]; |
| | | [self.bgView addSubview:self.titleLabel]; |
| | | self.backgroundColor = [UIColor whiteColor]; |
| | | self.contentView.backgroundColor = [UIColor whiteColor]; |
| | | // [self.contentView addSubview:self.bgView]; |
| | | [self.contentView addSubview:self.titleLabel]; |
| | | if (@available(iOS 12.0, *)) { |
| | | [self.bgView addSubview:self.shortcutButton]; |
| | | [self.contentView addSubview:self.shortcutButton]; |
| | | } |
| | | [self.contentView addSubview:self.lineView]; |
| | | } |
| | | |
| | | -(UIView*)bgView{ |
| | | if(!_bgView){ |
| | | _bgView = [[UIView alloc]initWithFrame:CGRectMake(20, 6, APP_SCREEN_WIDTH - 40, 60)]; |
| | | _bgView.backgroundColor = UIColor.whiteColor; |
| | | _bgView.layer.cornerRadius = 12; |
| | | _bgView.layer.masksToBounds = YES;// 隐藏边界 |
| | | //-(UIView*)bgView{ |
| | | // if(!_bgView){ |
| | | // _bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APP_SCREEN_WIDTH, 50)]; |
| | | // _bgView.backgroundColor = UIColor.whiteColor; |
| | | //// _bgView.layer.cornerRadius = 12; |
| | | //// _bgView.layer.masksToBounds = YES;// 隐藏边界 |
| | | // } |
| | | // return _bgView; |
| | | //} |
| | | -(UIView*)lineView{ |
| | | if(!_lineView){ |
| | | _lineView = [[UIView alloc]initWithFrame:CGRectMake(16, 49, APP_SCREEN_WIDTH - 32, 1)]; |
| | | _lineView.backgroundColor = HEXCOLORA(0xECEDEE , 1.0); |
| | | } |
| | | return _bgView; |
| | | return _lineView; |
| | | } |
| | | |
| | | |
| | | -(UILabel*)titleLabel{ |
| | | if(!_titleLabel){ |
| | | _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(6, 10, APP_SCREEN_WIDTH - 40 - 206, 40)]; |
| | | _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(16, 0, APP_SCREEN_WIDTH - 32 - 180, 50)]; |
| | | _titleLabel.textColor = COLOR_TEXT; |
| | | _titleLabel.font = Get_FontMediumWithSize(16); |
| | | _titleLabel.font = Get_FontMediumWithSize(14); |
| | | _titleLabel.textAlignment = NSTextAlignmentLeft; |
| | | _titleLabel.numberOfLines = 2; |
| | | } |
| | |
| | | - (INUIAddVoiceShortcutButton*)shortcutButton{ |
| | | if(!_shortcutButton){ |
| | | _shortcutButton = [[INUIAddVoiceShortcutButton alloc] initWithStyle:INUIAddVoiceShortcutButtonStyleWhite]; |
| | | // _shortcutButton.backgroundColor = UIColor.redColor; |
| | | // _shortcutButton.shortcut = [[INShortcut alloc] initWithIntent:self.intent]; |
| | | _shortcutButton.translatesAutoresizingMaskIntoConstraints = YES; |
| | | _shortcutButton.frame = CGRectMake(APP_SCREEN_WIDTH - 40 - 150, 6, 150, 48); |
| | | _shortcutButton.frame = CGRectMake(APP_SCREEN_WIDTH - 160, 2, 160, 46); |
| | | [_shortcutButton setEnabled:NO]; |
| | | // _shortcutButton.delegate = self; |
| | | } |
| | |
| | | // self.titleLabel.text = model.name; |
| | | //} |
| | | |
| | | -(void)initModel:(HDLSiriSceneModel *)model intent:(HDLRunSceneIntent*)intent API_AVAILABLE(ios(12.0)){ |
| | | -(void)initModel:(HDLSiriControlModel *)model intent:(HDLRunSceneIntent*)intent API_AVAILABLE(ios(12.0)){ |
| | | _model = model; |
| | | //判空 |
| | | if (_model == nil) return; |
| | | //处理model数据 |
| | | self.titleLabel.text = model.name; |
| | | self.titleLabel.text = model.controlName; |
| | | if(intent == nil){ |
| | | _shortcutButton.shortcut = [self getINShortcut]; |
| | | _shortcutButton.shortcut = [self getINShortcut:_model]; |
| | | }else{ |
| | | _shortcutButton.shortcut = [[INShortcut alloc] initWithIntent:intent]; |
| | | } |
| | | } |
| | | |
| | | - (INShortcut *) getINShortcut API_AVAILABLE(ios(12.0)){ |
| | | NSString *title = _model.name; |
| | | - (INShortcut *) getINShortcut:(HDLSiriControlModel*)sceneModel API_AVAILABLE(ios(12.0)){ |
| | | NSString *title = sceneModel.controlName; |
| | | HDLRunSceneIntent *intent = [[HDLRunSceneIntent alloc] init]; |
| | | intent.sceneId = _model.userSceneId; |
| | | intent.suggestedInvocationPhrase = title; //在Siri语音设置时显示的建议设置唤起文字 |
| | | intent.sceneName = title; |
| | | intent.controlId = sceneModel.controlId; |
| | | intent.controlName = title; |
| | | intent.homeId = self.homeId; |
| | | intent.actionName = |
| | | intent.controlType = sceneModel.controlType; |
| | | intent.controlJSONStr = sceneModel.controlJSONStr; |
| | | INShortcut *shortCut = [[INShortcut alloc] initWithIntent:intent]; |
| | | return shortCut; |
| | | } |