@@ -253,11 +253,21 @@ - (NSString *)p_appID{
253
253
}
254
254
255
255
- (BOOL )p_needToCheckIfNewVersion {
256
- return (!_isHeaderClosed && (_useNewStyle && _myProjects.type == ProjectsTypeAll) && !self.isNewerVersionAvailable );
256
+ return (!_isHeaderClosed &&
257
+ (_useNewStyle && _myProjects.type == ProjectsTypeAll) &&
258
+ !self.isNewerVersionAvailable );
257
259
}
258
260
259
261
- (BOOL )p_needToShowVersionTip {
260
- return (!_isHeaderClosed && (_useNewStyle && _myProjects.type == ProjectsTypeAll) && self.isNewerVersionAvailable );
262
+ return (!_isHeaderClosed &&
263
+ (_useNewStyle && _myProjects.type == ProjectsTypeAll) &&
264
+ self.isNewerVersionAvailable );
265
+ }
266
+
267
+ - (BOOL )p_needToShowHeaderTip {
268
+ return (!_isHeaderClosed &&
269
+ (_useNewStyle && _myProjects.type == ProjectsTypeAll) &&
270
+ (self.isNewerVersionAvailable || ![NSObject isPrivateCloud ].boolValue ));
261
271
}
262
272
263
273
- (void )refreshUI {
@@ -353,11 +363,21 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
353
363
}
354
364
355
365
- (CGFloat )tableView : (UITableView *)tableView heightForHeaderInSection : (NSInteger )section {
356
- return [self p_needToShowVersionTip ]? 40 : 0 ;
366
+ if ([self p_needToShowHeaderTip ]) {
367
+ static UILabel *tipL;
368
+ if (!tipL) {
369
+ tipL = [UILabel labelWithFont: [UIFont systemFontOfSize: 12 ] textColor: [UIColor colorWithHexString: @" 0x136BFB" ]];
370
+ tipL.numberOfLines = 0 ;
371
+ }
372
+ tipL.attributedText = [self p_headerTipStr ];
373
+ return [tipL sizeThatFits: CGSizeMake (kScreen_Width - 40 * 1 , CGFLOAT_MAX)].height + 16 ;
374
+ } else {
375
+ return 0 ;
376
+ }
357
377
}
358
378
359
379
- (UIView *)tableView : (UITableView *)tableView viewForHeaderInSection : (NSInteger )section {
360
- if ([self p_needToShowVersionTip ]) {
380
+ if ([self p_needToShowHeaderTip ]) {
361
381
UIView *headerV = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 40 )];
362
382
headerV.backgroundColor = [UIColor colorWithHexString: @" 0xECF9FF" ];
363
383
__weak typeof (self) weakSelf = self;
@@ -368,32 +388,51 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
368
388
} forControlEvents: UIControlEventTouchUpInside];
369
389
[headerV addSubview: closeBtn];
370
390
[closeBtn mas_makeConstraints: ^(MASConstraintMaker *make) {
371
- make.top .bottom .right .equalTo (headerV);
372
- make.width .equalTo (closeBtn.mas_height );
391
+ make.top .right .equalTo (headerV);
392
+ make.width .mas_equalTo (40 );
393
+ make.height .mas_equalTo (36 ); // 文字单行显示时的高度
373
394
}];
374
- UIImageView *noticeV = [[UIImageView alloc ] initWithImage: [UIImage imageNamed: @" button_tip_notice" ]];
375
- noticeV.contentMode = UIViewContentModeCenter;
376
- [headerV addSubview: noticeV];
377
- [noticeV mas_makeConstraints: ^(MASConstraintMaker *make) {
378
- make.top .bottom .left .equalTo (headerV);
379
- make.width .equalTo (noticeV.mas_height );
380
- }];
381
- UILabel *tipL = [UILabel labelWithFont: [UIFont systemFontOfSize: 15 ] textColor: [UIColor colorWithHexString: @" 0x136BFB" ]];
382
- tipL.adjustsFontSizeToFitWidth = YES ;
383
- tipL.minimumScaleFactor = .5 ;
395
+ // UIImageView *noticeV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"button_tip_notice"]];
396
+ // noticeV.contentMode = UIViewContentModeCenter;
397
+ // [headerV addSubview:noticeV];
398
+ // [noticeV mas_makeConstraints:^(MASConstraintMaker *make) {
399
+ // make.top.bottom.left.equalTo(headerV);
400
+ // make.width.mas_equalTo(0);
401
+ // }];
402
+ UILabel *tipL = [UILabel labelWithFont: [UIFont systemFontOfSize: 12 ] textColor: [UIColor colorWithHexString: @" 0x136BFB" ]];
403
+ tipL.numberOfLines = 0 ;
384
404
tipL.userInteractionEnabled = YES ;
385
- tipL.text = kTarget_Enterprise ? @" 立即升级最新 CODING 企业版客户端" : @" 立即升级最新 Coding 客户端" ;
386
- [tipL bk_whenTapped: ^{
387
- [[UIApplication sharedApplication ] openURL: [NSURL URLWithString: kAppUrl ]];
388
- }];
405
+ tipL.attributedText = [self p_headerTipStr ];
406
+ if ([self p_needToShowVersionTip ]) {
407
+ [tipL bk_whenTapped: ^{
408
+ [[UIApplication sharedApplication ] openURL: [NSURL URLWithString: kAppUrl ]];
409
+ }];
410
+ }
389
411
[headerV addSubview: tipL];
390
412
[tipL mas_makeConstraints: ^(MASConstraintMaker *make) {
391
- make.centerY .equalTo (headerV);
392
- make.left .equalTo (noticeV. mas_right );
413
+ make.centerY .equalTo (headerV). mas_offset ( 3 ) ;
414
+ make.left .equalTo (headerV). offset ( 15 );
393
415
make.right .equalTo (closeBtn.mas_left );
394
416
}];
395
417
return headerV;
396
- }else {
418
+ } else {
419
+ return nil ;
420
+ }
421
+ }
422
+
423
+ - (NSAttributedString *)p_headerTipStr {
424
+ if ([self p_needToShowHeaderTip ]) {
425
+ NSString *tipStr;
426
+ if ([self p_needToShowVersionTip ]) {
427
+ tipStr = kTarget_Enterprise ? @" 立即升级最新 CODING 企业版客户端" : @" 立即升级最新 Coding 客户端" ;
428
+ } else {
429
+ tipStr = @" 温馨提示:出于实际使用场景限制的考虑,该 App 不再进行更多新功能开发,建议您前往 PC 端网页版体验更完整的产品功能。" ;
430
+ }
431
+ NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new ];
432
+ paragraphStyle.lineSpacing = 6 ;
433
+ NSDictionary *attributes = @{NSParagraphStyleAttributeName : paragraphStyle};
434
+ return [[NSAttributedString alloc ] initWithString: tipStr attributes: attributes];
435
+ } else {
397
436
return nil ;
398
437
}
399
438
}
0 commit comments