Skip to content

Commit

Permalink
Merge pull request #22 from thedrick/master
Browse files Browse the repository at this point in the history
Adds a gitignore file and the ability to choose a photo from your photo library
  • Loading branch information
romaonthego committed Nov 5, 2013
2 parents 1d6ddc4 + c9ce9a6 commit c338afa
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout

#CocoaPods
Pods
1 change: 1 addition & 0 deletions REComposeViewController/REComposeSheetView.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
@property (readonly, nonatomic) UINavigationBar *navigationBar;
@property (readonly, nonatomic) UIView *textViewContainer;
@property (readonly, nonatomic) DEComposeTextView *textView;
@property (readonly, nonatomic) UIButton *attachmentViewButton;

@end

Expand Down
4 changes: 4 additions & 0 deletions REComposeViewController/REComposeSheetView.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ - (id)initWithFrame:(CGRect)frame
}
[_attachmentView addSubview:_attachmentContainerView];
_attachmentView.hidden = YES;

_attachmentViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
_attachmentViewButton.frame = _attachmentView.bounds;
[_attachmentView addSubview:_attachmentViewButton];

[self addSubview:_navigationBar];
}
Expand Down
1 change: 1 addition & 0 deletions REComposeViewController/REComposeViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef void (^REComposeViewControllerCompletionHandler)(REComposeViewController
@property (weak, readwrite, nonatomic) id<REComposeViewControllerDelegate> delegate;
@property (assign, readwrite, nonatomic) NSInteger cornerRadius;
@property (assign, readwrite, nonatomic) BOOL hasAttachment;
@property (assign, readonly, nonatomic) BOOL userUpdatedAttachment;
@property (strong, readwrite, nonatomic) NSString *text;
@property (strong, readwrite, nonatomic) NSString *placeholderText;
@property (strong, readonly, nonatomic) UINavigationBar *navigationBar;
Expand Down
37 changes: 36 additions & 1 deletion REComposeViewController/REComposeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
#import "REComposeViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface REComposeViewController ()
@interface REComposeViewController () <UIImagePickerControllerDelegate, UINavigationControllerDelegate>

@property (strong, readonly, nonatomic) REComposeBackgroundView *backgroundView;
@property (strong, readonly, nonatomic) UIView *containerView;
@property (strong, readonly, nonatomic) REComposeSheetView *sheetView;
@property (assign, readwrite, nonatomic) BOOL userUpdatedAttachment;

@end

Expand Down Expand Up @@ -109,6 +110,9 @@ - (void)viewDidLoad
_attachmentImage = [UIImage imageNamed:@"REComposeViewController.bundle/URLAttachment"];

_sheetView.attachmentImageView.image = _attachmentImage;
[_sheetView.attachmentViewButton addTarget:self
action:@selector(didTapAttachmentView:)
forControlEvents:UIControlEventTouchUpInside];
}

- (void)didMoveToParentViewController:(UIViewController *)parent
Expand Down Expand Up @@ -319,6 +323,37 @@ - (void)postButtonPressed
_completionHandler(self, REComposeResultPosted);
}

#pragma mark -
#pragma mark UIImagePickerControllerDelegate

- (void)didTapAttachmentView:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// If our device has a cmera, we want to take a picture, otherwise we just pick from the library
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
} else {
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}

picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self setAttachmentImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
self.userUpdatedAttachment = YES;
[picker dismissViewControllerAnimated:YES completion:nil];
[self.sheetView.textView becomeFirstResponder];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
[self.sheetView.textView becomeFirstResponder];
}

#pragma mark -
#pragma mark Orientation

Expand Down

0 comments on commit c338afa

Please sign in to comment.