playerSetView.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. //
  2. // playerSetView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/6/24.
  6. //
  7. #import "playerSetView.h"
  8. #import "SYJUISwitch.h"
  9. @interface playerSetView ()
  10. @property(nonatomic, strong) SYJUISwitch * bottomNavSwitch;//底部导航栏开关
  11. @property(nonatomic, strong) SYJUISwitch * fullScreenSwitch;//全面屏开关
  12. @property(nonatomic, strong) UIButton *TVButton;
  13. @end
  14. @implementation playerSetView
  15. - (id)initWithFrame:(CGRect)frame{
  16. self = [super initWithFrame:frame];
  17. self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
  18. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:) name:getCouldPhoneTvStatusNotification object:nil];
  19. [self drawAnyView];
  20. return self;
  21. }
  22. - (void)drawAnyView{
  23. //扩大金融云机范围按钮
  24. UIButton *bigButton = [[UIButton alloc] init];
  25. bigButton.tag = 1;
  26. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  27. [self addSubview:bigButton];
  28. //bigButton.backgroundColor = [UIColor greenColor];
  29. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.mas_equalTo(0);
  31. make.right.mas_equalTo(0);
  32. make.left.mas_equalTo(0);
  33. make.bottom.mas_equalTo(0);
  34. }];
  35. UIView* blackBgView = [UIView new];
  36. blackBgView.layer.cornerRadius = 20;
  37. blackBgView.backgroundColor = [UIColor hwColor:@"#202630"];
  38. [self addSubview:blackBgView];
  39. [blackBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.height.mas_equalTo(256);
  41. make.width.mas_equalTo(245);
  42. make.centerX.mas_equalTo(0.f);
  43. make.centerY.mas_equalTo(00.f);
  44. }];
  45. UIView *bg1View = [UIView new];
  46. bg1View.layer.cornerRadius = 12;
  47. bg1View.backgroundColor = [UIColor hwColor:@"#29313D"];
  48. [blackBgView addSubview:bg1View];
  49. [bg1View mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.height.mas_equalTo(74);
  51. make.left.mas_equalTo(12);
  52. make.right.mas_equalTo(-12);
  53. make.top.mas_equalTo(16.f);
  54. }];
  55. //底部导航栏开关
  56. _bottomNavSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)];
  57. _bottomNavSwitch.onTintColor = HW13B2EBColor;
  58. _bottomNavSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"];
  59. [_bottomNavSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged];
  60. [bg1View addSubview:_bottomNavSwitch];
  61. [_bottomNavSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.mas_equalTo(35.f);
  63. make.top.mas_equalTo(16.f);
  64. make.width.mas_equalTo(44.f);
  65. make.height.mas_equalTo(22.f);
  66. }];
  67. UILabel *navSwitchTipLabel = [[UILabel alloc] init];
  68. navSwitchTipLabel.text = NSLocalizedString(@"cloudPhone_nav_show_tip",nil);
  69. navSwitchTipLabel.textAlignment = NSTextAlignmentCenter;
  70. navSwitchTipLabel.textColor = [UIColor whiteColor];
  71. navSwitchTipLabel.font = [UIFont systemFontOfSize:10.0];
  72. [bg1View addSubview:navSwitchTipLabel];
  73. [navSwitchTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.right.equalTo(bg1View.mas_centerX).offset(-10.f);
  75. make.left.mas_equalTo(10);
  76. make.top.equalTo(_bottomNavSwitch.mas_bottom).offset(6);
  77. }];
  78. //全面屏开关
  79. _fullScreenSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)];
  80. _fullScreenSwitch.onTintColor = HW13B2EBColor;
  81. _fullScreenSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"];
  82. [_fullScreenSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged];
  83. [bg1View addSubview:_fullScreenSwitch];
  84. [_fullScreenSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.right.mas_equalTo(-35.f);
  86. make.top.mas_equalTo(16.f);
  87. make.width.mas_equalTo(44.f);
  88. make.height.mas_equalTo(22.f);
  89. }];
  90. UILabel *fullScreenTipLabel = [[UILabel alloc] init];
  91. fullScreenTipLabel.text = NSLocalizedString(@"cloudPhone_fullScreen_show_tip",nil);
  92. fullScreenTipLabel.textAlignment = NSTextAlignmentCenter;
  93. fullScreenTipLabel.textColor = [UIColor whiteColor];
  94. fullScreenTipLabel.font = [UIFont systemFontOfSize:10.0];
  95. [bg1View addSubview:fullScreenTipLabel];
  96. [fullScreenTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.equalTo(bg1View.mas_centerX).offset(10.f);
  98. make.right.mas_equalTo(-10);
  99. make.top.equalTo(_bottomNavSwitch.mas_bottom).offset(6);
  100. }];
  101. KWeakSelf
  102. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  103. [weakSelf setAllSwitchFun];
  104. });
  105. /**********************************************************************************/
  106. UIView *bg2View = [UIView new];
  107. bg2View.layer.cornerRadius = 12;
  108. bg2View.backgroundColor = [UIColor hwColor:@"#29313D"];
  109. [blackBgView addSubview:bg2View];
  110. [bg2View mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.height.mas_equalTo(74);
  112. make.left.mas_equalTo(12);
  113. make.right.mas_equalTo(-12);
  114. make.top.equalTo(bg1View.mas_bottom).offset(12);
  115. }];
  116. NSArray *titleArr = @[//NSLocalizedString(@"cloudPhone_set_screenshot_tip",nil),
  117. NSLocalizedString(@"my_set_no_restart_phone",nil),
  118. NSLocalizedString(@"cloudPhone_set_exit_tip",nil),
  119. ];
  120. NSArray *imageArr = @[//@"cloudPhone_set_screenshot",
  121. @"cloudPhone_set_restart",
  122. @"cloudPhone_set_exit",
  123. ];
  124. CGFloat butTopY = 15.0;
  125. CGFloat imageWH = 24.0;
  126. CGFloat butHeight = imageWH +20 +5;
  127. //CGFloat butWidth = (245 -12*2)/3.0; //70.0;
  128. CGFloat butWidth = (245 -12*2)/2.0; //70.0;
  129. CGFloat butSpace = 0.0; //(245 - butWidth*3)/3.0;
  130. for (int i=0; i<titleArr.count; i++) {
  131. UIButton *but = [[UIButton alloc] init];
  132. //but.tag = 10+i;
  133. but.tag = 11+i;
  134. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  135. [bg2View addSubview:but];
  136. //but.backgroundColor = [UIColor greenColor];
  137. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  139. make.width.mas_equalTo(butWidth);
  140. make.height.mas_equalTo(butHeight);
  141. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  142. }];
  143. UIImageView *imageV = [[UIImageView alloc] init];
  144. imageV.image = [UIImage imageNamed:imageArr[i]];
  145. [but addSubview:imageV];
  146. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.centerX.mas_equalTo(0);
  148. make.width.mas_equalTo(imageWH);
  149. make.height.mas_equalTo(imageWH);
  150. make.top.mas_equalTo(0);
  151. }];
  152. UILabel *textLabel = [[UILabel alloc] init];
  153. textLabel.textAlignment = NSTextAlignmentCenter;
  154. textLabel.font = [UIFont systemFontOfSize:10.0];
  155. textLabel.textColor = [UIColor whiteColor];
  156. textLabel.text = titleArr[i];
  157. [but addSubview:textLabel];
  158. //textLabel.backgroundColor = [UIColor redColor];
  159. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  160. make.centerX.mas_equalTo(0);
  161. make.width.mas_equalTo(butWidth);
  162. make.height.mas_equalTo(20);
  163. make.top.equalTo(imageV.mas_bottom).offset(5);
  164. }];
  165. }
  166. /**********************************************************************************/
  167. _TVButton = [[UIButton alloc] init];
  168. _TVButton.tag = 100;
  169. [_TVButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  170. [_TVButton setTitle:NSLocalizedString(@"my_set_no_TV_p2p",nil) forState:(UIControlStateNormal)];
  171. [_TVButton setTitle:NSLocalizedString(@"my_set_no_close_TV_p2p",nil) forState:(UIControlStateSelected)];
  172. _TVButton.layer.cornerRadius = 12;
  173. [_TVButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14.f]];
  174. _TVButton.backgroundColor = [UIColor hwColor:@"#29313D"];
  175. [blackBgView addSubview:_TVButton];
  176. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  177. _TVButton.selected = YES;
  178. }
  179. [_TVButton mas_makeConstraints:^(MASConstraintMaker *make) {
  180. make.height.mas_equalTo(50);
  181. make.left.mas_equalTo(12);
  182. make.right.mas_equalTo(-12);
  183. make.top.equalTo(bg2View.mas_bottom).offset(12);
  184. }];
  185. }
  186. - (void)setAllSwitchFun
  187. {
  188. BOOL haveShowBottonNavType = ![HWDataManager getBoolWithKey:Consn_player_Nav_hide];
  189. [_bottomNavSwitch setOn:haveShowBottonNavType];
  190. }
  191. - (void)maskSwitchPressed:(SYJUISwitch *)maskSwitch{
  192. if(_bottomNavSwitch == maskSwitch){
  193. if (maskSwitch.on) {
  194. [HWDataManager setBoolWithKey:Consn_player_Nav_hide value:NO];
  195. }
  196. else{
  197. [HWDataManager setBoolWithKey:Consn_player_Nav_hide value:YES];
  198. }
  199. [[NSNotificationCenter defaultCenter] postNotificationName:getPlayerBottomNavNotification object:nil];
  200. }
  201. }
  202. #pragma mark 按钮事件
  203. - (void)didClickButtonFun:(UIButton*)but
  204. {
  205. NSInteger tag = but.tag;
  206. HLog(@"%ld",tag);
  207. [self removeFun];
  208. if(tag == 1){
  209. return;
  210. }
  211. if(tag == 100 && but.selected){
  212. tag = 101;
  213. }
  214. if(_didClickButtonFun){
  215. _didClickButtonFun(tag);
  216. }
  217. }
  218. - (void)removeFun
  219. {
  220. [self removeFromSuperview];
  221. }
  222. - (void)getCouldPhoneTvStatusFun:(NSNotification*)not
  223. {
  224. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  225. _TVButton.selected = YES;
  226. }
  227. else{
  228. _TVButton.selected = NO;
  229. }
  230. }
  231. @end