DurationPopupView.m 4.1 KB

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