DurationPopupView.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // DurationPopupView.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 1/25/16.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "CustomLabel.h"
  10. #import "CustomButton.h"
  11. #import "DurationPopupView.h"
  12. #import "DatePickerButton.h"
  13. #import "CustomTextField.h"
  14. @interface DurationPopupView () {
  15. }
  16. @end
  17. @implementation DurationPopupView
  18. - (id)initFromNib {
  19. for (UIView *view in [CommonUtil nibViews:@"DurationPopupView"]) {
  20. if ([view isKindOfClass:[DurationPopupView class]]) {
  21. self = (DurationPopupView *)view;
  22. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  23. self.frame = [UIScreen mainScreen].bounds;
  24. _btnFrom.date = [NSDate systemDate];
  25. _btnTo.date = [NSDate systemDate];
  26. _btnFrom.placeHolder = _btnFrom.dateString; //[CommonUtil formattedDate:[CommonUtil stringFromDate:[NSDate systemDate]]];
  27. _btnTo.placeHolder = _btnTo.dateString; //[CommonUtil formattedDate:[CommonUtil stringFromDate:[NSDate systemDate]]];
  28. [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  29. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  30. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  31. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  32. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  33. //Localization
  34. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  35. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  36. }
  37. }
  38. return self;
  39. }
  40. - (void)didMoveToSuperview {
  41. }
  42. - (void)setCondition:(ItemModel *)condition {
  43. _condition = condition;
  44. if (_condition.itemSubTypeCode && [_condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeDueDate]) {
  45. // ItemSubModel *subCondition = _condition.subItems && _condition.subItems.count ? _condition.subItems[0] : nil;
  46. // if (subCondition) {
  47. // //set values.
  48. // NSArray *darray = [subCondition.cmdclsValueMsg componentsSeparatedByString:@"~"];
  49. //
  50. // //from
  51. // [_btnFrom setTitle:darray[0] forState:UIControlStateNormal];
  52. // if (darray.count > 1) {//to
  53. // [_btnTo setTitle:darray[1] forState:UIControlStateNormal];
  54. // }
  55. // }
  56. } else {
  57. _condition.itemName = @"이 기간동안만";
  58. _condition.itemSubTypeCode = ksConditionSubTypeCodeDueDate;
  59. }
  60. }
  61. #pragma mark - UI Events
  62. - (IBAction)btnConfirmTouched:(id)sender {
  63. //validate
  64. ItemSubModel *subCondition = nil;
  65. if (_condition.subItems && _condition.subItems.count) {
  66. subCondition = _condition.subItems[0];
  67. } else {
  68. subCondition = [[ItemSubModel alloc] init];
  69. _condition.subItems = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] init];
  70. [_condition.subItems addObject:subCondition];
  71. }
  72. // subCondition.sourceId = @"VAR";
  73. subCondition.conditionTypeCode = @"09";
  74. subCondition.cmdclsValue = [NSString stringWithFormat:@"%@~%@", _btnFrom.dateString, _btnTo.dateString];;
  75. subCondition.cmdclsValueMsg = [NSString stringWithFormat:@"%@ ~ %@", _btnFrom.formatString, _btnTo.formatString];;
  76. [super btnConfirmTouched:sender];
  77. }
  78. @end