Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // PaymentConfirmationNewViewController.m
- // Moselo
- //
- // Created by Axel Soedarsono on 11/16/17.
- // Copyright © 2017 Moselo. All rights reserved.
- //
- #import "PaymentConfirmationNewViewController.h"
- #import "PaymentConfirmationNewView.h"
- //AS TEMP
- #import "AdditionalCostPopupViewController.h"
- #import "PaymentConfirmationNewCollectionViewCell.h"
- //END AS TEMP
- @interface PaymentConfirmationNewViewController () <AdditionalCostPopupViewControllerDelegate, UICollectionViewDelegate, UICollectionViewDataSource, PaymentConfirmationNewCollectionViewCellDelegate>
- @property (strong, nonatomic) PaymentConfirmationNewView *paymentConfirmationNewView;
- //AS TEMP
- @property (strong, nonatomic) AdditionalCostPopupViewController *additionalCostPopupViewController;
- //END AS TEMP
- //AS TEMP COLLECTION VIEW CELL UPDATED
- //PaymentConfirmationNewCollectionViewCell
- @property (nonatomic) CGFloat newPaymentConfirmationNewCollectionViewCellHeight;
- @property (nonatomic) BOOL isDataPaymentConfirmationNewCollectionViewHeightUpdated;
- @property (nonatomic) CGFloat heightCell;
- //END AS TEMP
- - (void)backButtonDidTapped;
- //- (void)declineButtonDidTapped;
- //- (void)acceptButtonDidTapped;
- - (void)createConfirmationButtonDidTapped;
- @end
- @implementation PaymentConfirmationNewViewController
- #pragma mark - Lifecyce
- - (void)loadView {
- [super loadView];
- _paymentConfirmationNewView = [[PaymentConfirmationNewView alloc] initWithFrame:[BaseView frameWithNavigationBar]];
- [self.view addSubview:self.paymentConfirmationNewView];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- //self.title = NSLocalizedString(@"Payment for MS-XXXXXX", @"");
- self.title = [NSString stringWithFormat:@"%@", self.orderID];
- //LEFT BUTTON
- UIImage *buttonImage = [UIImage imageNamed:@"backOn"];
- UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, buttonImage.size.width, buttonImage.size.height)];
- [button setImage:buttonImage forState:UIControlStateNormal];
- [button addTarget:self action:@selector(backButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
- [self.navigationItem setLeftBarButtonItem:barButtonItem];
- // initialize 4 DEC 2017
- _isDataPaymentConfirmationNewCollectionViewHeightUpdated = NO;
- _heightCell = 0.0f;
- //END INITIALIZE
- // //IF DEVICE BELOW 4.7 Inch
- // if(!IS_IPHONE_4_7_INCH_AND_ABOVE){
- // self.paymentConfirmationNewView.paymentConfirmationItemPriceLabel.font = [UIFont fontWithName:FONT_LATO_BOLD size:14.0f];
- //
- // //self.paymentConfirmationNewView.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.paymentConfirmationNewView.scrollView.frame), CGRectGetMaxY(self.paymentConfirmationNewView.paymentConfirmationContainerView.frame) + 40.0f + CGRectGetHeight(self.paymentConfirmationNewView.createConfirmationContainerView.frame) + 100.0f);
- // }
- //Button
- // [self.paymentConfirmationNewView.leftOptionButton addTarget:self action:@selector(declineButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
- // [self.paymentConfirmationNewView.rightOptionButton addTarget:self action:@selector(acceptButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
- [self.paymentConfirmationNewView.createConfirmationButton addTarget:self action:@selector(createConfirmationButtonDidTapped) forControlEvents:UIControlEventTouchUpInside];
- //AS TEMP
- //register for delegate additionalCostPopupViewController
- _additionalCostPopupViewController = [[AdditionalCostPopupViewController alloc] init];
- self.additionalCostPopupViewController.view.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth([UIScreen mainScreen].bounds), CGRectGetHeight([UIScreen mainScreen].bounds));
- self.additionalCostPopupViewController.delegate = self;
- self.additionalCostPopupViewController.view.alpha = 0.0f;
- self.additionalCostPopupViewController.additionalCostPopupView.backgroundView.alpha = 0.5f;
- [self.navigationController.view addSubview:self.additionalCostPopupViewController.view];
- [self.navigationController.view bringSubviewToFront:self.additionalCostPopupViewController.view];
- //END AS TEMP
- //set totalprice on top
- [self.paymentConfirmationNewView setTotalPriceNumberWithTotalAmountPrice:550000 totalPrice:88000];
- //set type payment AS TEMP
- [self.paymentConfirmationNewView setPaymentConfirmationNewViewType:PaymentConfirmationNewViewTypeAccepted];
- //[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 "];
- //set Data Dummy in itemContainer
- // [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."];
- //register delegate UICollectionView
- self.paymentConfirmationNewView.collectionView.delegate = self;
- self.paymentConfirmationNewView.collectionView.dataSource = self;
- //HAS PAYMENCONFIRMATION
- //AS TEMP 3 DEC 17 23:33
- [self.paymentConfirmationNewView setPaymentConfirmationNewViewValueType:PaymentConfirmationNewViewValueTypeHavePaymentConfirmation];
- //END AS TEMP
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - UICollectionView
- #pragma mark DataSource
- - (CGSize)collectionView:(UICollectionView *)collectionView
- layout:(UICollectionViewLayout *)collectionViewLayout
- sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- if(self.isDataPaymentConfirmationNewCollectionViewHeightUpdated) {
- self.heightCell = self.newPaymentConfirmationNewCollectionViewCellHeight;
- }
- else {
- // self.heightCell = 322.0f;
- self.heightCell = 303.0f; //DV Temp
- }
- return CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), self.heightCell);
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView
- layout:(UICollectionViewLayout *)collectionViewLayout
- insetForSectionAtIndex:(NSInteger)section {
- return UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f);
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView
- layout:(UICollectionViewLayout *)collectionViewLayout
- minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
- return 0.0f;
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView
- layout:(UICollectionViewLayout*)collectionViewLayout
- minimumLineSpacingForSectionAtIndex:(NSInteger)section {
- return 18.0f;
- }
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
- //this should be dynamic because depends on dataArray
- return 5;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifier = @"PaymentConfirmationNewCollectionViewCell";
- if(collectionView == self.paymentConfirmationNewView.collectionView) {
- [collectionView registerClass:[PaymentConfirmationNewCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
- PaymentConfirmationNewCollectionViewCell *cell = (PaymentConfirmationNewCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
- if(cell == nil)
- {
- cell = [[PaymentConfirmationNewCollectionViewCell alloc] init];
- }
- //DELEGATE BUTTON DELEGATENYA BELUM WORK
- cell.currentIndexPath = indexPath;
- cell.delegate = self;
- cell.contentView.userInteractionEnabled = YES;
- cell.userInteractionEnabled = YES;
- //IF DEVICE BELOW 4.7 Inch
- if(!IS_IPHONE_4_7_INCH_AND_ABOVE){
- cell.paymentConfirmationItemPriceLabel.font = [UIFont fontWithName:FONT_LATO_BOLD size:14.0f];
- }
- //AS Temp
- if(indexPath.row % 2 == 0) {
- [cell setPaymentConfirmationNewCollectionViewCellStatusType:PaymentConfirmationNewCollectionViewCellStatusTypeAcceptDecline];
- }
- else {
- [cell setPaymentConfirmationNewCollectionViewCellStatusType:PaymentConfirmationNewCollectionViewCellStatusTypePaymentDeclined];
- }
- [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"];
- //END AS Temp
- return cell;
- }
- BaseCollectionViewCell *cell = [[BaseCollectionViewCell alloc] init];
- return cell;
- }
- #pragma mark Delegate
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- }
- #pragma mark - PaymentConfirmationNewCollectionView
- #pragma mark Delegare
- - (void)paymentConfirmationNewCollectionViewCellResizeViewWithTotalHeight:(CGFloat)height indexPath:(NSIndexPath *)currentIndexPath {
- // if(!self.isDataPaymentConfirmationNewCollectionViewHeightUpdated) {
- self.isDataPaymentConfirmationNewCollectionViewHeightUpdated = YES;
- self.newPaymentConfirmationNewCollectionViewCellHeight = height;
- [self.paymentConfirmationNewView.collectionView reloadItemsAtIndexPaths:@[currentIndexPath]];
- // }
- }
- #pragma mark - Custom Method
- - (void)backButtonDidTapped {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)paymentConfirmationNewCollectionViewCellDidTappedDeclineButton {
- NSLog(@"Decline button pressed");
- }
- - (void)paymentConfirmationNewCollectionViewCellDidTappedAcceptButton {
- NSLog(@"Accept button pressed");
- }
- - (void)createConfirmationButtonDidTapped {
- NSLog(@"Create Confirmation button pressed");
- //AS TEMP
- [UIView animateWithDuration:0.2f animations:^{
- self.additionalCostPopupViewController.view.alpha = 1.0f;
- }];
- //END AS TEMP
- }
- //AS TEMP
- - (void)additionalCostPopupViewDidTappedBackgroundButton {
- NSLog(@"BackgroundButton for AdditionalCostPopupView");
- [UIView animateWithDuration:0.2f animations:^{
- self.additionalCostPopupViewController.view.alpha = 0.0f;
- }];
- }
- - (void)additionalCostPopupViewDidTappedDeclineButton {
- NSLog(@"Decline Button for AdditionalCostPopupView");
- }
- - (void)additionalCostPopupViewDidTappedAcceptButton {
- NSLog(@"Accept Button for AdditionalCostPopupView");
- }
- //END AS TEMP
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement