diff --git a/MiniKeePass/EditGroupViewController.h b/MiniKeePass/EditGroupViewController.h new file mode 100644 index 00000000..52ce782d --- /dev/null +++ b/MiniKeePass/EditGroupViewController.h @@ -0,0 +1,16 @@ +// +// EditGroupViewController.h +// MiniKeePass +// +// Created by Jason Rush on 6/23/11. +// Copyright 2011 Self. All rights reserved. +// + +#import + + +@interface EditGroupViewController : FormViewController { + +} + +@end diff --git a/MiniKeePass/EditGroupViewController.m b/MiniKeePass/EditGroupViewController.m new file mode 100644 index 00000000..46d638c6 --- /dev/null +++ b/MiniKeePass/EditGroupViewController.m @@ -0,0 +1,14 @@ +// +// EditGroupViewController.m +// MiniKeePass +// +// Created by Jason Rush on 6/23/11. +// Copyright 2011 Self. All rights reserved. +// + +#import "EditGroupViewController.h" + + +@implementation EditGroupViewController + +@end diff --git a/MiniKeePass/ImagesViewController.h b/MiniKeePass/ImagesViewController.h new file mode 100644 index 00000000..782a96f3 --- /dev/null +++ b/MiniKeePass/ImagesViewController.h @@ -0,0 +1,28 @@ +// +// ImagesViewController.h +// MiniKeePass +// +// Created by Jason Rush on 6/22/11. +// Copyright 2011 Self. All rights reserved. +// + +#import + +@protocol ImagesViewControllerDelegate; + +@interface ImagesViewController : UIViewController { + UIView *imagesView; + NSMutableArray *imageViews; + UIImageView *selectedImageView; + id delegate; +} + +@property (nonatomic, retain) id delegate; + +- (void)setSelectedImage:(NSUInteger)index; + +@end + +@protocol ImagesViewControllerDelegate +- (void)imagesViewController:(ImagesViewController*)controller imageSelected:(NSUInteger)index; +@end diff --git a/MiniKeePass/ImagesViewController.m b/MiniKeePass/ImagesViewController.m new file mode 100644 index 00000000..5eb11f0d --- /dev/null +++ b/MiniKeePass/ImagesViewController.m @@ -0,0 +1,109 @@ +// +// ImagesViewController.m +// MiniKeePass +// +// Created by Jason Rush on 6/22/11. +// Copyright 2011 Self. All rights reserved. +// + +#import "ImagesViewController.h" +#import "MiniKeePassAppDelegate.h" + +#define IMAGES_PER_ROW 7 +#define SIZE 24 +#define HORIZONTAL_SPACING 10.5 +#define VERTICAL_SPACING 10.5 + +@implementation ImagesViewController + +@synthesize delegate; + +- (id)init { + self = [super init]; + if (self) { + // Get the application delegate + MiniKeePassAppDelegate *appDelegate = (MiniKeePassAppDelegate*)[[UIApplication sharedApplication] delegate]; + + imagesView = [[UIView alloc] init]; + + CGRect frame = CGRectMake(HORIZONTAL_SPACING, VERTICAL_SPACING, SIZE, SIZE); + + // Load the images + imageViews = [[NSMutableArray alloc] initWithCapacity:NUM_IMAGES]; + for (NSUInteger index = 0; index < NUM_IMAGES; index += IMAGES_PER_ROW) { + for (int i = 0; i < IMAGES_PER_ROW; i++) { + UIImage *image = [appDelegate loadImage:index + i]; + + UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; + imageView.frame = frame; + [imagesView addSubview:imageView]; + + [imageViews addObject:imageView]; + + [imageView release]; + + frame.origin.x += SIZE + 2 * HORIZONTAL_SPACING; + } + + frame.origin.x = HORIZONTAL_SPACING; + frame.origin.y += SIZE + 2 * VERTICAL_SPACING; + } + + UIImage *selectedImage = [UIImage imageNamed:@"checkmark"]; + selectedImageView = [[UIImageView alloc] initWithImage:selectedImage]; + [imagesView addSubview:selectedImageView]; + + [self setSelectedImage:0]; + + UIScrollView *scrollView = [[UIScrollView alloc] init]; + scrollView.backgroundColor = [UIColor whiteColor]; + scrollView.alwaysBounceHorizontal = NO; + scrollView.contentSize = CGSizeMake(IMAGES_PER_ROW * (SIZE + 2 * HORIZONTAL_SPACING), ceil(((CGFloat)NUM_IMAGES) / IMAGES_PER_ROW) * (SIZE + 2 * VERTICAL_SPACING)); + [scrollView addSubview:imagesView]; + + UIGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageSelected:)]; + [scrollView addGestureRecognizer:gestureRecognizer]; + [gestureRecognizer release]; + + self.view = scrollView; + + [scrollView release]; + } + return self; +} + +- (void)dealloc { + [imagesView release]; + [imageViews release]; + [selectedImageView release]; + [delegate release]; + [super dealloc]; +} + +- (void)setSelectedImage:(NSUInteger)index { + if (index >= NUM_IMAGES) { + return; + } + + NSUInteger row = index / IMAGES_PER_ROW; + NSUInteger col = index - (row * IMAGES_PER_ROW); + + CGSize size = selectedImageView.image.size; + CGRect frame = CGRectMake((col + 1) * (SIZE + 2 * HORIZONTAL_SPACING) - size.width, (row + 1) * (SIZE + 2 * VERTICAL_SPACING) - size.height, size.width, size.height); + selectedImageView.frame = frame; +} + +- (void)imageSelected:(UIGestureRecognizer*)gestureRecognizer { + CGPoint point = [gestureRecognizer locationInView:imagesView]; + NSUInteger col = point.x / (SIZE + 2 * HORIZONTAL_SPACING); + NSUInteger row = point.y / (SIZE + 2 * VERTICAL_SPACING); + + NSUInteger index = row * IMAGES_PER_ROW + col; + [self setSelectedImage:index]; + + if ([delegate respondsToSelector:@selector(imageViewController:imageSelected:)]) { + [delegate imagesViewController:self imageSelected:index]; + } +} + +@end diff --git a/images/checkmark.png b/images/checkmark.png new file mode 100644 index 00000000..b2327fb3 Binary files /dev/null and b/images/checkmark.png differ diff --git a/images/checkmark.svg b/images/checkmark.svg new file mode 100644 index 00000000..e9f07b7f --- /dev/null +++ b/images/checkmark.svg @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/images/checkmark@2x.png b/images/checkmark@2x.png new file mode 100644 index 00000000..3ca28b24 Binary files /dev/null and b/images/checkmark@2x.png differ