ModifyStreamDataPopupView.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // ModifyStreamDataPopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 6/23/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "CustomLabel.h"
  12. #import "CustomTextField.h"
  13. #import "DeviceModel.h"
  14. #import "ModifyStreamDataPopupView.h"
  15. #import "ValidateUtil.h"
  16. @interface ModifyStreamDataPopupView () <CustomTextFieldDelegate> {
  17. }
  18. @end
  19. @implementation ModifyStreamDataPopupView
  20. - (id)initFromNib {
  21. for (UIView *view in [CommonUtil nibViews:@"ModifyStreamDataPopupView"]) {
  22. if ([view isKindOfClass:[ModifyStreamDataPopupView class]]) {
  23. self = (ModifyStreamDataPopupView *)view;
  24. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  25. self.frame = [UIScreen mainScreen].bounds;
  26. self.lblTitle.text = NSLocalizedString(@"연결 정보 변경", @"연결 정보 변경");
  27. _txtFoscamId.keyboardType = UIKeyboardTypeDefault;
  28. _txtFoscamId.returnKeyType = UIReturnKeyDone;
  29. _txtFoscamPwd.keyboardType = UIKeyboardTypeDefault;
  30. _txtFoscamPwd.returnKeyType = UIReturnKeyDone;
  31. _txtFoscamPwd.secureTextEntry = YES;
  32. _txtFoscamURL.keyboardType = UIKeyboardTypeURL;
  33. _txtFoscamURL.returnKeyType = UIReturnKeyDone;
  34. _txtFoscamPort.keyboardType = UIKeyboardTypeNumberPad;
  35. _txtFoscamPort.returnKeyType = UIReturnKeyDone;
  36. _txtFoscamId.placeholder = NSLocalizedString(@"포스캠 아이디", @"포스캠 아이디");
  37. _txtFoscamPwd.placeholder = NSLocalizedString(@"비밀번호", @"비밀번호");
  38. _txtFoscamURL.placeholder = NSLocalizedString(@"접속 URL", @"접속 URL");
  39. _txtFoscamPort.placeholder = NSLocalizedString(@"포트번호", @"포트번호");
  40. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  41. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  42. }
  43. }
  44. return self;
  45. }
  46. - (void)didMoveToSuperview {
  47. _txtFoscamId.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  48. _txtFoscamPwd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  49. _txtFoscamURL.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  50. _txtFoscamPort.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  51. }
  52. - (void)setDeviceDetail:(DeviceDetailModel *)deviceDetail {
  53. _deviceDetail = deviceDetail;
  54. _txtFoscamURL.text = _deviceDetail.ip;
  55. _txtFoscamPort.text = _deviceDetail.port;
  56. _txtFoscamId.text = _deviceDetail.cameraId;
  57. }
  58. #pragma mark - Main Logic
  59. #pragma mark - UI Events
  60. - (void)btnConfirmTouched:(id)sender {
  61. #ifdef DEBUG
  62. if ([_txtFoscamId.text isEmptyString]) {
  63. _txtFoscamId.text = @"ntels_cam";
  64. }
  65. if ([_txtFoscamPwd.text isEmptyString]) {
  66. _txtFoscamPwd.text = @"wotdemo2015@";
  67. }
  68. if ([_txtFoscamURL.text isEmptyString]) {
  69. _txtFoscamURL.text = @"http://192.168.2.100";
  70. }
  71. if ([_txtFoscamPort.text isEmptyString]) {
  72. _txtFoscamPort.text = @"8090";
  73. }
  74. //http://192.168.2.100:8090/
  75. // ID : ntels_cam
  76. // PW : wotdemo2015@
  77. #endif
  78. //1.validate
  79. if (![ValidateUtil validateTextfiled:_txtFoscamId type:ValidateTypeNull title:NSLocalizedString(@"포스캠 아이디", @"포스캠 아이디")]) {
  80. return;
  81. }
  82. if (![ValidateUtil validateTextfiled:_txtFoscamPwd type:ValidateTypeNull title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
  83. return;
  84. }
  85. if (![ValidateUtil validateTextfiled:_txtFoscamURL type:ValidateTypeNull title:NSLocalizedString(@"접속 URL", @"접속 URL")]) {
  86. return;
  87. }
  88. if (![ValidateUtil validateTextfiled:_txtFoscamPort type:ValidateTypeNull title:NSLocalizedString(@"포트번호", @"포트번호")]) {
  89. return;
  90. }
  91. [super btnConfirmTouched:sender];
  92. }
  93. @end