NASLastFileView.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // NASLastFileView.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/6/19.
  6. //
  7. #import "NASLastFileView.h"
  8. @interface NASLastFileView ()
  9. @property(nonatomic,strong) UILabel*titleLabel;
  10. @end
  11. @implementation NASLastFileView
  12. - (id)initWithFrame:(CGRect)frame{
  13. self = [super initWithFrame:frame];
  14. //self.backgroundColor = [UIColor clearColor];
  15. [self drawAnyView];
  16. return self;
  17. }
  18. -(void)drawAnyView
  19. {
  20. _whiteBgView = [[UIView alloc] init];
  21. _whiteBgView.backgroundColor = [UIColor whiteColor];
  22. [self addSubview:_whiteBgView];
  23. // whiteBgView.layer.cornerRadius = 12;
  24. // whiteBgView.layer.masksToBounds = YES;
  25. [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.mas_equalTo(0);
  27. make.left.mas_equalTo(16);
  28. make.right.mas_equalTo(-16);
  29. make.bottom.mas_equalTo(0);
  30. }];
  31. _titleLabel = [[UILabel alloc] init];
  32. _titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  33. _titleLabel.textColor = [UIColor hwColor:@"#0A132B"];
  34. _titleLabel.text = NSLocalizedString(@"NAS_last_file",nil);
  35. [_whiteBgView addSubview:_titleLabel];
  36. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.mas_equalTo(16);
  38. make.left.mas_equalTo(16);
  39. make.right.mas_equalTo(-24-12-10);
  40. make.height.mas_equalTo(20);
  41. }];
  42. //按钮
  43. UIButton *rightButton = [[UIButton alloc] init];
  44. [rightButton setBackgroundImage:[UIImage imageNamed:@"common_right_back_arrow"] forState:UIControlStateNormal];
  45. rightButton.tag = 1;
  46. [rightButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  47. [_whiteBgView addSubview:rightButton];
  48. [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.mas_equalTo(16);
  50. make.right.mas_equalTo(-12);
  51. make.width.mas_equalTo(24);
  52. make.height.mas_equalTo(24);
  53. }];
  54. UIView *lineView = [[UIView alloc] init];
  55. lineView.backgroundColor = [UIColor hwColor:@"#CFD1D4"];
  56. [_whiteBgView addSubview:lineView];
  57. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.top.equalTo(rightButton.mas_top).offset(5);
  59. make.width.mas_equalTo(1);
  60. make.right.equalTo(rightButton.mas_left).offset(-13);
  61. make.bottom.equalTo(rightButton.mas_bottom).offset(-5);
  62. }];
  63. //按钮
  64. _eyeButton = [[UIButton alloc] init];
  65. [_eyeButton setBackgroundImage:[UIImage imageNamed:@"common_eye_open_black"] forState:UIControlStateNormal];
  66. [_eyeButton setBackgroundImage:[UIImage imageNamed:@"common_eye_close_black"] forState:UIControlStateSelected];
  67. _eyeButton.tag = 2;
  68. [_eyeButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  69. [_whiteBgView addSubview:_eyeButton];
  70. [_eyeButton mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.top.mas_equalTo(16);
  72. make.right.equalTo(lineView.mas_left).offset(-14);
  73. make.width.mas_equalTo(24);
  74. make.height.mas_equalTo(24);
  75. }];
  76. //空白页
  77. _notDataImageV = [[UIImageView alloc] init];
  78. _notDataImageV.image = [UIImage imageNamed:@"nas_not_data"];
  79. [_whiteBgView addSubview:_notDataImageV];
  80. [_notDataImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.top.equalTo(_titleLabel.mas_bottom).offset(20);
  82. make.centerX.mas_equalTo(0);
  83. make.width.mas_equalTo(160);
  84. make.height.mas_equalTo(160);
  85. }];
  86. _notDataLabel = [[UILabel alloc] init];
  87. _notDataLabel.font = [UIFont systemFontOfSize:14.0];
  88. _notDataLabel.textColor = [UIColor hwColor:@"#999999"];
  89. _notDataLabel.text = NSLocalizedString(@"NAS_last_file_not_data_tip",nil);
  90. _notDataLabel.textAlignment = NSTextAlignmentCenter;
  91. [_whiteBgView addSubview:_notDataLabel];
  92. [_notDataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.top.equalTo(_notDataImageV.mas_bottom).offset(-10);
  94. make.left.mas_equalTo(16);
  95. make.right.mas_equalTo(-16);
  96. make.height.mas_equalTo(20);
  97. }];
  98. }
  99. #pragma mark 按钮事件
  100. - (void)didClickButtonFun:(UIButton*)but
  101. {
  102. NSInteger tag = but.tag;
  103. HLog(@"%ld",tag);
  104. if(tag == 2){
  105. [HWDataManager setBoolWithKey:Const_last_file_show value:but.selected];
  106. //HLog(@"Const_last_file_show xxx:%d",but.selected)
  107. but.selected = !but.selected;
  108. //HLog(@"Const_last_file_show ddd:%d",but.selected)
  109. }
  110. if(_didClickButtonFun){
  111. _didClickButtonFun(tag);
  112. }
  113. }
  114. @end