initial commit

This commit is contained in:
Caleb
2026-03-01 15:59:27 +08:00
commit a9e97d56cb
1426 changed files with 172367 additions and 0 deletions

View File

@@ -0,0 +1,202 @@
//
// SCLiveItemView.m
// SellyCloudSDK_Example
//
// Created by Caleb on 21/7/25.
// Copyright © 2025 Caleb. All rights reserved.
//
#import "SCLiveItemView.h"
@interface SCLiveItemView ()
@property (nonatomic, strong)UIButton *btn;
@property (nonatomic, strong)UIImageView *iconView;
@property (nonatomic, strong)UILabel *titleLabel;
@end
@implementation SCLiveItemView
- (instancetype)init
{
self = [super init];
if (self) {
[self setupView];
}
return self;
}
- (void)btnClick {
//
UIImpactFeedbackGenerator *feedback = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
[feedback impactOccurred];
//
[UIView animateWithDuration:0.1 animations:^{
self.transform = CGAffineTransformMakeScale(0.95, 0.95);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^{
self.transform = CGAffineTransformIdentity;
}];
}];
//
if (self.model.type == SCLiveItemTypeMute ||
self.model.type == SCLiveItemTypeCameraToggle) {
self.model.isSelected = !self.model.isSelected;
[self updateIconAndTitle];
}
if (self.model.clickCallback) {
self.model.clickCallback();
}
}
- (void)setupView {
//
[self addSubview:self.btn];
[self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
//
[self addSubview:self.iconView];
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(8);
make.centerX.equalTo(self);
make.width.height.offset(32);
}];
//
[self addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.iconView.mas_bottom).offset(4);
make.left.right.equalTo(self);
make.height.offset(16);
}];
}
- (void)updateIconAndTitle {
NSString *iconName = @"";
NSString *title = @"";
switch (self.model.type) {
// ========== ==========
case SCLiveItemTypeSwitchCamera: //
iconName = @"arrow.triangle.2.circlepath.camera";
title = @"翻转";
break;
case SCLiveItemTypeMute: // /
if (self.model.isSelected) {
iconName = @"mic.slash.fill";
title = @"取消静音";
} else {
iconName = @"mic.fill";
title = @"静音";
}
break;
case SCLiveItemTypeCameraToggle: //
if (self.model.isSelected) {
iconName = @"video.slash.fill";
title = @"开启摄像头";
} else {
iconName = @"video.fill";
title = @"关闭摄像头";
}
break;
case SCLiveItemTypeCapture: //
iconName = @"camera.fill";
title = @"截图";
break;
case SCLiveItemTypeBackgroundImage: //
iconName = @"photo.fill";
title = @"背景图";
break;
// ========== ==========
case SCLiveItemTypePlayPause: // /
if (self.model.isSelected) {
iconName = @"pause.circle.fill";
title = @"暂停";
} else {
iconName = @"play.circle.fill";
title = @"播放";
}
break;
case SCLiveItemTypeVolume: //
if (self.model.isSelected) {
iconName = @"speaker.slash.fill";
title = @"取消静音";
} else {
iconName = @"speaker.wave.3.fill";
title = @"静音";
}
break;
case SCLiveItemTypeScreenshot: //
iconName = @"camera.fill";
title = @"截图";
break;
case SCLiveItemTypeSeekForward: //
iconName = @"goforward.10";
title = @"快进10秒";
break;
case SCLiveItemTypeSettings: // /
iconName = @"gearshape.fill";
title = @"设置";
break;
case SCLiveItemTypePiP: // /
iconName = @"pip";
title = @"画中画";
break;
default:
iconName = @"circle.fill";
title = @"";
break;
}
UIImage *icon = [UIImage systemImageNamed:iconName];
self.iconView.image = icon;
self.titleLabel.text = title;
}
- (void)setModel:(SCLiveItemModel *)model {
_model = model;
[self updateIconAndTitle];
}
- (UIButton *)btn {
if (!_btn) {
_btn = [UIButton buttonWithType:UIButtonTypeCustom];
_btn.backgroundColor = [UIColor clearColor];
[_btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
}
return _btn;
}
- (UIImageView *)iconView {
if (!_iconView) {
_iconView = [[UIImageView alloc] init];
_iconView.contentMode = UIViewContentModeScaleAspectFit;
_iconView.tintColor = [UIColor whiteColor];
}
return _iconView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.font = [UIFont systemFontOfSize:11 weight:UIFontWeightMedium];
_titleLabel.textColor = [UIColor whiteColor];
}
return _titleLabel;
}
@end