Files
yinmeng-ios-store/yinmeng-ios/DingDangApp/CodeClass/Room/View/PopView/RoomDetailView.m
2023-12-07 10:50:21 +08:00

261 lines
9.6 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// RoomInfoView.m
// DingDangApp
//
// Created by apple on 2023/6/26.
//
#import "RoomDetailView.h"
@interface RoomDetailView ()
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UIView *topLineView;
@property (nonatomic,strong) UIView *bottomLineView;
@property (nonatomic,strong) DDAnimateImageView *headerImageView;
@property (nonatomic, strong) UIImageView * typeImaegView;
@property (nonatomic, strong) UILabel * roomTitleLabel;
@property (nonatomic, strong) UIButton * IDBtn;
@property (nonatomic, strong) UIButton * reportButton;
@property (nonatomic, strong) UIButton * collectButton;
@property (nonatomic, strong) UITextView * textView;
@end
@implementation RoomDetailView
- (void)initView{
[super initView];
[self jk_setRoundedCorners:UIRectCornerTopLeft|UIRectCornerTopRight radius:20];
[self addSubview:self.titleLabel];
[self addSubview:self.topLineView];
[self addSubview:self.headerImageView];
[self addSubview:self.roomTitleLabel];
[self addSubview:self.typeImaegView];
[self addSubview:self.IDBtn];
[self addSubview:self.textView];
[self addSubview:self.bottomLineView];
[self addSubview:self.reportButton];
[self addSubview:self.collectButton];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(50);
make.top.right.left.equalTo(self);
}];
[self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.height.mas_equalTo(.5);
make.top.equalTo(self.titleLabel.mas_bottom);
}];
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.width.mas_equalTo(68);
make.top.equalTo(self.topLineView.mas_bottom).offset(15);
make.left.equalTo(self).offset(15);
}];
[self.roomTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.headerImageView.mas_right).offset(10);
make.top.equalTo(self.headerImageView).offset(3.5);
make.height.mas_equalTo(16);
make.right.equalTo(self).inset(15);
}];
[self.typeImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.roomTitleLabel);
make.top.equalTo(self.roomTitleLabel.mas_bottom).offset(5);
make.width.mas_equalTo(30);
make.height.mas_equalTo(16);
}];
[self.IDBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.typeImaegView.mas_bottom).offset(10);
make.bottom.equalTo(self.headerImageView).inset(3.5);
make.right.left.equalTo(self.roomTitleLabel);
}];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.headerImageView.mas_bottom).offset(15);
make.left.equalTo(self).offset(20);
make.right.equalTo(self).inset(20);
}];
[self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.height.mas_equalTo(.5);
make.top.equalTo(self.textView.mas_bottom);
}];
[self.reportButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.bottomLineView.mas_bottom).offset(10);
make.bottom.equalTo(self).inset(KSAFEAREA_BOTTOM_HEIHGHT);
make.left.equalTo(self);
make.height.mas_equalTo(78);
}];
[self.collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.equalTo(self.reportButton);
make.width.equalTo(self.reportButton).multipliedBy(1);
make.left.equalTo(self.reportButton.mas_right);
make.right.equalTo(self);
}];
[self.headerImageView layoutIfNeeded];
[self.headerImageView jk_setRoundedCorners:UIRectCornerAllCorners radius:8];
}
- (void)reportButtonClick{
if(self.reportBlock){
self.reportBlock();
}
[self dismiss];
}
- (void)collectButtonClick{
if(self.collectBlock){
self.collectBlock(!self.collectButton.isSelected);
}
[self dismiss];
}
- (void)IDBtnClick{
if([ToolsObject isBlankString:self.roomInfoModel.room_info.room_number].length >0){
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = self.roomInfoModel.room_info.room_number;
[ToolsObject addPopVieToText:@"已复制ID到剪切板"];
}
}
- (void)setRoomInfoModel:(RoomInfoModel *)roomInfoModel{
_roomInfoModel = roomInfoModel;
RoomModel * model = roomInfoModel.room_info;
[self.headerImageView ddSetAnimatedImageView:[NSURL URLWithString:model.room_head?:@""] placeholderImage:nil];
self.roomTitleLabel.text = model.room_name?:@"";
[self.IDBtn setTitle:[NSString stringWithFormat:@"ID:%@",model.room_number] forState:UIControlStateNormal];
[self.IDBtn setImage:KGetImage(@"com_8") forState:UIControlStateNormal];
[self.IDBtn setImagePositionWithType:SSImagePositionTypeRight spacing:5];
self.textView.text = model.room_desc?:@"";
switch ([model.room_type integerValue]) {
case 1://房间类型1:娱乐2:女神3:男神4交友
{
self.typeImaegView.image = KGetImage(@"");
}
break;
case 2:
{
self.typeImaegView.image = KGetImage(@"");
}
break;
case 3:
{
self.typeImaegView.image = KGetImage(@"");
}
break;
case 4:
{
self.typeImaegView.image = KGetImage(@"");
}
break;
default:
break;
}
self.collectButton.selected = roomInfoModel.is_collect;
}
- (UILabel *)titleLabel{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = @"房间详情";
_titleLabel.backgroundColor = UIColor.whiteColor;
_titleLabel.textColor = [UIColor jk_colorWithHex:0x333333];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.font = KFont(18);
}
return _titleLabel;
}
- (UIView *)topLineView{
if (!_topLineView) {
_topLineView = [[UIView alloc] init];
_topLineView.backgroundColor = [UIColor jk_colorWithHex:0xebebeb];
}return _topLineView;
}
- (UIView *)bottomLineView{
if (!_bottomLineView) {
_bottomLineView = [[UIView alloc] init];
_bottomLineView.backgroundColor = [UIColor jk_colorWithHex:0xebebeb];
}return _bottomLineView;
}
- (UITextView *)textView{
if (!_textView) {
_textView = [[UITextView alloc] init];
_textView.textColor = [UIColor jk_colorWithHex:0x666666];
_textView.font = KFont(14);
_textView.scrollEnabled = YES;
_textView.userInteractionEnabled = NO;
}return _textView;
}
- (UIButton *)reportButton{
if (!_reportButton) {
_reportButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_reportButton setTitle:@"举报房间" forState:UIControlStateNormal];
[_reportButton setImage:KGetImage(@"") forState:UIControlStateNormal];
_reportButton.titleLabel.font = KFont(12);
[_reportButton addTarget:self action:@selector(reportButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_reportButton setTitleColor:[UIColor jk_colorWithHex:0x333333] forState:UIControlStateNormal];
[_reportButton setImagePositionWithType:SSImagePositionTypeTop spacing:10];
}return _reportButton;
}
- (UIButton *)collectButton{
if (!_collectButton) {
_collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_collectButton setTitle:@"收藏房间" forState:UIControlStateNormal];
[_collectButton setTitle:@"已收藏" forState:UIControlStateSelected];
[_collectButton setImage:KGetImage(@"") forState:UIControlStateNormal];
[_collectButton setImage:KGetImage(@"") forState:UIControlStateSelected];
[_collectButton addTarget:self action:@selector(collectButtonClick) forControlEvents:UIControlEventTouchUpInside];
_collectButton.titleLabel.font = KFont(12);
[_collectButton setTitleColor:[UIColor jk_colorWithHex:0x333333] forState:UIControlStateNormal];
[_collectButton setImagePositionWithType:SSImagePositionTypeTop spacing:10];
}
return _collectButton;
}
- (DDAnimateImageView *)headerImageView{
if (!_headerImageView) {
_headerImageView = [[DDAnimateImageView alloc] init];
_headerImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _headerImageView;
}
- (UIImageView *)typeImaegView{
if (!_typeImaegView) {
_typeImaegView = [[UIImageView alloc] init];
_typeImaegView.contentMode = UIViewContentModeScaleAspectFill;
}
return _typeImaegView;
}
- (UILabel *)roomTitleLabel{
if (!_roomTitleLabel) {
_roomTitleLabel = [[UILabel alloc] init];
_roomTitleLabel.textColor = [UIColor jk_colorWithHex:0x333333];
_roomTitleLabel.font = KFont(16);
_roomTitleLabel.textAlignment = NSTextAlignmentLeft;
}
return _roomTitleLabel;
}
- (UIButton *)IDBtn{
if (!_IDBtn) {
_IDBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_IDBtn setTitle:@"ID:0" forState:UIControlStateNormal];
[_IDBtn setImage:KGetImage(@"") forState:UIControlStateNormal];
[_IDBtn addTarget:self action:@selector(IDBtnClick) forControlEvents:UIControlEventTouchUpInside];
_IDBtn.titleLabel.font = KFont(14);
[_IDBtn setTitleColor:[UIColor jk_colorWithHex:0x999999] forState:UIControlStateNormal];
[_IDBtn setImagePositionWithType:SSImagePositionTypeRight spacing:5];
[_IDBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
}
return _IDBtn;
}
@end