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