Skip to content

Commit

Permalink
version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Hahn committed Jan 8, 2014
1 parent dae46b8 commit 2692d1b
Show file tree
Hide file tree
Showing 60 changed files with 3,805 additions and 13 deletions.
21 changes: 10 additions & 11 deletions LICENSE
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
The MIT License (MIT)

Copyright (c) 2014 Mario Hahn
Copyright (c) 2012-2013, Monospace Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions MHVideoPhotoGallery.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pod::Spec.new do |s|
s.name = 'MHVideoPhotoGallery'
s.version = '1.0'
s.license = 'MIT'
s.homepage = 'https://github.com/mariohahn/MHVideoPhotoGallery'
s.author = {
'Mario Hahn' => '[email protected]'
}
s.summary = 'Gallery for iOS 7 Devices.'
s.platform = :ios
s.source = {
:git => 'https://github.com/mariohahn/MHVideoPhotoGallery.git',
:tag => 'v1.0'
}
s.source_files = ['MHVideoPhotoGallery/MMHVideoPhotoGallery/']
s.ios.deployment_target = '7.0'
s.requires_arc = true
end
632 changes: 632 additions & 0 deletions MHVideoPhotoGallery.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions MHVideoPhotoGallery.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions MHVideoPhotoGallery/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// MHVideoPhotoGallery
//
// Created by Mario Hahn on 19.09.13.
// Copyright (c) 2013 Mario Hahn. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
46 changes: 46 additions & 0 deletions MHVideoPhotoGallery/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.m
// MHVideoPhotoGallery
//
// Created by Mario Hahn on 19.09.13.
// Copyright (c) 2013 Mario Hahn. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
19 changes: 19 additions & 0 deletions MHVideoPhotoGallery/ExampleViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ExampleViewController.h
// MHVideoPhotoGallery
//
// Created by Mario Hahn on 30.09.13.
// Copyright (c) 2013 Mario Hahn. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MHGalleryCells.h"
#import "AnimatorShowDetailForPresentingMHGallery.h"
#import "AnimatorShowDetailForDismissMHGallery.h"

@interface UINavigationController (Rotation)
@end

@interface ExampleViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UIViewControllerTransitioningDelegate>
@property (strong,nonatomic) IBOutlet UITableView *tableView;
@end
222 changes: 222 additions & 0 deletions MHVideoPhotoGallery/ExampleViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
//
// ExampleViewController.m
// MHVideoPhotoGallery
//
// Created by Mario Hahn on 30.09.13.
// Copyright (c) 2013 Mario Hahn. All rights reserved.
//

#import "ExampleViewController.h"
#import "MHGalleryOverViewController.h"

@interface ExampleViewController ()
@property(nonatomic,strong)NSArray *galleryDataSource;
@property(nonatomic,strong) UIImageView *imageViewForPresentingMHGallery;
@end

@implementation ExampleViewController

- (void)viewDidLoad
{
[super viewDidLoad];


self.title = @"Gallery";



MHGalleryItem *item0 = [[MHGalleryItem alloc]initWithURL:@"https://dl.dropboxusercontent.com/u/17911939/UIViewios7.png"
galleryType:MHGalleryTypeImage];

MHGalleryItem *item1 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/reminders_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item2 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/videos_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item3 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/keynote_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item4 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/iphoto_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item5 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/imovie_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item6 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/iphone/shared/built-in-apps/images/facetime_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item7 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/siri_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item8 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/photos_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item9 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/ibooks_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item10 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/facetime_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item11 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/itunesstore_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item12 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/appstore_screen_2x.jpg"
galleryType:MHGalleryTypeImage];
MHGalleryItem *item13 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/garageband_screen_2x.jpg"
galleryType:MHGalleryTypeImage];

MHGalleryItem *item14 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/built-in-apps/images/safari_screen_2x.jpg"
galleryType:MHGalleryTypeImage];

MHGalleryItem *item15 = [[MHGalleryItem alloc]initWithURL:@"http://mcms.tailored-apps.com/videos/42/1374753780Reuters_Peru.mp4"
galleryType:MHGalleryTypeVideo];

MHGalleryItem *item16 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/media/us/iphone-5c/2013/10ba527a-1a10-3f70-aae814f8/feature/iphone5c-feature-cc-us-20131003_r848-9dwc.mov?width=848&height=480"
galleryType:MHGalleryTypeVideo];




MHGalleryItem *item17 = [[MHGalleryItem alloc]initWithURL:@"http://store.storeimages.cdn-apple.com/3769/as-images.apple.com/is/image/AppleInc/H4825_FV2?wid=1204&hei=306&fmt=jpeg&qlt=95&op_sharpen=0&resMode=bicub&op_usm=0.5,0.5,0,0&iccEmbed=0&layer=comp&.v=1367279419213"
galleryType:MHGalleryTypeImage];

