Advertisement
axelso

backup - PaymentConfirmationNewViewController - 12 dec 15.55

Dec 12th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  PaymentConfirmationNewViewController.m
  3. //  Moselo
  4. //
  5. //  Created by Axel Soedarsono on 11/16/17.
  6. //  Copyright © 2017 Moselo. All rights reserved.
  7. //
  8.  
  9. #import "PaymentConfirmationNewViewController.h"
  10. #import "PaymentConfirmationNewView.h"
  11. //AS TEMP
  12. #import "AdditionalCostPopupViewController.h"
  13. #import "PaymentConfirmationNewCollectionViewCell.h"
  14. //END AS TEMP
  15.  
  16. @interface PaymentConfirmationNewViewController () <AdditionalCostPopupViewControllerDelegate, UICollectionViewDelegate, UICollectionViewDataSource, PaymentConfirmationNewCollectionViewCellDelegate>
  17.  
  18. @property (strong, nonatomic) PaymentConfirmationNewView *paymentConfirmationNewView;
  19. //AS TEMP
  20. @property (strong, nonatomic) AdditionalCostPopupViewController *additionalCostPopupViewController;
  21. //END AS TEMP
  22.  
  23.  
  24. //AS TEMP COLLECTION VIEW CELL UPDATED
  25. //PaymentConfirmationNewCollectionViewCell
  26. @property (nonatomic) CGFloat newPaymentConfirmationNewCollectionViewCellHeight;
  27. @property (nonatomic) BOOL isDataPaymentConfirmationNewCollectionViewHeightUpdated;
  28. @property (nonatomic) CGFloat heightCell;
  29. //END AS TEMP
  30.  
  31. - (void)backButtonDidTapped;
  32. //- (void)declineButtonDidTapped;
  33. //- (void)acceptButtonDidTapped;
  34. - (void)createConfirmationButtonDidTapped;
  35.  
  36. @end
  37.  
  38. @implementation PaymentConfirmationNewViewController
  39. #pragma mark - Lifecyce
  40. - (void)loadView {
  41.     [super loadView];
  42.    
  43.     _paymentConfirmationNewView = [[PaymentConfirmationNewView alloc] initWithFrame:[BaseView frameWithNavigationBar]];
  44.     [self.view addSubview:self.paymentConfirmationNewView];
  45. }
  46.  
  47. - (void)viewDidLoad {
  48.     [super viewDidLoad];
  49.    
  50.     //self.title = NSLocalizedString(@"Payment for MS-XXXXXX", @"");
  51.     self.title = [NSString stringWithFormat:@"%@", self.orderID];
  52.    
  53.     //LEFT BUTTON
  54.     UIImage *buttonImage = [UIImage imageNamed:@"backOn"];
  55.     UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, buttonImage.size.width, buttonImage.size.height)];
  56.     [button setImage:buttonImage forState:UIControlStateNormal];
  57.     [button addTarget:self action:@selector(backButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
  58.     UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
  59.     [self.navigationItem setLeftBarButtonItem:barButtonItem];
  60.    
  61.     // initialize 4 DEC 2017
  62.     _isDataPaymentConfirmationNewCollectionViewHeightUpdated = NO;
  63.     _heightCell = 0.0f;
  64.     //END INITIALIZE
  65.    
  66. //    //IF DEVICE BELOW 4.7 Inch
  67. //    if(!IS_IPHONE_4_7_INCH_AND_ABOVE){
  68. //        self.paymentConfirmationNewView.paymentConfirmationItemPriceLabel.font = [UIFont fontWithName:FONT_LATO_BOLD size:14.0f];
  69. //
  70. //        //self.paymentConfirmationNewView.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.paymentConfirmationNewView.scrollView.frame), CGRectGetMaxY(self.paymentConfirmationNewView.paymentConfirmationContainerView.frame) + 40.0f + CGRectGetHeight(self.paymentConfirmationNewView.createConfirmationContainerView.frame) + 100.0f);
  71. //    }
  72.    
  73.     //Button
  74. //    [self.paymentConfirmationNewView.leftOptionButton addTarget:self action:@selector(declineButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
  75. //    [self.paymentConfirmationNewView.rightOptionButton addTarget:self action:@selector(acceptButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
  76.    
  77.     [self.paymentConfirmationNewView.createConfirmationButton addTarget:self action:@selector(createConfirmationButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
  78.    
  79.     //AS TEMP
  80.     //register for delegate additionalCostPopupViewController
  81.     _additionalCostPopupViewController = [[AdditionalCostPopupViewController alloc] init];
  82.     self.additionalCostPopupViewController.view.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth([UIScreen mainScreen].bounds), CGRectGetHeight([UIScreen mainScreen].bounds));
  83.     self.additionalCostPopupViewController.delegate = self;
  84.     self.additionalCostPopupViewController.view.alpha = 0.0f;
  85.     self.additionalCostPopupViewController.additionalCostPopupView.backgroundView.alpha = 0.5f;
  86.     [self.navigationController.view addSubview:self.additionalCostPopupViewController.view];
  87.     [self.navigationController.view bringSubviewToFront:self.additionalCostPopupViewController.view];
  88.     //END AS TEMP
  89.    
  90.     //set totalprice on top
  91.     [self.paymentConfirmationNewView setTotalPriceNumberWithTotalAmountPrice:550000 totalPrice:88000];
  92.    
  93.     //set type payment AS TEMP
  94.     [self.paymentConfirmationNewView setPaymentConfirmationNewViewType:PaymentConfirmationNewViewTypeAccepted];
  95.    
  96.     //[self.paymentConfirmationNewView setPaymentConfirmationItemWithImageUrl:@"testCover" dateTimeConfirmation:@"08 Feb 2017, 21:00" totalPrice:@"Rp 123.456.789" bankAccountTransferDestination:@"Bank BRI: 777-1087-888-00-1111" bankAccountUsernameTransferDestination:@"Poppy" bankAccountSender:@"Bank BCA: 888-8888-888" bankAccountUsernameSender:@"Rizka FM Rizka "];
  97.    
  98.     //set Data Dummy in itemContainer
  99. //    [self.paymentConfirmationNewView setPaymentConfirmationItemWithImageUrl:@"testCover" dateTimeConfirmation:@"datetime" totalPrice:@"123.456.789" bankAccountTransferDestination:@"Description Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dol Description Lorem ipsum dolor sit amet" bankAccountUsernameTransferDestination:@"Description Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dol" bankAccountSender:@"Description Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dol Description Lorem ipsum dolor sit amet" bankAccountUsernameSender:@"Description Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dol Description Lorem ipsum dolor sit amet, consectetuer adipiscing elit."];
  100.    
  101.     //register delegate UICollectionView
  102.     self.paymentConfirmationNewView.collectionView.delegate = self;
  103.     self.paymentConfirmationNewView.collectionView.dataSource = self;
  104.    
  105.     //HAS PAYMENCONFIRMATION
  106.     //AS TEMP 3 DEC 17 23:33
  107.     [self.paymentConfirmationNewView setPaymentConfirmationNewViewValueType:PaymentConfirmationNewViewValueTypeHavePaymentConfirmation];
  108.     //END AS TEMP
  109. }
  110.  
  111. - (void)didReceiveMemoryWarning {
  112.     [super didReceiveMemoryWarning];
  113.     // Dispose of any resources that can be recreated.
  114. }
  115.  
  116. #pragma mark - UICollectionView
  117. #pragma mark DataSource
  118. - (CGSize)collectionView:(UICollectionView *)collectionView
  119.                   layout:(UICollectionViewLayout *)collectionViewLayout
  120.   sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  121.    
  122.     if(self.isDataPaymentConfirmationNewCollectionViewHeightUpdated) {
  123.         self.heightCell = self.newPaymentConfirmationNewCollectionViewCellHeight;
  124.     }
  125.     else {
  126. //        self.heightCell = 322.0f;
  127.         self.heightCell = 303.0f; //DV Temp
  128.     }
  129.     return CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), self.heightCell);
  130. }
  131.  
  132. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView
  133.                         layout:(UICollectionViewLayout *)collectionViewLayout
  134.         insetForSectionAtIndex:(NSInteger)section {
  135.     return UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f);
  136. }
  137.  
  138. - (CGFloat)collectionView:(UICollectionView *)collectionView
  139.                    layout:(UICollectionViewLayout *)collectionViewLayout
  140. minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  141.     return 0.0f;
  142. }
  143.  
  144. - (CGFloat)collectionView:(UICollectionView *)collectionView
  145.                    layout:(UICollectionViewLayout*)collectionViewLayout
  146. minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  147.     return 18.0f;
  148. }
  149.  
  150. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  151.     return 1;
  152. }
  153.  
  154. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  155.    
  156.     //this should be dynamic because depends on dataArray
  157.     return 5;
  158. }
  159.  
  160. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  161.    
  162.     static NSString *cellIdentifier = @"PaymentConfirmationNewCollectionViewCell";
  163.    
  164.     if(collectionView == self.paymentConfirmationNewView.collectionView) {
  165.        
  166.         [collectionView registerClass:[PaymentConfirmationNewCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
  167.        
  168.         PaymentConfirmationNewCollectionViewCell *cell = (PaymentConfirmationNewCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
  169.        
  170.         if(cell == nil)
  171.         {
  172.             cell = [[PaymentConfirmationNewCollectionViewCell alloc] init];
  173.         }
  174.        
  175.         //DELEGATE BUTTON DELEGATENYA BELUM WORK
  176.         cell.currentIndexPath = indexPath;
  177.         cell.delegate = self;
  178.         cell.contentView.userInteractionEnabled = YES;
  179.         cell.userInteractionEnabled = YES;
  180.        
  181.         //IF DEVICE BELOW 4.7 Inch
  182.         if(!IS_IPHONE_4_7_INCH_AND_ABOVE){
  183.             cell.paymentConfirmationItemPriceLabel.font = [UIFont fontWithName:FONT_LATO_BOLD size:14.0f];
  184.         }
  185.        
  186.        
  187.         //AS Temp
  188.         if(indexPath.row % 2 == 0) {
  189.             [cell setPaymentConfirmationNewCollectionViewCellStatusType:PaymentConfirmationNewCollectionViewCellStatusTypeAcceptDecline];
  190.            
  191.         }
  192.         else {
  193.             [cell setPaymentConfirmationNewCollectionViewCellStatusType:PaymentConfirmationNewCollectionViewCellStatusTypePaymentDeclined];
  194.            
  195.         }
  196.        
  197.         [cell setPaymentConfirmationItemWithImageUrl:@"testCover" dateTimeConfirmation:@"2 Dec 2017" totalPrice:@"8888888" bankAccountTransferDestination:@"1701314545 1701314545 1701314545 1701314545 1701314545 1701314545" bankAccountUsernameTransferDestination:@"Axel Soedarsono Axel Soedarsono Axel Soedarsono Axel Soedarsono Axel Soedarsono Axel Soedarsono Axel Soedarsono" bankAccountSender:@"4545170131" bankAccountUsernameSender:@"Soedarsono Axel"];
  198.        
  199.         //END AS Temp
  200.        
  201.         return cell;
  202.     }
  203.    
  204.     BaseCollectionViewCell *cell = [[BaseCollectionViewCell alloc] init];
  205.     return cell;
  206. }
  207.  
  208. #pragma mark Delegate
  209. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  210.    
  211. }
  212.  
  213. #pragma mark - PaymentConfirmationNewCollectionView
  214. #pragma mark Delegare
  215. - (void)paymentConfirmationNewCollectionViewCellResizeViewWithTotalHeight:(CGFloat)height indexPath:(NSIndexPath *)currentIndexPath {
  216. //    if(!self.isDataPaymentConfirmationNewCollectionViewHeightUpdated) {
  217.         self.isDataPaymentConfirmationNewCollectionViewHeightUpdated = YES;
  218.         self.newPaymentConfirmationNewCollectionViewCellHeight = height;
  219.         [self.paymentConfirmationNewView.collectionView reloadItemsAtIndexPaths:@[currentIndexPath]];
  220. //    }
  221. }
  222.  
  223. #pragma mark - Custom Method
  224. - (void)backButtonDidTapped {
  225.     [self.navigationController popViewControllerAnimated:YES];
  226. }
  227.  
  228. - (void)paymentConfirmationNewCollectionViewCellDidTappedDeclineButton {
  229.     NSLog(@"Decline button pressed");
  230. }
  231.  
  232. - (void)paymentConfirmationNewCollectionViewCellDidTappedAcceptButton {
  233.     NSLog(@"Accept button pressed");
  234. }
  235.  
  236. - (void)createConfirmationButtonDidTapped {
  237.     NSLog(@"Create Confirmation button pressed");
  238.     //AS TEMP
  239.     [UIView animateWithDuration:0.2f animations:^{
  240.         self.additionalCostPopupViewController.view.alpha = 1.0f;
  241.     }];
  242.     //END AS TEMP
  243. }
  244.  
  245. //AS TEMP
  246. - (void)additionalCostPopupViewDidTappedBackgroundButton {
  247.     NSLog(@"BackgroundButton for AdditionalCostPopupView");
  248.     [UIView animateWithDuration:0.2f animations:^{
  249.         self.additionalCostPopupViewController.view.alpha = 0.0f;
  250.     }];
  251. }
  252.  
  253. - (void)additionalCostPopupViewDidTappedDeclineButton {
  254.     NSLog(@"Decline Button for AdditionalCostPopupView");
  255. }
  256.  
  257. - (void)additionalCostPopupViewDidTappedAcceptButton {
  258.     NSLog(@"Accept Button for AdditionalCostPopupView");
  259. }
  260. //END AS TEMP
  261.  
  262. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement