vdeep
10/3/2016 - 5:28 PM

katchup

katchup

- (void)addSwipeViewWith:(NSIndexPath*)currentIndexPath {
    
    NSLog(@"currentIndexPath %@ ",currentIndexPath);
    
//    _selectedImageView = ((KUMediaCell*)gesture.view).imageView;
    
//    NSMutableArray *photos = [[NSMutableArray alloc] init];
//    MWPhoto *photo;
//    
//    NSUInteger lastIndex = [[[self.collectionView.fetchedResultController sections] objectAtIndex:0] numberOfObjects];
//    
//    for (int i = 0; i < lastIndex; i++) {
//        
//                NSIndexPath* indexPath = [NSIndexPath indexPathForItem:i inSection:0];
//                Media* media = [self.collectionView.fetchedResultController objectAtIndexPath:indexPath];
//
//        
//       /* Media* media = [[Media alloc]init];
//        media.url = _fullMediaCollection[i][@"url"];
//        media.mediaID = _fullMediaCollection[i][@"id"];
//        media.commentCount = _fullMediaCollection[i][@"numComments"];
//        media.loveCount = _fullMediaCollection[i][@"numOfLove"];
//        media.hasUserLoved = _fullMediaCollection[i][@"userHasLovedMedia"];
//        media.width = _fullMediaCollection[i][@"width"];
//        media.height = _fullMediaCollection[i][@"height"];
//        
//        */
//        
//        if (media) {
//            //            photo = [MWPhoto photoWithURL:[NSURL URLWithString:media.url]];
//            photo = [MWPhoto photoWithMedia:media];
//            [photos addObject:photo];
//            
//            [_albumMedias addObject:media];
//        }
//    }
    
    // Create browser
    if (!browser) {
        browser = [[MWPhotoBrowser alloc] init];
    }
//        browser.photosMediaArray = _albumMedias;
        browser.delegate = self;
        browser.displayActionButton = NO;
        browser.displayNavArrows = NO;
        browser.displaySelectionButtons = NO;
        browser.alwaysShowControls = YES;
        browser.zoomPhotosToFill = YES;
        browser.enableGrid = NO;
        browser.startOnGrid = YES;
        browser.enableSwipeToDismiss = NO;
        browser.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [browser setCurrentPhotoIndex:currentIndexPath.row];
        [browser.view setHidden:false];
        
        [self presentViewController:browser animated:NO completion:nil];

//        [self addChildViewController:browser];
//        [self.view addSubview:browser.view];
//        [browser didMoveToParentViewController:self];
//    } else {
//        browser.fixedPhotosArray = photos;
//        [browser numberOfPhotos];
//        [browser setCurrentPhotoIndex:currentIndexPath.row];
//    }

}

#pragma mark - MWPhotoBrowserDelegate

- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return _fullMediaCollection.count;
}

- (id<MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    NSDictionary *photoObject = _fullMediaCollection[index];
    MWPhoto *photo = [[MWPhoto alloc] initWithURL:[NSURL URLWithString:photoObject[@"url"]]];
    photo.isProgressNeed = false;
    return photo;
}