JXDeviceAuthController.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // JXDeviceAuthController.m
  3. // shiku_im
  4. //
  5. // Created by IMAC on 2019/8/21.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "JXDeviceAuthController.h"
  9. #define JX_SCREEN_BAR (THE_DEVICE_HAVE_HEAD ? 34 : 0)
  10. @interface JXDeviceAuthController ()
  11. @property (nonatomic, strong)UIView *baseView;
  12. @property (nonatomic, strong)NSString *str;
  13. @property (nonatomic, assign)BOOL disSynchronizedMessage;
  14. @property (nonatomic, strong)JXMessageObject *msg;
  15. @end
  16. @implementation JXDeviceAuthController
  17. - (instancetype)initWithMsg:(JXMessageObject *)msg{
  18. self = [super init];
  19. if (self) {
  20. self.msg = msg;
  21. }
  22. return self;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [self creatView];
  27. }
  28. - (void)viewDidAppear:(BOOL)animated {
  29. [super viewDidAppear:animated];
  30. [UIView animateWithDuration:0.5 animations:^{
  31. self.view.backgroundColor = [UIColor whiteColor];
  32. self.baseView.frame = CGRectMake(0, JX_SCREEN_BAR, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_BAR);
  33. }];
  34. }
  35. - (void)viewWillDisappear:(BOOL)animated{
  36. }
  37. - (void)creatView{
  38. self.baseView = [[UIView alloc] initWithFrame:CGRectMake(0, JX_SCREEN_HEIGHT+JX_SCREEN_BAR, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT-JX_SCREEN_BAR)];
  39. self.baseView.backgroundColor = [UIColor whiteColor];
  40. [self.view addSubview:self.baseView];
  41. UIImageView *imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ALOGO_1200"]];
  42. imgV.frame = CGRectMake(0, 0, 87, 87);
  43. imgV.center = CGPointMake(JX_SCREEN_WIDTH/2, 124 + 87/2);
  44. [self.baseView addSubview:imgV];
  45. UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imgV.frame) + 10, JX_SCREEN_WIDTH, 40)];
  46. [lab setText:g_appName];
  47. [lab setFont:[UIFont systemFontOfSize:20]];
  48. [lab setTextAlignment:NSTextAlignmentCenter];
  49. [lab setTextColor:[UIColor blackColor]];
  50. [lab setBackgroundColor:[UIColor whiteColor]];
  51. [self.baseView addSubview:lab];
  52. UIView *lineView = [[UIView alloc] init];
  53. lineView.frame = CGRectMake(35, CGRectGetMaxY(lab.frame) + 40, JX_SCREEN_WIDTH - 35*2, 0.3);
  54. lineView.backgroundColor = HEXCOLOR(0xD9D9D9);
  55. [self.baseView addSubview:lineView];
  56. UILabel *nameLab = [[UILabel alloc] initWithFrame:CGRectMake(60, CGRectGetMaxY(lineView.frame) + 35, 120, 25)];
  57. nameLab.backgroundColor = [UIColor whiteColor];
  58. nameLab.font = [UIFont systemFontOfSize:16];
  59. nameLab.text = MY_USER_NAME;
  60. nameLab.textColor = [UIColor blackColor];
  61. nameLab.textAlignment = NSTextAlignmentLeft;
  62. [self.baseView addSubview:nameLab];
  63. UILabel *idLab = [[UILabel alloc] initWithFrame:CGRectMake(60, CGRectGetMaxY(nameLab.frame) + 10, 120, 25)];
  64. idLab.backgroundColor = [UIColor whiteColor];
  65. idLab.font = [UIFont systemFontOfSize:14];
  66. idLab.text = MY_USER_ID;
  67. idLab.textColor = HEXCOLOR(0x999999);
  68. idLab.textAlignment = NSTextAlignmentLeft;
  69. [self.baseView addSubview:idLab];
  70. UIImageView *headImgV = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH - 62 - 50, CGRectGetMaxY(lineView.frame) + 37, 50, 50)];
  71. headImgV.clipsToBounds = YES;
  72. headImgV.layer.cornerRadius = 25;
  73. [g_server getHeadImageLarge:MY_USER_ID userName:MY_USER_NAME imageView:headImgV];
  74. [self.baseView addSubview:headImgV];
  75. UIButton *btn = [UIFactory createCommonButton:Localized(@"JX_ConfirmTheLogin") target:self action:@selector(agreeLogin)];
  76. btn.frame = CGRectMake(15, CGRectGetMaxY(headImgV.frame) + 35, JX_SCREEN_WIDTH - 15*2, 40);
  77. btn.backgroundColor = [g_theme themeColor];
  78. [btn.titleLabel setFont:g_factory.font16];
  79. btn.titleLabel.textColor = [UIColor whiteColor];
  80. btn.clipsToBounds = YES;
  81. btn.layer.cornerRadius = 7;
  82. [self.baseView addSubview:btn];
  83. UIButton *btn2 = [[UIButton alloc] init];
  84. btn2.frame = CGRectMake(15, CGRectGetMaxY(btn.frame) + 30, JX_SCREEN_WIDTH - 15*2, 40);
  85. btn2.backgroundColor = [UIColor whiteColor];
  86. [btn2 setTitle:Localized(@"JX_CancelLogin") forState:UIControlStateNormal];
  87. [btn2.titleLabel setFont:[UIFont systemFontOfSize:14]];
  88. [btn2 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  89. [btn2 addTarget:self action:@selector(cancelLogin) forControlEvents:UIControlEventTouchUpInside];
  90. [self.baseView addSubview:btn2];
  91. }
  92. - (void)agreeLogin{
  93. [g_server agreeAuthLogin:self.msg.content toView:self];
  94. [self dismissViewController];
  95. }
  96. - (void)cancelLogin{
  97. [self dismissViewController];
  98. }
  99. - (void)dismissViewController {
  100. [UIView animateWithDuration:0.5 animations:^{
  101. self.baseView.frame = CGRectMake(0, JX_SCREEN_HEIGHT+JX_SCREEN_BAR, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  102. self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0];
  103. } completion:^(BOOL finished) {
  104. [self dismissViewControllerAnimated:YES completion:nil];
  105. if (self) {
  106. [self.view removeFromSuperview];
  107. }
  108. }];
  109. }
  110. - (void)dealloc{
  111. }
  112. @end