Skip to content

Commit

Permalink
feat: 操作回放加入区位信息的展示。
Browse files Browse the repository at this point in the history
  • Loading branch information
Hulk committed Oct 20, 2021
1 parent 2a5c43a commit e173496
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import <Foundation/Foundation.h>
#import "PrismInstructionAreaInfoUtil.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -21,6 +22,7 @@ typedef NS_ENUM(NSUInteger, PrismBehaviorDescType) {
@property (nonatomic, assign) PrismBehaviorDescType descType;
@property (nonatomic, copy) NSString *descContent;
@property (nonatomic, copy) NSString *descTime;
@property (nonatomic, assign) PrismInstructionArea areaInfo;
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ + (PrismBehaviorTextModel *)translateWithModel:(PrismBehaviorVideoModel *)model
textModel.operationName = @"点击";
textModel.descType = PrismBehaviorDescTypeNone;
textModel.descTime = model.descTime.length ? model.descTime : @" ";
textModel.areaInfo = [model.instructionFormatter instructionFragmentContentWithType:PrismInstructionFragmentTypeViewQuadrant].integerValue;

NSArray<NSString*> *eventArray = [model.instructionFormatter instructionFragmentWithType:PrismInstructionFragmentTypeEvent];
NSArray<NSString*> *h5ViewArray = [model.instructionFormatter instructionFragmentWithType:PrismInstructionFragmentTypeH5View];
Expand Down
161 changes: 159 additions & 2 deletions iOS/DiDiPrismDemo/DiDiPrismDemo/View/BehaviorTextDescViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
#import <SDWebImage/SDWebImage.h>
#import "UIColor+PrismExtends.h"

#define kPhoneWidth 22
#define kPhoneHeight 42

@interface BehaviorTextDescViewCell()
@property (nonatomic, strong) UILabel *operationLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *phoneView;
@property (nonatomic, strong) UIView *phoneBarView;
@property (nonatomic, strong) UIView *locationView;

@end

Expand Down Expand Up @@ -79,13 +85,16 @@ - (void)initView {
[self.contentView addSubview:self.contentImageView];
[self.contentView addSubview:self.timeLabel];
[self.contentView addSubview:self.failFlagLabel];
[self.contentView addSubview:self.phoneView];
[self.contentView addSubview:self.phoneBarView];
[self.contentView addSubview:self.locationView];

[self.indexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(18);
make.centerY.equalTo(self.contentView);
}];
[self.operationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.indexLabel).offset(55);
make.left.equalTo(self.indexLabel).offset(37);
make.centerY.equalTo(self.contentView);
}];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
Expand All @@ -95,6 +104,18 @@ - (void)initView {
[self.failFlagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.contentView).offset(1);
}];
[self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.operationLabel.mas_right).offset(23);
make.centerY.equalTo(self.contentView);
make.width.mas_equalTo(kPhoneWidth);
make.height.mas_equalTo(kPhoneHeight);
}];
[self.phoneBarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.phoneView);
make.centerX.equalTo(self.phoneView);
make.width.mas_equalTo(10);
make.height.mas_equalTo(4);
}];
}

#pragma mark - setters
Expand All @@ -106,7 +127,6 @@ - (void)setTextModel:(PrismBehaviorTextModel *)textModel {
switch (_textModel.descType) {
case PrismBehaviorDescTypeNone:
{
self.operationLabel.text = nil;
self.contentLabel.text = @"[无法翻译]";
self.contentLabel.hidden = NO;
self.contentImageView.hidden = YES;
Expand Down Expand Up @@ -155,6 +175,112 @@ - (void)setTextModel:(PrismBehaviorTextModel *)textModel {
break;
}


CGFloat width = 0;
CGFloat height = 0;
CGFloat left = 0;
CGFloat top = 0;

self.phoneView.hidden = NO;
self.phoneView.text = nil;
self.phoneBarView.hidden = NO;
self.locationView.hidden = NO;

switch (_textModel.areaInfo) {
case PrismInstructionAreaUp:
{
width = 6;
height = kPhoneHeight / 2;
left = kPhoneWidth / 2 - 3;
top = 0;
}
break;
case PrismInstructionAreaBottom:
{
width = 6;
height = kPhoneHeight / 2;
left = kPhoneWidth / 2 - 3;
top = kPhoneHeight / 2;
}
break;
case PrismInstructionAreaLeft:
{
width = kPhoneWidth / 2;
height = 6;
left = 0;
top = kPhoneHeight / 2 - 3;
}
break;
case PrismInstructionAreaRight:
{
width = kPhoneWidth / 2;
height = 6;
left = kPhoneWidth / 2;
top = kPhoneHeight / 2 - 3;
}
break;
case PrismInstructionAreaCenter:
{
width = 12;
height = 18;
left = kPhoneWidth / 2 - 6;
top = kPhoneHeight / 2 - 9;
}
break;
case PrismInstructionAreaUpLeft:
{
width = kPhoneWidth / 2;
height = kPhoneHeight / 2;
left = 0;
top = 0;
}
break;
case PrismInstructionAreaUpRight:
{
width = kPhoneWidth / 2;
height = kPhoneHeight / 2;
left = kPhoneWidth / 2;
top = 0;
}
break;
case PrismInstructionAreaBottomLeft:
{
width = kPhoneWidth / 2;
height = kPhoneHeight / 2;
left = 0;
top = kPhoneHeight / 2;
}
break;
case PrismInstructionAreaBottomRight:
{
width = kPhoneWidth / 2;
height = kPhoneHeight / 2;
left = kPhoneWidth / 2;
top = kPhoneHeight / 2;
}
break;
case PrismInstructionAreaCanScroll:
{
self.phoneView.text = @"列表";
}
break;
default:
{
self.phoneView.hidden = YES;
self.phoneBarView.hidden = YES;
self.locationView.hidden = YES;
}
break;
}

[self.locationView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
make.height.mas_equalTo(height);
make.left.equalTo(self.phoneView).offset(left);
make.top.equalTo(self.phoneView).offset(top);
}];


[self setNeedsUpdateConstraints];
[self updateConstraintsIfNeeded];
}
Expand Down Expand Up @@ -218,4 +344,35 @@ - (UILabel *)failFlagLabel {
}
return _failFlagLabel;
}

- (UILabel *)phoneView {
if (!_phoneView) {
_phoneView = [[UILabel alloc] init];
_phoneView.backgroundColor = [UIColor clearColor];
_phoneView.layer.borderWidth = 1.0;
_phoneView.layer.borderColor = [UIColor prism_colorWithHexString:@"#666666"].CGColor;
_phoneView.layer.cornerRadius = 3.0;
_phoneView.textColor = [UIColor prism_colorWithHexString:@"#666666"];
_phoneView.font = [UIFont systemFontOfSize:8];
_phoneView.textAlignment = NSTextAlignmentCenter;
}
return _phoneView;
}

- (UIView *)phoneBarView {
if (!_phoneBarView) {
_phoneBarView = [[UIView alloc] init];
_phoneBarView.backgroundColor = [UIColor prism_colorWithHexString:@"#666666"];
_phoneBarView.layer.cornerRadius = 1.0;
}
return _phoneBarView;
}

- (UIView *)locationView {
if (!_locationView) {
_locationView = [[UIView alloc] init];
_locationView.backgroundColor = [[UIColor prism_colorWithHexString:@"#666666"] colorWithAlphaComponent:0.6];
}
return _locationView;
}
@end

0 comments on commit e173496

Please sign in to comment.