118 lines
4.0 KiB
Objective-C
118 lines
4.0 KiB
Objective-C
//
|
|
// QXRoomWelcomeView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/6/23.
|
|
//
|
|
|
|
#import "QXRoomWelcomeView.h"
|
|
#import "QXTextView.h"
|
|
#import "QXMineNetwork.h"
|
|
|
|
@interface QXRoomWelcomeView()<UIGestureRecognizerDelegate,UITextViewDelegate>
|
|
@property (nonatomic,strong)UIView *bgView;
|
|
@property (nonatomic,strong)UILabel *titleLabel;
|
|
@property (nonatomic,strong)UIButton *saveBtn;
|
|
@property (nonatomic,strong)QXTextView *textView;
|
|
@end
|
|
|
|
@implementation QXRoomWelcomeView
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
|
tap.delegate = self;
|
|
[self addGestureRecognizer:tap];
|
|
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 348)];
|
|
self.bgView.backgroundColor = [UIColor whiteColor];
|
|
[self.bgView addRoundedCornersWithRadius:16];
|
|
[self addSubview:self.bgView];
|
|
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 100, 24)];
|
|
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
|
self.titleLabel.textColor = QXConfig.textColor;
|
|
self.titleLabel.text = @"编辑房间公告";
|
|
[self.bgView addSubview:self.titleLabel];
|
|
|
|
self.saveBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bgView.width-40-6, 6, 40, 40)];
|
|
[self.saveBtn setTitle:QXText (@"保存") forState:(UIControlStateNormal)];
|
|
self.saveBtn.titleLabel.font = [UIFont systemFontOfSize:14];;
|
|
[self.saveBtn setTitleColor:RGB16(0xFF8ACC) forState:(UIControlStateNormal)];
|
|
[self.saveBtn addTarget:self action:@selector(saveAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgView addSubview:self.saveBtn];
|
|
|
|
self.textView = [[QXTextView alloc] initWithFrame:CGRectMake(16, self.titleLabel.bottom+12, self.bgView.width-32, 150)];
|
|
self.textView.delegate = self;
|
|
[self.textView addRoundedCornersWithRadius:11];
|
|
self.textView.font = [UIFont systemFontOfSize:12];
|
|
self.textView.textColor = QXConfig.textColor;
|
|
self.textView.placehoulder = QXText(@"本房间严禁刷屏,禁止非法广告宣传,禁止引战地域黑,语言攻击等");
|
|
self.textView.backgroundColor = RGB16(0xEFF2F8);
|
|
[self.bgView addSubview:self.textView];
|
|
}
|
|
|
|
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
|
return touch.view == self;
|
|
}
|
|
-(void)textViewDidBeginEditing:(UITextView *)textView{
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT-348-200;
|
|
}];
|
|
}
|
|
-(void)textViewDidEndEditing:(UITextView *)textView{
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT-348;
|
|
}];
|
|
}
|
|
|
|
|
|
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
|
|
if( [ @"\n" isEqualToString: text]){
|
|
|
|
//你的响应方法
|
|
[textView endEditing:YES];
|
|
return NO;
|
|
|
|
}
|
|
|
|
return YES;
|
|
}
|
|
-(void)saveAction{
|
|
MJWeakSelf
|
|
if (![self.textView.text isExist]) {
|
|
showToast(@"请输入房间公告");
|
|
return;
|
|
}
|
|
[QXMineNetwork roomInfoEditWithRoomId:self.roomId room_name:@"" room_cover:@"" room_intro:self.textView.text room_background:@"" successBlock:^(NSDictionary * _Nonnull dict) {
|
|
if (self.setIntroduceBlock) {
|
|
self.setIntroduceBlock(weakSelf.textView.text);
|
|
}
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)showInView:(UIView *)view{
|
|
[view addSubview:self];
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT-348;
|
|
}];
|
|
}
|
|
-(void)hide{
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
@end
|