123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- //
- // YMSoundShowcaseTeleprompterView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/8.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMSoundShowcaseTeleprompterView.h"
- #import "YMSoundShowcaseViewModel.h"
- @interface YMSoundShowcaseTeleprompterView ()
- /// 声音展示VM
- @property (nonatomic, strong) YMSoundShowcaseViewModel *viewModel;
- /// 题词器提示标签
- @property (nonatomic, strong) UILabel *teleprompterTipsLb;
- /// 题词器基础视图
- @property (nonatomic, strong) UIView *teleprompterBaseView;
- /// 题词器标题标签
- @property (nonatomic, strong) UILabel *teleprompterTitleLb;
- /// 题词器内容标签
- @property (nonatomic, strong) UILabel *teleprompterContentLb;
- /// 题词器刷新视图
- @property (nonatomic, strong) UIView *teleprompterRefreshView;
- /// 题词器刷新图标
- @property (nonatomic, strong) UIImageView *teleprompterRefreshIcon;
- /// 题词器刷新图标
- @property (nonatomic, strong) UILabel *teleprompterRefreshLb;
- @end
- @implementation YMSoundShowcaseTeleprompterView
- - (void)ym_setupViews{
-
- [self addSubview:self.teleprompterTipsLb];
- [self addSubview:self.teleprompterBaseView];
- [self.teleprompterBaseView addSubview:self.teleprompterTitleLb];
- [self.teleprompterBaseView addSubview:self.teleprompterContentLb];
- [self.teleprompterBaseView addSubview:self.teleprompterRefreshView];
- [self.teleprompterRefreshView addSubview:self.teleprompterRefreshIcon];
- [self.teleprompterRefreshView addSubview:self.teleprompterRefreshLb];
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
- [self.teleprompterTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(15));
- make.left.equalTo(self).offset(adapt(15));
- }];
-
- [self.teleprompterBaseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.teleprompterTipsLb.mas_bottom).offset(adapt(5));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- make.bottom.equalTo(self).offset(adapt(-15));
- }];
-
- [self.teleprompterTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.teleprompterBaseView).offset(adapt(20));
- make.left.equalTo(self.teleprompterBaseView).offset(adapt(10));
- }];
-
- [self.teleprompterContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.teleprompterTitleLb.mas_bottom).offset(adapt(20));
- make.left.equalTo(self.teleprompterBaseView).offset(adapt(10));
- make.right.equalTo(self.teleprompterBaseView).offset(adapt(-10));
- make.bottom.equalTo(self.teleprompterBaseView).offset(adapt(-20));
- }];
-
- [self.teleprompterRefreshView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.teleprompterTitleLb.mas_centerY);
- make.right.equalTo(self.teleprompterBaseView).offset(adapt(-10));
- }];
-
- [self.teleprompterRefreshIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.teleprompterRefreshView).offset(adapt(5));
- make.left.equalTo(self.teleprompterRefreshView).offset(adapt(5));
- make.bottom.equalTo(self.teleprompterRefreshView).offset(adapt(-5));
- make.width.height.mas_equalTo(adapt(15));
- }];
-
- [self.teleprompterRefreshLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.teleprompterRefreshView.mas_centerY);
- make.left.equalTo(self.teleprompterRefreshIcon.mas_right).offset(adapt(5));
- make.right.equalTo(self.teleprompterRefreshView).offset(adapt(-5));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMSoundShowcaseViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- RAC(self.teleprompterContentLb, attributedText) = RACObserve(self.viewModel, voiceTeleprompterContent);
-
- }
- - (UILabel *)teleprompterTipsLb{
- if (!_teleprompterTipsLb) {
- _teleprompterTipsLb = [[UILabel alloc]init];
- _teleprompterTipsLb.font = LCFont(12);
- _teleprompterTipsLb.textColor = HexColorFromRGB(0x989898);
- _teleprompterTipsLb.textAlignment = NSTextAlignmentLeft;
- _teleprompterTipsLb.text = @"展示你的声线,更有吸引力";
- }
- return _teleprompterTipsLb;
- }
- - (UIView *)teleprompterBaseView{
- if (!_teleprompterBaseView) {
- _teleprompterBaseView = [[UIView alloc]init];
- _teleprompterBaseView.backgroundColor = HexColorFromRGB(0xf6f6f6);
- _teleprompterBaseView.layer.cornerRadius = adapt(10);
- _teleprompterBaseView.layer.masksToBounds = YES;
- }
- return _teleprompterBaseView;
- }
- - (UILabel *)teleprompterTitleLb{
- if (!_teleprompterTitleLb) {
- _teleprompterTitleLb = [[UILabel alloc]init];
- _teleprompterTitleLb.font = LCBoldFont(16);
- _teleprompterTitleLb.textColor = HexColorFromRGB(0x333333);
- _teleprompterTitleLb.textAlignment = NSTextAlignmentLeft;
- _teleprompterTitleLb.text = @"读一段话";
- }
- return _teleprompterTitleLb;
- }
- - (UILabel *)teleprompterContentLb{
- if (!_teleprompterContentLb) {
- _teleprompterContentLb = [[UILabel alloc]init];
- _teleprompterContentLb.font = LCFont(14);
- _teleprompterContentLb.textColor = HexColorFromRGB(0x262626);
- _teleprompterContentLb.textAlignment = NSTextAlignmentLeft;
- _teleprompterContentLb.text = @"*******";
- _teleprompterContentLb.numberOfLines = 0;
- }
- return _teleprompterContentLb;
- }
- - (UIView *)teleprompterRefreshView{
- if (!_teleprompterRefreshView) {
- _teleprompterRefreshView = [[UIView alloc]init];
- _teleprompterRefreshView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_teleprompterRefreshView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel refreshVoiceTelepromptertData];
- }];
- }
- return _teleprompterRefreshView;
- }
- - (UIImageView *)teleprompterRefreshIcon{
- if (!_teleprompterRefreshIcon) {
- _teleprompterRefreshIcon = [[UIImageView alloc]init];
- _teleprompterRefreshIcon.image = ImageByName(@"ym_sound_showcase_refresh_icon");
- }
- return _teleprompterRefreshIcon;
- }
- - (UILabel *)teleprompterRefreshLb{
- if (!_teleprompterRefreshLb) {
- _teleprompterRefreshLb = [[UILabel alloc]init];
- _teleprompterRefreshLb.font = LCFont(12);
- _teleprompterRefreshLb.textColor = HexColorFromRGB(0x262626);
- _teleprompterRefreshLb.textAlignment = NSTextAlignmentCenter;
- _teleprompterRefreshLb.text = @"换一句";
- }
- return _teleprompterRefreshLb;
- }
- @end
|