MHGalleryItem *item18 = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/media/us/ipad-air/2013/0be12b9f-265c-474c-a0cc-d3c4c304c031/feature/ipadair-feature-cc-us-20131114_r848-9dwc.mov?width=848&height=480"
galleryType:MHGalleryTypeVideo];

MHGalleryItem *errorImage = [[MHGalleryItem alloc]initWithURL:@"http://images.apple.com/ipad-air/bui"
galleryType:MHGalleryTypeImage];

item0.description = @"MHValidation Screenshot";
item1.description = @"App Store App Screenshot from iOS7";
item2.description = @"Calendar App Screenshot from iOS7";
item3.description = @"Camera App Screenshot from iOS7";
item4.description = @"Clock App Screenshot from iOS7";
item5.description = @"Compass App Screenshot from iOS7";
item6.description = @"Gamecenter App Screenshot from iOS7";


self.galleryDataSource = @[
@[item0,item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11,item12,item13,item14,item15,item16,item17,item18,errorImage],
@[item0,item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11,item12,item13,item14,item15,item16,item17,item18,errorImage]
];
[self.tableView setBackgroundColor:[UIColor whiteColor]];
[self.tableView registerClass:[MHGalleryCollectionViewCell class]
forCellReuseIdentifier:@"MHGalleryCollectionViewCell"];
[self.tableView reloadData];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.galleryDataSource.count;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return [self.galleryDataSource[collectionView.tag] count];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 210;

}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 30)];
view.backgroundColor = [UIColor clearColor];

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(25, 0, 320, 30)];
label.textColor = [UIColor blackColor];
label.font = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:20];
label.text = [NSString stringWithFormat:@"Gallery %@",@(section)];
label.backgroundColor = [UIColor clearColor];

[view addSubview:label];
return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 30;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *cellIdentifier = nil;
cellIdentifier = @"MHGalleryCollectionViewCell";

MHGalleryCollectionViewCell *cell = (MHGalleryCollectionViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (!cell){
cell = [[MHGalleryCollectionViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
[cell.collectionView setDelegate:self];
[cell.collectionView setDataSource:self];
[cell.collectionView setBackgroundColor:[UIColor whiteColor]];
[cell.collectionView setTag:indexPath.section];
[cell.collectionView reloadData];

return cell;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell =nil;
NSString *cellIdentifier = @"MHGalleryOverViewCell";
cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
NSIndexPath *indexPathNew = [NSIndexPath indexPathForRow:indexPath.row inSection:collectionView.tag];
[self makeOverViewDetailCell:(MHGalleryOverViewCell*)cell atIndexPath:indexPathNew];

return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

self.imageViewForPresentingMHGallery = [(MHGalleryOverViewCell*)[collectionView cellForItemAtIndexPath:indexPath] iv];
[[MHGallerySharedManager sharedManager] setGalleryItems:self.galleryDataSource[indexPath.section]];

MHGalleryOverViewController *gallery = [MHGalleryOverViewController new];
gallery.viewMode = MHGalleryViewModeList;
gallery.currentPage = indexPath.row;
[gallery viewDidLoad];
gallery.finishedCallback = ^(NSUInteger photoIndex) {

NSIndexPath * newIndexPath = [NSIndexPath indexPathForRow:photoIndex inSection:0];
CGRect cellFrame = [[collectionView collectionViewLayout] layoutAttributesForItemAtIndexPath:newIndexPath].frame;
[collectionView scrollRectToVisible:cellFrame
animated:NO];

dispatch_async(dispatch_get_main_queue(), ^{
[collectionView reloadItemsAtIndexPaths:@[newIndexPath]];
self.imageViewForPresentingMHGallery = [(MHGalleryOverViewCell*)[collectionView cellForItemAtIndexPath:newIndexPath] iv];
[self dismissViewControllerAnimated:YES completion:nil];
});
};

MHGalleryImageViewerViewController *detail = [MHGalleryImageViewerViewController new];
detail.pageIndex = indexPath.row;

UINavigationController *nav = [UINavigationController new];

nav.viewControllers = @[gallery,detail];
nav.transitioningDelegate = self;
nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nav animated:YES completion:nil];
}


-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationPortrait;
}
-(BOOL)shouldAutorotate{
return NO;
}


-(id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
AnimatorShowDetailForDismissMHGallery *detail = [AnimatorShowDetailForDismissMHGallery new];
detail.iv = self.imageViewForPresentingMHGallery;
return detail;
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source {
AnimatorShowDetailForPresentingMHGallery *detail = [AnimatorShowDetailForPresentingMHGallery new];
detail.iv = self.imageViewForPresentingMHGallery;
return detail;
}


-(void)makeOverViewDetailCell:(MHGalleryOverViewCell*)cell atIndexPath:(NSIndexPath*)indexPath{
MHGalleryItem *item = self.galleryDataSource[indexPath.section][indexPath.row];
[cell.iv setImageWithURL:[NSURL URLWithString:item.urlString]];
}


@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading

0 comments on commit 2692d1b

Please sign in to comment.