editAPPBottomView.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. //
  2. // editAPPBottomView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2025/3/14.
  6. //
  7. #import "editAPPBottomView.h"
  8. #import "nasDownloadFileManager.h"
  9. @interface editAPPBottomView ()
  10. @property(nonatomic,strong) UIButton*oneButton;
  11. @property(nonatomic,strong) UIImageView*oneImageV;
  12. @property(nonatomic,strong) UILabel *oneLabel;
  13. @property(nonatomic,strong) UIButton*twoButton;
  14. @property(nonatomic,strong) UIImageView*twoImageV;
  15. @property(nonatomic,strong) UILabel *twoLabel;
  16. @property(nonatomic,strong) UIButton*threeButton;
  17. @property(nonatomic,strong) UIImageView*threeImageV;
  18. @property(nonatomic,strong) UILabel *threeLabel;
  19. @property(nonatomic,strong) UIButton*fourButton;
  20. @property(nonatomic,strong) UIImageView*fourImageV;
  21. @property(nonatomic,strong) UILabel *fourLabel;
  22. @end
  23. @implementation editAPPBottomView
  24. - (id)initWithFrame:(CGRect)frame{
  25. self = [super initWithFrame:frame];
  26. self.backgroundColor = [UIColor whiteColor];
  27. [self drawAnyView];
  28. return self;
  29. }
  30. - (void)drawAnyView{
  31. CGFloat curButFullWidth = SCREEN_W/3.0;
  32. _oneButton = [[UIButton alloc] init];
  33. [_oneButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  34. _oneButton.tag = 1;
  35. [self addSubview:_oneButton];
  36. [_oneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.width.mas_equalTo(curButFullWidth);
  38. make.left.mas_equalTo(0);
  39. make.height.mas_equalTo(60);
  40. make.top.mas_equalTo(0);
  41. }];
  42. _oneImageV = [[UIImageView alloc] init];
  43. _oneImageV.image = [UIImage imageNamed:@"edit_download_icon"];
  44. [_oneButton addSubview:_oneImageV];
  45. [_oneImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.width.mas_equalTo(25);
  47. make.height.mas_equalTo(25);
  48. make.centerX.equalTo(_oneButton.mas_centerX);
  49. make.centerY.equalTo(_oneButton.mas_centerY).offset(-10);
  50. }];
  51. _oneLabel = [[UILabel alloc] init];
  52. _oneLabel.textColor = [UIColor hwColor:@"#0A132B"];
  53. _oneLabel.textAlignment = NSTextAlignmentCenter;
  54. _oneLabel.font = [UIFont systemFontOfSize:12.0];
  55. _oneLabel.text = NSLocalizedString(@"my_set_no_File_download",nil);
  56. [_oneButton addSubview:_oneLabel];
  57. [_oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.width.mas_equalTo(curButFullWidth);
  59. make.height.mas_equalTo(25);
  60. make.centerX.equalTo(_oneButton.mas_centerX);
  61. make.centerY.equalTo(_oneButton.mas_centerY).offset(10);
  62. }];
  63. _twoButton = [[UIButton alloc] init];
  64. [_twoButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  65. _twoButton.tag = 2;
  66. [self addSubview:_twoButton];
  67. [_twoButton mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.width.mas_equalTo(curButFullWidth);
  69. make.left.mas_equalTo(curButFullWidth);
  70. make.height.mas_equalTo(60);
  71. make.top.mas_equalTo(0);
  72. }];
  73. _twoImageV = [[UIImageView alloc] init];
  74. _twoImageV.image = [UIImage imageNamed:@"edit_share_icon"];
  75. [_twoButton addSubview:_twoImageV];
  76. [_twoImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.width.mas_equalTo(25);
  78. make.height.mas_equalTo(25);
  79. make.centerX.equalTo(_twoButton.mas_centerX);
  80. make.centerY.equalTo(_twoButton.mas_centerY).offset(-10);
  81. }];
  82. _twoLabel = [[UILabel alloc] init];
  83. _twoLabel.textColor = [UIColor hwColor:@"#0A132B"];
  84. _twoLabel.textAlignment = NSTextAlignmentCenter;
  85. _twoLabel.font = [UIFont systemFontOfSize:12.0];
  86. _twoLabel.text = NSLocalizedString(@"common_edit_share",nil);
  87. [_twoButton addSubview:_twoLabel];
  88. [_twoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.width.mas_equalTo(curButFullWidth);
  90. make.height.mas_equalTo(25);
  91. make.centerX.equalTo(_twoButton.mas_centerX);
  92. make.centerY.equalTo(_twoButton.mas_centerY).offset(10);
  93. }];
  94. _threeButton = [[UIButton alloc] init];
  95. [_threeButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  96. _threeButton.tag = 3;
  97. [self addSubview:_threeButton];
  98. [_threeButton mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.width.mas_equalTo(curButFullWidth);
  100. make.right.mas_equalTo(0);
  101. make.height.mas_equalTo(60);
  102. make.top.mas_equalTo(0);
  103. }];
  104. _threeImageV = [[UIImageView alloc] init];
  105. _threeImageV.image = [UIImage imageNamed:@"edit_del_icon"];
  106. [_threeButton addSubview:_threeImageV];
  107. [_threeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.width.mas_equalTo(25);
  109. make.height.mas_equalTo(25);
  110. make.centerX.equalTo(_threeButton.mas_centerX);
  111. make.centerY.equalTo(_threeButton.mas_centerY).offset(-10);
  112. }];
  113. _threeLabel = [[UILabel alloc] init];
  114. _threeLabel.textColor = [UIColor hwColor:@"#0A132B"];
  115. _threeLabel.textAlignment = NSTextAlignmentCenter;
  116. _threeLabel.font = [UIFont systemFontOfSize:12.0];
  117. _threeLabel.text = NSLocalizedString(@"File_upload_Record_delete",nil);
  118. [_threeButton addSubview:_threeLabel];
  119. [_threeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.width.mas_equalTo(curButFullWidth);
  121. make.height.mas_equalTo(25);
  122. make.centerX.equalTo(_threeButton.mas_centerX);
  123. make.centerY.equalTo(_threeButton.mas_centerY).offset(10);
  124. }];
  125. //
  126. _fourButton = [[UIButton alloc] init];
  127. [_fourButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  128. _fourButton.tag = 4;
  129. [self addSubview:_fourButton];
  130. [_fourButton mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.width.mas_equalTo(curButFullWidth);
  132. make.right.mas_equalTo(0);
  133. make.height.mas_equalTo(60);
  134. make.top.mas_equalTo(0);
  135. }];
  136. _fourImageV = [[UIImageView alloc] init];
  137. _fourImageV.image = [UIImage imageNamed:@"edit_TV_icon"];
  138. [_fourButton addSubview:_fourImageV];
  139. [_fourImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  140. make.width.mas_equalTo(25);
  141. make.height.mas_equalTo(25);
  142. make.centerX.equalTo(_fourButton.mas_centerX);
  143. make.centerY.equalTo(_fourButton.mas_centerY).offset(-10);
  144. }];
  145. _fourLabel = [[UILabel alloc] init];
  146. _fourLabel.textColor = [UIColor hwColor:@"#0A132B"];
  147. _fourLabel.textAlignment = NSTextAlignmentCenter;
  148. _fourLabel.font = [UIFont systemFontOfSize:12.0];
  149. _fourLabel.text = NSLocalizedString(@"edit_install_TV_title",nil);
  150. [_fourButton addSubview:_fourLabel];
  151. [_fourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.width.mas_equalTo(curButFullWidth);
  153. make.height.mas_equalTo(25);
  154. make.centerX.equalTo(_fourButton.mas_centerX);
  155. make.centerY.equalTo(_fourButton.mas_centerY).offset(10);
  156. }];
  157. }
  158. - (void)didClickButFun:(UIButton*)but
  159. {
  160. NSInteger tag = but.tag;
  161. if(tag == 1){
  162. //1.4.3 新需求 有传输任务超过200个时 不给上传
  163. if([nasDownloadFileManager shareInstance].downLoadFileModelDataArr.count >= 200){
  164. [[iToast makeText:NSLocalizedString(@"download_task_not_done_tip",nil)] show];
  165. return;
  166. }
  167. }
  168. if(_didClickButtonFun){
  169. _didClickButtonFun(tag);
  170. }
  171. }
  172. - (void)setIsCanShareType:(BOOL)isCanShareType
  173. {
  174. _isCanShareType = isCanShareType;
  175. [self updateUIFun];
  176. }
  177. - (void)setIsCanDeleteType:(BOOL)isCanDeleteType
  178. {
  179. _isCanDeleteType = isCanDeleteType;
  180. [self updateUIFun];
  181. }
  182. - (void)setIsCanInstallToTVType:(BOOL)isCanInstallToTVType
  183. {
  184. _isCanInstallToTVType = isCanInstallToTVType;
  185. [self updateUIFun];
  186. }
  187. - (void)setButtonStateFunBy:(BOOL)canClick
  188. {
  189. CGFloat alpha = canClick ? 1.0 : 0.5;
  190. _oneButton.enabled = canClick;
  191. _twoButton.enabled = canClick;
  192. _threeButton.enabled = canClick;
  193. _fourButton.enabled = canClick;
  194. _oneButton.alpha = alpha;
  195. _twoButton.alpha = alpha;
  196. _threeButton.alpha = alpha;
  197. _fourButton.alpha = alpha;
  198. }
  199. - (void)updateUIFun
  200. {
  201. //test code
  202. //canShare = NO;
  203. NSInteger butNumber = 4;
  204. _twoButton.hidden = !_isCanShareType;
  205. _threeButton.hidden = !_isCanDeleteType;
  206. _fourButton.hidden = !_isCanInstallToTVType;
  207. if(!_isCanShareType){
  208. butNumber -= 1;
  209. }
  210. if(!_isCanDeleteType){
  211. butNumber -= 1;
  212. }
  213. if(!_isCanInstallToTVType){
  214. butNumber -= 1;
  215. }
  216. CGFloat curButFullWidth = SCREEN_W/butNumber;
  217. [_oneButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  218. make.width.mas_equalTo(curButFullWidth);
  219. make.left.mas_equalTo(0);
  220. make.height.mas_equalTo(60);
  221. make.top.mas_equalTo(0);
  222. }];
  223. if (_isCanShareType) {
  224. [_twoButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  225. make.width.mas_equalTo(curButFullWidth);
  226. make.left.mas_equalTo(curButFullWidth);
  227. make.height.mas_equalTo(60);
  228. make.top.mas_equalTo(0);
  229. }];
  230. }
  231. if (_isCanDeleteType) {
  232. CGFloat curRight = -curButFullWidth;
  233. if (!_isCanInstallToTVType) {
  234. curRight = 0.f;
  235. }
  236. [_threeButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  237. make.width.mas_equalTo(curButFullWidth);
  238. make.right.mas_equalTo(curRight);
  239. make.height.mas_equalTo(60);
  240. make.top.mas_equalTo(0);
  241. }];
  242. }
  243. if (_isCanInstallToTVType) {
  244. [_fourButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  245. make.width.mas_equalTo(curButFullWidth);
  246. make.right.mas_equalTo(0);
  247. make.height.mas_equalTo(60);
  248. make.top.mas_equalTo(0);
  249. }];
  250. }
  251. // if(canShare){
  252. // CGFloat curButFullWidth = SCREEN_W/3.0;
  253. // [_leftButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  254. // make.width.mas_equalTo(curButFullWidth);
  255. // make.left.mas_equalTo(0);
  256. // make.height.mas_equalTo(60);
  257. // make.top.mas_equalTo(0);
  258. // }];
  259. //
  260. // [_midButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  261. // make.width.mas_equalTo(curButFullWidth);
  262. // make.left.mas_equalTo(curButFullWidth);
  263. // make.height.mas_equalTo(60);
  264. // make.top.mas_equalTo(0);
  265. // }];
  266. //
  267. // [_rightButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  268. // make.width.mas_equalTo(curButFullWidth);
  269. // make.right.mas_equalTo(0);
  270. // make.height.mas_equalTo(60);
  271. // make.top.mas_equalTo(0);
  272. // }];
  273. // }
  274. // else{
  275. // CGFloat curButFullWidth = SCREEN_W/2.0;
  276. // [_leftButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  277. // make.width.mas_equalTo(curButFullWidth);
  278. // make.left.mas_equalTo(0);
  279. // make.height.mas_equalTo(60);
  280. // make.top.mas_equalTo(0);
  281. // }];
  282. //
  283. //// [_midButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  284. //// make.width.mas_equalTo(curButFullWidth);
  285. //// make.left.mas_equalTo(curButFullWidth);
  286. //// make.height.mas_equalTo(60);
  287. //// make.top.mas_equalTo(0);
  288. //// }];
  289. //
  290. // [_rightButton mas_remakeConstraints:^(MASConstraintMaker *make) {
  291. // make.width.mas_equalTo(curButFullWidth);
  292. // make.right.mas_equalTo(0);
  293. // make.height.mas_equalTo(60);
  294. // make.top.mas_equalTo(0);
  295. // }];
  296. // }
  297. }
  298. - (void)setIsBlackType:(BOOL)isBlackType
  299. {
  300. // _isBlackType = isBlackType;
  301. // if(isBlackType){
  302. // self.backgroundColor = [UIColor clearColor];
  303. //
  304. // // gradient
  305. // CAGradientLayer *gl = [CAGradientLayer layer];
  306. // gl.frame = CGRectMake(0,0,SCREEN_W,60 + AdaptTabHeight);
  307. // gl.startPoint = CGPointMake(0.5, 0);
  308. // gl.endPoint = CGPointMake(0.5, 1);
  309. // gl.colors = @[(__bridge id)[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.0].CGColor, (__bridge id)[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1.0].CGColor];
  310. // gl.locations = @[@(0), @(1.0f)];
  311. // //[self.layer addSublayer:gl];
  312. // [self.layer insertSublayer:gl atIndex:0];
  313. //
  314. // self.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.0200].CGColor;
  315. // self.layer.shadowOffset = CGSizeMake(0,-1);
  316. // self.layer.shadowOpacity = 1;
  317. // self.layer.shadowRadius = 1;
  318. //
  319. // //
  320. // _leftImageV.image = [UIImage imageNamed:@"edit_download_white_icon"];
  321. // _leftLabel.textColor = [UIColor whiteColor];
  322. //
  323. // _midImageV.image = [UIImage imageNamed:@"edit_share_white_icon"];
  324. // _midLabel.textColor = [UIColor whiteColor];
  325. //
  326. // _rightImageV.image = [UIImage imageNamed:@"edit_del_white_icon"];
  327. // _rightLabel.textColor = [UIColor whiteColor];
  328. // }
  329. }
  330. @end