MOCheckNotiView.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // MOCheckNotiView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2025/6/3.
  6. //
  7. #import "MOCheckNotiView.h"
  8. @implementation MOCheckNotiView
  9. - (instancetype)initWithFrame:(CGRect)frame{
  10. if (self = [super initWithFrame:frame]){
  11. [self setupUI];
  12. self.backgroundColor = [UIColor whiteColor];
  13. }
  14. return self;
  15. }
  16. - (void)setupUI{
  17. [self addSubview:self.closeBtn];
  18. [self addSubview:self.openBtn];
  19. [self addSubview:self.contentLab];
  20. [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.width.height.equalTo(@16.0);
  22. make.leading.equalTo(self).offset(8.0);
  23. make.centerY.equalTo(self.mas_centerY);
  24. }];
  25. [self.openBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.trailing.equalTo(self).offset(-12.0);
  27. make.height.equalTo(@24.0);
  28. make.width.equalTo(@66.0);
  29. make.centerY.equalTo(self.mas_centerY);
  30. }];
  31. [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.leading.equalTo(self.closeBtn.mas_trailing).offset(8.0);
  33. make.trailing.equalTo(self.openBtn.mas_leading).offset(-8.0);
  34. make.top.equalTo(self).offset(8.0);
  35. make.bottom.equalTo(self).offset(-8.0);
  36. }];
  37. }
  38. - (CGFloat)getTheViewHeight{
  39. CGFloat theContentWidth = SCREENWIDTH - 12.0 * 2.0 - 8.0 - 16.0 - 8.0 - 12.0 - 66.0;
  40. CGFloat theContentHeight = [MOTools calculateRowHeight:NSLocalString(@"mimo_2_chat_noti_check_tip") font:[UIFont systemFontOfSize:12.0] andWidth:theContentWidth];
  41. CGFloat theViewHeight = theContentHeight + 8.0 * 2.0;
  42. if(theViewHeight < 44.0){
  43. theViewHeight = 44.0;
  44. }
  45. return theViewHeight;
  46. }
  47. #pragma mark - Lazy
  48. - (BigBtn *)closeBtn{
  49. if (!_closeBtn) {
  50. _closeBtn = [BigBtn buttonWithType:UIButtonTypeCustom];
  51. [_closeBtn setImage:[UIImage imageNamed:@"icon_2_close"] forState:UIControlStateNormal];
  52. [_closeBtn addTarget:self action:@selector(closeAction:) forControlEvents:UIControlEventTouchUpInside];
  53. }
  54. return _closeBtn;
  55. }
  56. - (void)closeAction:(UIButton *)sender{
  57. self.closeClickBlock ? self.closeClickBlock() : nil;
  58. }
  59. - (BigBtn *)openBtn{
  60. if (!_openBtn) {
  61. _openBtn = [BigBtn buttonWithType:UIButtonTypeCustom];
  62. NSArray *colorArr = @[kBaseColorLeft,kBaseColorRight];
  63. UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 66, 24.0) Colors:colorArr GradientType:0];
  64. [_openBtn setBackgroundImage:image forState:UIControlStateNormal];
  65. [_openBtn addTarget:self action:@selector(openAction:) forControlEvents:UIControlEventTouchUpInside];
  66. [_openBtn setTitle:NSLocalString(@"mimo_2_chat_noti_open") forState:UIControlStateNormal];
  67. [_openBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kPoppinsMediumFontStr]];
  68. _openBtn.layer.cornerRadius = 8.0;
  69. _openBtn.layer.masksToBounds = YES;
  70. }
  71. return _openBtn;
  72. }
  73. - (void)openAction:(UIButton *)sender{
  74. NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  75. if ([[UIApplication sharedApplication] canOpenURL:settingsURL]) {
  76. [[UIApplication sharedApplication] openURL:settingsURL options:@{} completionHandler:nil];
  77. }
  78. }
  79. - (UILabel *)contentLab{
  80. if (!_contentLab) {
  81. _contentLab = [[UILabel alloc] init];
  82. _contentLab.textColor = kBaseTextColor_1;
  83. _contentLab.font = [UIFont systemFontOfSize:12.0];
  84. _contentLab.textAlignment = NSTextAlignmentLeft;
  85. _contentLab.text = NSLocalString(@"mimo_2_chat_noti_check_tip");
  86. _contentLab.numberOfLines = 0;
  87. }
  88. return _contentLab;
  89. }
  90. @end