playerSetView.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. @property(nonatomic, strong) UILabel *TVShowLabel;
  14. @property(nonatomic, strong) UIButton *exitPhoneButton;
  15. @property(nonatomic, strong) UILabel *delayedLabel;//延时
  16. @property(nonatomic, strong) UILabel *PacketLossLabel;//丢包
  17. @property(nonatomic, strong) UILabel *speedLabel;//速度(带宽)
  18. @property(nonatomic, strong) UILabel *fpsLabel;
  19. @end
  20. @implementation playerSetView
  21. - (id)initWithFrame:(CGRect)frame{
  22. self = [super initWithFrame:frame];
  23. self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
  24. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneTvStatusFun:) name:getCouldPhoneTvStatusNotification object:nil];
  25. [self drawAnyView];
  26. return self;
  27. }
  28. - (void)drawAnyView{
  29. //扩大金融云机范围按钮
  30. UIButton *bigButton = [[UIButton alloc] init];
  31. bigButton.tag = 1;
  32. [bigButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  33. [self addSubview:bigButton];
  34. //bigButton.backgroundColor = [UIColor greenColor];
  35. [bigButton mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.mas_equalTo(0);
  37. make.right.mas_equalTo(0);
  38. make.left.mas_equalTo(0);
  39. make.bottom.mas_equalTo(0);
  40. }];
  41. UIView* blackBgView = [UIView new];
  42. blackBgView.layer.cornerRadius = 20;
  43. blackBgView.backgroundColor = [UIColor hwColor:@"#202630"];
  44. [self addSubview:blackBgView];
  45. [blackBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.height.mas_equalTo(202);//(256);
  47. make.width.mas_equalTo(320);//(245);
  48. make.centerX.mas_equalTo(0.f);
  49. make.centerY.mas_equalTo(0.f);
  50. }];
  51. // UIView *bg1View = [UIView new];
  52. // bg1View.layer.cornerRadius = 12;
  53. // bg1View.backgroundColor = [UIColor hwColor:@"#29313D"];
  54. // [blackBgView addSubview:bg1View];
  55. //
  56. // [bg1View mas_makeConstraints:^(MASConstraintMaker *make) {
  57. // make.height.mas_equalTo(74);
  58. // make.left.mas_equalTo(12);
  59. // make.right.mas_equalTo(-12);
  60. // make.top.mas_equalTo(16.f);
  61. // }];
  62. //
  63. // //底部导航栏开关
  64. // _bottomNavSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)];
  65. // _bottomNavSwitch.onTintColor = HW13B2EBColor;
  66. // _bottomNavSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"];
  67. // [_bottomNavSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged];
  68. // [bg1View addSubview:_bottomNavSwitch];
  69. // [_bottomNavSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  70. // make.left.mas_equalTo(35.f);
  71. // make.top.mas_equalTo(16.f);
  72. // make.width.mas_equalTo(44.f);
  73. // make.height.mas_equalTo(22.f);
  74. // }];
  75. //
  76. //
  77. //
  78. // UILabel *navSwitchTipLabel = [[UILabel alloc] init];
  79. // navSwitchTipLabel.text = NSLocalizedString(@"cloudPhone_nav_show_tip",nil);
  80. // navSwitchTipLabel.textAlignment = NSTextAlignmentCenter;
  81. // navSwitchTipLabel.textColor = [UIColor whiteColor];
  82. // navSwitchTipLabel.font = [UIFont systemFontOfSize:10.0];
  83. // [bg1View addSubview:navSwitchTipLabel];
  84. //
  85. // [navSwitchTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  86. // make.right.equalTo(bg1View.mas_centerX).offset(-10.f);
  87. // make.left.mas_equalTo(10);
  88. // make.top.equalTo(_bottomNavSwitch.mas_bottom).offset(6);
  89. // }];
  90. //
  91. // //全面屏开关
  92. // _fullScreenSwitch = [[SYJUISwitch alloc] initWithFrame:CGRectMake(0, 0, 44, 22)];
  93. // _fullScreenSwitch.onTintColor = HW13B2EBColor;
  94. // _fullScreenSwitch.offTintColor = [UIColor hwColor:@"#E3E8F1"];
  95. // [_fullScreenSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:UIControlEventValueChanged];
  96. // [bg1View addSubview:_fullScreenSwitch];
  97. // [_fullScreenSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  98. // make.right.mas_equalTo(-35.f);
  99. // make.top.mas_equalTo(16.f);
  100. // make.width.mas_equalTo(44.f);
  101. // make.height.mas_equalTo(22.f);
  102. // }];
  103. //
  104. // UILabel *fullScreenTipLabel = [[UILabel alloc] init];
  105. // fullScreenTipLabel.text = NSLocalizedString(@"cloudPhone_fullScreen_show_tip",nil);
  106. // fullScreenTipLabel.textAlignment = NSTextAlignmentCenter;
  107. // fullScreenTipLabel.textColor = [UIColor whiteColor];
  108. // fullScreenTipLabel.font = [UIFont systemFontOfSize:10.0];
  109. // [bg1View addSubview:fullScreenTipLabel];
  110. //
  111. // [fullScreenTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  112. // make.left.equalTo(bg1View.mas_centerX).offset(10.f);
  113. // make.right.mas_equalTo(-10);
  114. // make.top.equalTo(_bottomNavSwitch.mas_bottom).offset(6);
  115. // }];
  116. //
  117. // KWeakSelf
  118. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  119. // [weakSelf setAllSwitchFun];
  120. // });
  121. /***************************顶部按钮显示*******************************************************/
  122. // UILabel * delayedTipLabel = [UILabel a]
  123. // @property(nonatomic, strong) UILabel *delayedLabel;//延时
  124. // @property(nonatomic, strong) UILabel *PacketLossLabel;//丢包
  125. // @property(nonatomic, strong) UILabel *speedLabel;//速度(带宽)
  126. // @property(nonatomic, strong) UILabel *fpsLabel;
  127. /**********************************************************************************/
  128. UIView *bg2View = [UIView new];
  129. bg2View.layer.cornerRadius = 12;
  130. bg2View.backgroundColor = [UIColor hwColor:@"#29313D"];
  131. [blackBgView addSubview:bg2View];
  132. [bg2View mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.height.mas_equalTo(72);
  134. make.left.mas_equalTo(15);
  135. make.right.mas_equalTo(-15);
  136. //make.top.equalTo(bg1View.mas_bottom).offset(12);
  137. make.top.mas_equalTo(52);
  138. }];
  139. NSArray *titleArr = @[NSLocalizedString(@"cloudPhone_set_screenshot_tip",nil),
  140. NSLocalizedString(@"my_set_no_TV_p2p",nil),//my_set_no_close_TV_p2p
  141. NSLocalizedString(@"my_set_no_restart_phone",nil),
  142. //NSLocalizedString(@"cloudPhone_set_exit_tip",nil),
  143. ];
  144. NSArray *imageArr = @[@"cloudPhone_set_screenshot",
  145. @"cloudPhone_set_TV",
  146. @"cloudPhone_set_restart",
  147. //@"cloudPhone_set_exit",
  148. ];
  149. CGFloat butTopY = 15.0;
  150. CGFloat imageWH = 24.0;
  151. CGFloat butHeight = imageWH +20 +5;
  152. CGFloat butWidth = (320 -15*2)/3.0; //70.0;
  153. //CGFloat butWidth = (245 -12*2)/2.0; //70.0;
  154. CGFloat butSpace = 0.0; //(245 - butWidth*3)/3.0;
  155. for (int i=0; i<titleArr.count; i++) {
  156. UIButton *but = [[UIButton alloc] init];
  157. //but.tag = 10+i;
  158. but.tag = 200+i;
  159. [but addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  160. [bg2View addSubview:but];
  161. //but.backgroundColor = [UIColor greenColor];
  162. [but mas_makeConstraints:^(MASConstraintMaker *make) {
  163. make.left.mas_equalTo(butSpace + (butWidth+butSpace)*(i%4));
  164. make.width.mas_equalTo(butWidth);
  165. make.height.mas_equalTo(butHeight);
  166. make.top.mas_equalTo(butTopY + (i/4)* (butHeight + 25) );
  167. }];
  168. UIImageView *imageV = [[UIImageView alloc] init];
  169. imageV.image = [UIImage imageNamed:imageArr[i]];
  170. [but addSubview:imageV];
  171. [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.centerX.mas_equalTo(0);
  173. make.width.mas_equalTo(imageWH);
  174. make.height.mas_equalTo(imageWH);
  175. make.top.mas_equalTo(0);
  176. }];
  177. UILabel *textLabel = [[UILabel alloc] init];
  178. textLabel.textAlignment = NSTextAlignmentCenter;
  179. textLabel.font = [UIFont systemFontOfSize:10.0];
  180. textLabel.textColor = [UIColor whiteColor];
  181. textLabel.text = titleArr[i];
  182. [but addSubview:textLabel];
  183. //textLabel.backgroundColor = [UIColor redColor];
  184. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.centerX.mas_equalTo(0);
  186. make.width.mas_equalTo(butWidth);
  187. make.height.mas_equalTo(20);
  188. make.top.equalTo(imageV.mas_bottom).offset(0);
  189. }];
  190. if(i==1){
  191. _TVButton = but;
  192. _TVShowLabel = textLabel;
  193. [self getCouldPhoneTvStatusFun:nil];
  194. }
  195. }
  196. /**********************************************************************************/
  197. NSString *titleStr = [[NSString alloc] initWithFormat:@" %@",NSLocalizedString(@"cloudPhone_set_exit_tip",nil)];
  198. _exitPhoneButton = [[UIButton alloc] init];
  199. _exitPhoneButton.tag = 100;
  200. [_exitPhoneButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  201. [_exitPhoneButton setTitle:titleStr forState:(UIControlStateNormal)];
  202. [_exitPhoneButton setImage:[UIImage imageNamed:@"cloudPhone_set_exit"] forState:UIControlStateNormal];
  203. _exitPhoneButton.layer.cornerRadius = 12;
  204. [_exitPhoneButton.titleLabel setFont:[UIFont systemFontOfSize:12.f]];
  205. _exitPhoneButton.backgroundColor = [UIColor hwColor:@"#29313D"];
  206. [blackBgView addSubview:_exitPhoneButton];
  207. // if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  208. // _TVButton.selected = YES;
  209. // }
  210. [_exitPhoneButton mas_makeConstraints:^(MASConstraintMaker *make) {
  211. make.height.mas_equalTo(42);
  212. make.left.mas_equalTo(12);
  213. make.right.mas_equalTo(-12);
  214. make.top.equalTo(bg2View.mas_bottom).offset(12);
  215. }];
  216. }
  217. - (void)setAllSwitchFun
  218. {
  219. BOOL haveShowBottonNavType = ![HWDataManager getBoolWithKey:Consn_player_Nav_hide];
  220. [_bottomNavSwitch setOn:haveShowBottonNavType];
  221. BOOL fullscreenType = [HWDataManager getBoolWithKey:Consn_player_full_screen_show];
  222. [_fullScreenSwitch setOn:fullscreenType];
  223. }
  224. - (void)maskSwitchPressed:(SYJUISwitch *)maskSwitch{
  225. if(_bottomNavSwitch == maskSwitch){
  226. if (maskSwitch.on) {
  227. [HWDataManager setBoolWithKey:Consn_player_Nav_hide value:NO];
  228. }
  229. else{
  230. [HWDataManager setBoolWithKey:Consn_player_Nav_hide value:YES];
  231. }
  232. [[NSNotificationCenter defaultCenter] postNotificationName:getPlayerBottomNavNotification object:nil];
  233. }
  234. else if (_fullScreenSwitch == maskSwitch){
  235. BOOL isTVShowType = ksharedAppDelegate.TvStatusMod.isTVShowType;
  236. if(isTVShowType){
  237. [[iToast makeText:NSLocalizedString(@"cloudPhone_tvShow_before_fullscreen_tip",nil)] show];
  238. [self removeFun];
  239. return;
  240. }
  241. if (maskSwitch.on) {
  242. [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:YES];
  243. //数据埋点
  244. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_full_screen_on"];
  245. }
  246. else{
  247. [HWDataManager setBoolWithKey:Consn_player_full_screen_show value:NO];
  248. //数据埋点
  249. [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Cloud_full_screen_off"];
  250. }
  251. [[NSNotificationCenter defaultCenter] postNotificationName:setPlayerFullScreenNotification object:nil];
  252. }
  253. [self removeFun];
  254. }
  255. #pragma mark 按钮事件
  256. - (void)didClickButtonFun:(UIButton*)but
  257. {
  258. NSInteger tag = but.tag;
  259. HLog(@"%ld",tag);
  260. [self removeFun];
  261. if(tag == 1){
  262. return;
  263. }
  264. if(tag == 201 && but.selected){
  265. tag = 301;
  266. }
  267. if(_didClickButtonFun){
  268. _didClickButtonFun(tag);
  269. }
  270. }
  271. - (void)removeFun
  272. {
  273. [self removeFromSuperview];
  274. }
  275. - (void)getCouldPhoneTvStatusFun:(NSNotification*)not
  276. {
  277. if(ksharedAppDelegate.TvStatusMod.isTVShowType){
  278. _TVButton.selected = YES;
  279. _TVShowLabel.text = NSLocalizedString(@"my_set_no_close_TV_p2p",nil);
  280. }
  281. else{
  282. _TVButton.selected = NO;
  283. _TVShowLabel.text = NSLocalizedString(@"my_set_no_TV_p2p",nil);
  284. }
  285. }
  286. @end