jiGuangXieZuo/ProductApp/ProductApp/ProductMain/引导/课堂写作/view/StartKTXZWenZhangView.m

467 lines
17 KiB
Objective-C

//
// StartKTXZWenZhangView.m
// ProductApp
//
// Created by 工作 on 2024/9/21.
//
#import "StartKTXZWenZhangView.h"
#import "StartKTXZPGView.h"
#import "BaseViewController.h"
@interface StartKTXZWenZhangView ()<UIScrollViewDelegate>
///
@property (nonatomic , strong) UIScrollView *scvback0;
///
@property (nonatomic , strong) UILabel *lbtitle;
@property (nonatomic , strong) UILabel *lbname;
@property (nonatomic , strong) UILabel *lbinfo;
///
@property (nonatomic , strong) PGJUILabel *lbyq;
@property (nonatomic , strong) PGJUILabel *lbbz;
@property (nonatomic , strong) UIScrollView *scvback;
@property (nonatomic , strong) UIView *viewback;
@property (nonatomic , assign) float viewbackHeight;
///
@property (nonatomic , strong) UIView *viewbackwz;
@property (nonatomic , strong) ViewLable *lbwz;
@property (nonatomic , assign) BOOL isDragging;
@property (nonatomic , assign) BOOL isendDraw;
@end
@implementation StartKTXZWenZhangView
-(id)initWithFrame:(CGRect)frame
{
if(self = [super initWithFrame:frame])
{
UIScrollView *scvback0 = [[UIScrollView alloc] init];
[self addSubview:scvback0];
[scvback0 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.offset(0);
make.width.height.equalTo(self);
}];
_scvback0 = scvback0;
[self drawScrollBack];
if (@available(iOS 11.0, *)) {
scvback0.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else{
self.viewController.automaticallyAdjustsScrollViewInsets =NO;
}
UIScrollView *scvback = [[UIScrollView alloc] init];
[scvback setShowsVerticalScrollIndicator:NO];
[self addSubview:scvback];
[scvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(0);
make.top.offset(KMagrinTop);
make.width.offset(UISCREEN_WIDTH);
make.height.offset(UISCREEN_HEIGHT-KMagrinTop-TabHeight-20);
}];
[scvback setDelegate:self];
_scvback = scvback;
UILabel *lbtitle = [[UILabel alloc] init];
[lbtitle setText:@"标题"];
[lbtitle setTextColor:[UIColor whiteColor]];
[lbtitle setTextAlignment:NSTextAlignmentLeft];
[lbtitle setFont:[UIFont systemFontOfSize:18]];
[scvback addSubview:lbtitle];
[lbtitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.offset(0);
make.height.offset(44);
}];
_lbtitle= lbtitle;
UILabel *lbname = [[UILabel alloc] init];
[lbname setTextColor:[UIColor whiteColor]];
[lbname setTextAlignment:NSTextAlignmentLeft];
[lbname setFont:[UIFont fontWithName:@"AlimamaShuHeiTi-Bold" size:40]];
[scvback addSubview:lbname];
[lbname mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(scvback);
make.top.offset(44);
}];
_lbname = lbname;
UILabel *lbinfo = [[UILabel alloc] init];
[lbinfo setTextColor:[UIColor whiteColor]];
[lbinfo setTextAlignment:NSTextAlignmentCenter];
[lbinfo setFont:[UIFont systemFontOfSize:14]];
[scvback addSubview:lbinfo];
[lbinfo mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(lbname);
make.top.equalTo(lbname.mas_bottom).offset(8);
make.height.offset(30);
make.width.offset(200);
}];
[lbinfo setBackgroundColor:RGBCOLOR(253, 154, 20)];
[lbinfo.layer setMasksToBounds:YES];
[lbinfo.layer setCornerRadius:15];
_lbinfo = lbinfo;
UIImage *image = [UIImage imageNamed:@"yd_kt_bc"];
float fheight = UISCREEN_WIDTH*image.size.height/image.size.width-40;
image = nil;
UIView *viewback = [[UIView alloc] init];
[viewback setBackgroundColor:[UIColor whiteColor]];
[scvback addSubview:viewback];
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(16);
make.width.offset(UISCREEN_WIDTH-32);
make.top.offset(fheight);
make.height.offset(208);
}];
_viewback = viewback;
[self drawInfoView];
UIView *viewbackwz = [[UIView alloc] init];
[viewbackwz setBackgroundColor:[UIColor whiteColor]];
[scvback addSubview:viewbackwz];
[viewbackwz mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(viewback);
make.top.equalTo(viewback.mas_bottom).offset(30);
make.height.offset(100);
}];
_viewbackwz = viewbackwz;
[self drawWenZhangView];
[scvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(viewbackwz).offset(50);
}];
UIButton *btpigai = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH-32, 44)];
[btpigai setTitle:@"按照写作标准-批改作文" forState:UIControlStateNormal];
[btpigai setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btpigai.titleLabel setFont:[UIFont boldSystemFontOfSize:16]];
[btpigai.layer setMasksToBounds:YES];
[btpigai.layer setCornerRadius:5];
[self addSubview:btpigai];
[btpigai mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(16);
make.right.equalTo(self).offset(-16);
make.bottom.equalTo(self).offset(-20);
make.height.offset(44);
}];
[btpigai addTarget:self action:@selector(pigaiAction) forControlEvents:UIControlEventTouchUpInside];
[Tools changedView:btpigai colors:MainJBColors startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
}
return self;
}
-(void)drawScrollBack
{
UIImage *image = [UIImage imageNamed:@"yd_kt_bc"];
UIImageView *imgvback = [[UIImageView alloc] init];
[imgvback setImage:image];
[self.scvback0 addSubview:imgvback];
[imgvback mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.width.top.equalTo(self.scvback0);
make.height.offset(UISCREEN_WIDTH*image.size.height/image.size.width);
}];
}
-(void)drawTitleView:(UIView *)view title:(NSString *)title
{
UIView *viewline = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 7, 17)];
[view addSubview:viewline];
[viewline mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(14);
make.centerY.equalTo(view);
make.size.sizeOffset(CGSizeMake(7, 17));
}];
[viewline.layer setMasksToBounds:YES];
[viewline.layer setCornerRadius:3.5];
[Tools changedView:viewline colors:@[(id)RGBCOLOR(42, 211, 237).CGColor,(id)RGBCOLOR(167, 247, 153).CGColor] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(0, 1)];
UILabel *lbname = [[UILabel alloc] init];
[lbname setText:title];
[lbname setTextColor:RGBCOLOR(26, 26, 17)];
[lbname setTextAlignment:NSTextAlignmentLeft];
[lbname setFont:[UIFont boldSystemFontOfSize:18]];
[view addSubview:lbname];
[lbname mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(view);
make.left.equalTo(viewline.mas_right).offset(6);
}];
}
-(void)drawInfoView
{
UIImageView *imgvtop = [[UIImageView alloc] init];
[imgvtop setImage:[UIImage imageNamed:@"yd_kt_lineL"]];
[self.viewback addSubview:imgvtop];
[imgvtop mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(13);
make.top.offset(0);
make.right.equalTo(self.viewback);
make.height.offset(16);
}];
UIImageView *imgvtype = [[UIImageView alloc] init];
[imgvtype setImage:[UIImage imageNamed:@"yd_写作要求及标准"]];
[self.viewback addSubview:imgvtype];
[imgvtype mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(14);
make.top.offset(32);
make.height.offset(34);
make.width.offset(158);
}];
UIButton *btzhan= [[UIButton alloc] init];
[btzhan setTitle:@"展开" forState:UIControlStateNormal];
[btzhan setImage:[UIImage imageNamed:@"yd_收起"] forState:UIControlStateNormal];
[btzhan setTitle:@"收起" forState:UIControlStateSelected];
[btzhan setImage:[UIImage imageNamed:@"yd_展开"] forState:UIControlStateSelected];
[btzhan setTitleColor:RGBCOLOR(153, 153, 153) forState:UIControlStateNormal];
[btzhan.titleLabel setFont:[UIFont systemFontOfSize:14]];
[self.viewback addSubview:btzhan];
[btzhan mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(imgvtype);
make.right.equalTo(self.viewback).offset(-10);
make.height.offset(30);
make.width.offset(60);
}];
[btzhan addTarget:self action:@selector(zhankaiAction:) forControlEvents:UIControlEventTouchUpInside];
UIView *viewt0 = [[UIView alloc] init];
[self.viewback addSubview:viewt0];
[viewt0 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.viewback);
make.top.equalTo(imgvtype.mas_bottom).offset(17);
make.height.offset(24);
}];
[self drawTitleView:viewt0 title:@"写作要求"];
PGJUILabel *lbyq = [[PGJUILabel alloc] init];
[lbyq setTextColor:RGBCOLOR(102, 102, 102)];
[lbyq setTextAlignment:NSTextAlignmentLeft];
[lbyq setFont:[UIFont systemFontOfSize:15]];
[lbyq setNumberOfLines:0];
[self.viewback addSubview:lbyq];
[lbyq mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(14);
make.right.equalTo(self.viewback).offset(-14);
make.top.equalTo(viewt0.mas_bottom).offset(15);
}];
_lbyq = lbyq;
UIView *viewt1 = [[UIView alloc] init];
[self.viewback addSubview:viewt1];
[viewt1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.viewback);
make.top.equalTo(lbyq.mas_bottom).offset(28);
make.height.offset(24);
}];
[self drawTitleView:viewt1 title:@"写作标准"];
PGJUILabel *lbbz = [[PGJUILabel alloc] init];
[lbbz setTextColor:RGBCOLOR(102, 102, 102)];
[lbbz setTextAlignment:NSTextAlignmentLeft];
[lbbz setFont:[UIFont systemFontOfSize:15]];
[lbbz setNumberOfLines:0];
[self.viewback addSubview:lbbz];
[lbbz mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(14);
make.right.equalTo(self.viewback).offset(-14);
make.top.equalTo(viewt1.mas_bottom).offset(15);
}];
_lbbz = lbbz;
UIImageView *imgvbottom = [[UIImageView alloc] init];
[imgvbottom setImage:[UIImage imageNamed:@"yd_kt_lineR"]];
[self.viewback addSubview:imgvbottom];
[imgvbottom mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.viewback).offset(-13);
make.bottom.equalTo(self.viewback);
make.left.offset(0);
make.height.offset(16);
}];
[self refBackView];
}
-(void)refBackView
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: self.viewback.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(14,14)];
//创建 layer
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.viewback.bounds;
//赋值
maskLayer.path = maskPath.CGPath;
self.viewback.layer.mask = maskLayer;
});
}
-(void)drawWenZhangView
{
UIImageView *imgvtop = [[UIImageView alloc] init];
[imgvtop setImage:[UIImage imageNamed:@"yd_kt_lineL"]];
[self.viewbackwz addSubview:imgvtop];
[imgvtop mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(13);
make.top.offset(0);
make.right.equalTo(self.viewbackwz);
make.height.offset(16);
}];
UIImageView *imgvtype = [[UIImageView alloc] init];
[imgvtype setImage:[UIImage imageNamed:@"yd_写作成文"]];
[self.viewbackwz addSubview:imgvtype];
[imgvtype mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(14);
make.top.offset(32);
make.height.offset(34);
make.width.offset(104);
}];
///
ViewLable *lbwz = [[ViewLable alloc] init];
[self.viewbackwz addSubview:lbwz];
[lbwz mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.offset(14);
make.right.equalTo(self.viewbackwz).offset(-14);
make.top.equalTo(imgvtype.mas_bottom).offset(16);
}];
lbwz.fspeed = 0.02;
[lbwz setBackHeight:^(float fheight,BOOL isend) {
[self.viewbackwz mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.offset(140+fheight);
}];
[self refwenzhangView];
if(self.isDragging==NO)
{
[self.scvback setContentOffset:CGPointMake(0, self.scvback.contentSize.height-self.scvback.height) animated:NO];
}
self.isendDraw = isend;
}];
_lbwz = lbwz;
///
UIImageView *imgvbottom = [[UIImageView alloc] init];
[imgvbottom setImage:[UIImage imageNamed:@"yd_kt_lineR"]];
[self.viewbackwz addSubview:imgvbottom];
[imgvbottom mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.viewbackwz).offset(-13);
make.bottom.equalTo(self.viewbackwz);
make.left.offset(0);
make.height.offset(16);
}];
[self refwenzhangView];
}
-(void)refwenzhangView
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: self.viewbackwz.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(14,14)];
//创建 layer
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.viewbackwz.bounds;
//赋值
maskLayer.path = maskPath.CGPath;
self.viewbackwz.layer.mask = maskLayer;
});
}
#pragma mark - UIScrollView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
float f_y = scrollView.contentOffset.y;
if(f_y>=0)
{
[self.scvback0 setContentOffset:CGPointMake(0, f_y*0.4)];
self.backvalue(self.viewback.top, f_y);
}
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
self.isDragging = YES;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
self.isDragging = NO;
}
-(void)setModelDetail:(TextbookDetailModelData *)modelDetail
{
_modelDetail = modelDetail;
_modelDetail = modelDetail;
self.lbtitle.text = self.strtitle;
self.lbname.text = [Tools isStringnilkong:modelDetail.title];
NSString *strinfo = [NSString stringWithFormat:@" %@、%@单元、%@字 ",modelDetail.genre,[Tools convertNumberToUppercase:modelDetail.unit.integerValue],modelDetail.word_count];
self.lbinfo.text = strinfo;
float f_w = [Tools getWidthWithText:strinfo height:20 font:14]+1;
[self.lbinfo mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.offset(f_w);
}];
self.lbyq.text = [Tools isStringnilkong:modelDetail.content];
self.lbbz.text = [Tools isStringnilkong:modelDetail.standard];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.viewbackHeight = self.lbbz.bottom+30;
});
[self refBackView];
}
-(void)setModelDetailYDY:(TextbookInfoModelData *)modelDetailYDY
{
_modelDetailYDY = modelDetailYDY;
self.lbwz.strValue = modelDetailYDY.content;
self.lbwz.isWriteEnd = YES;
}
-(void)zhankaiAction:(UIButton *)sender
{
sender.selected = !sender.selected;
if(sender.selected)
{
[self.viewback mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.offset(self.viewbackHeight);
}];
}
else
{
[self.viewback mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.offset(208);
}];
}
[self refBackView];
}
-(void)pigaiAction
{
if(self.isendDraw==NO)
{
[HXHud showMessage:@"请等待文章写作完成" afterDelayType:0];
return;
}
BaseViewController *vcbase = (BaseViewController *)self.viewController;
[UserInfoModel shijianShangBao:0 key:@"client.guide.classroom.write.start.correct" value:self.modelDetail.standard extra:[self.modelDetailYDY yy_modelToJSONString]];
StartKTXZPGView *view = [[StartKTXZPGView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT)];
view.isshiyong = YES;
view.modelDetailYDY = self.modelDetailYDY;
[self.viewController.view addSubview:view];
}
@end