#202: Tag and Albumg integration with Gallery
This commit is contained in:
parent
5f71d06e56
commit
505911c5a8
4 changed files with 47 additions and 6 deletions
|
@ -144,7 +144,21 @@
|
|||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - Table view delegate
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// get the tag
|
||||
NSUInteger row = [indexPath row];
|
||||
Album *album = [self.albums objectAtIndex:row];
|
||||
|
||||
if (album.quantity >0 ){
|
||||
// open the gallery with a tag that contains at least one picture.
|
||||
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[GalleryViewController alloc]initWithAlbum:album]];
|
||||
self.viewDeckController.centerController = nav;
|
||||
[NSThread sleepForTimeInterval:(300+arc4random()%700)/1000000.0]; // mimic delay... not really necessary
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark
|
||||
#pragma mark - Methods to get albums via json
|
||||
|
|
|
@ -24,9 +24,14 @@
|
|||
#import "WebPhoto.h"
|
||||
#import "TMQuiltView.h"
|
||||
#import "TMPhotoQuiltViewCell.h"
|
||||
#import "Album.h"
|
||||
#import "Tag.h"
|
||||
|
||||
@interface GalleryViewController : TMQuiltViewController
|
||||
|
||||
@property (nonatomic, strong) NSMutableArray *photos;
|
||||
|
||||
- (id) initWithTag:(Tag *) tag;
|
||||
- (id) initWithAlbum:(Album *) album;
|
||||
|
||||
@end
|
||||
|
|
|
@ -30,12 +30,17 @@
|
|||
// for loading page
|
||||
@property (nonatomic) NSInteger page;
|
||||
|
||||
// for albums or tags
|
||||
@property (nonatomic,weak) Album *album;
|
||||
@property (nonatomic,weak) Tag *tag;
|
||||
@end
|
||||
|
||||
@implementation GalleryViewController
|
||||
@synthesize photos=_photos;
|
||||
@synthesize isLoading=_isLoading;
|
||||
@synthesize page=_page;
|
||||
@synthesize album=_album;
|
||||
@synthesize tag=_tag;
|
||||
|
||||
- (id)init
|
||||
{
|
||||
|
@ -49,6 +54,25 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithTag:(Tag *) tag
|
||||
{
|
||||
self = [self init];
|
||||
if (self){
|
||||
self.tag = tag;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithAlbum:(Album *) album
|
||||
{
|
||||
self = [self init];
|
||||
if (self){
|
||||
self.album = album;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
@ -163,7 +187,7 @@
|
|||
- (CGFloat)quiltView:(TMQuiltView *)quiltView heightForCellAtIndexPath:(NSIndexPath *)indexPath {
|
||||
WebPhoto *photo = [self.photos objectAtIndex:indexPath.row];
|
||||
|
||||
return [photo.thumbHeight integerValue] / [self quiltViewNumberOfColumns:quiltView];
|
||||
return [photo.thumbHeight integerValue];
|
||||
}
|
||||
|
||||
-(void) loadPhotos
|
||||
|
|
|
@ -250,12 +250,10 @@
|
|||
Tag *tag = [self.tags objectAtIndex:row];
|
||||
|
||||
if (tag.quantity >0 && self.readOnly == NO){
|
||||
|
||||
/*
|
||||
// open the gallery with a tag that contains at least one picture.
|
||||
GalleryViewController *galleryController = [[GalleryViewController alloc]initWithTagName:[tag.tagName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||
[self.navigationController pushViewController:galleryController animated:YES];
|
||||
*/
|
||||
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:[[GalleryViewController alloc]initWithTag:tag]];
|
||||
self.viewDeckController.centerController = nav;
|
||||
[NSThread sleepForTimeInterval:(300+arc4random()%700)/1000000.0]; // mimic delay... not really necessary
|
||||
}
|
||||
|
||||
if (self.readOnly == YES){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue