Skip to content

Commit

Permalink
Updated SSPostmarkVewController to support the new SSPostmark initWit…
Browse files Browse the repository at this point in the history
…hApiKey: method
  • Loading branch information
Skylar Schipper committed Jun 19, 2012
1 parent 9d1b745 commit dd8b9b4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions SSPostmark.m
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ - (BOOL)isValid {
}
return YES;
}

- (NSDictionary *)asDict {
NSMutableDictionary *d = [NSMutableDictionary new];
if (self.htmlBody != nil) {
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion SSPostmark/SSViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "SSPostmarkViewController.h"

@interface SSViewController : UIViewController
@interface SSViewController : UIViewController <SSPostmarkViewDelegate>

- (IBAction)sendMail:(id)sender;

Expand Down
10 changes: 10 additions & 0 deletions SSPostmark/SSViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@

@implementation SSViewController

- (void)postmark:(id)postmark returnedMessage:(NSDictionary *)message withStatusCode:(NSUInteger)code {
NSLog(@"%s\n%@",__PRETTY_FUNCTION__, message);
[self dismissModalViewControllerAnimated:YES];
}
- (void)postmark:(id)postmark encounteredError:(SSPMErrorType)type {
NSLog(@"%s :: %i",__PRETTY_FUNCTION__,type);
}

- (void)sendMail:(id)sender {
SSPostmarkViewController *pm = [[SSPostmarkViewController alloc] init];
pm.delegate = self;
pm.barTitle = @"SSPostmark";
pm.to = @"test@test.com";
pm.apiKey = @"POSTMARK_API_TEST";
pm.modalPresentationStyle = UIModalPresentationFullScreen;
pm.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:pm animated:YES];
Expand Down
13 changes: 13 additions & 0 deletions SSPostmarkViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@

#define SSPM_FIELD_PADDING 20

@protocol SSPostmarkViewDelegate;

@interface SSPostmarkViewController : UIViewController <SSPostmarkDelegate, UITextFieldDelegate, UITextViewDelegate, UIActionSheetDelegate>

@property (nonatomic, assign) id<SSPostmarkViewDelegate> delegate;

@property (nonatomic, retain) NSString *barTitle;
@property (nonatomic, retain) NSString *to;
@property (nonatomic, strong) NSString *apiKey;

- (void)sendMail:(id)sender;

Expand All @@ -25,3 +30,11 @@
- (void)keyboardNotification:(NSNotification *)notification;

@end


@protocol SSPostmarkViewDelegate <SSPostmarkDelegate>

@required


@end
22 changes: 11 additions & 11 deletions SSPostmarkViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ - (void)okayToSend;
@end

@implementation SSPostmarkViewController
@synthesize barTitle = _barTitle, to = _to;

- (void)postmark:(id)postmark returnedMessage:(NSDictionary *)message withStatusCode:(NSUInteger)code {
if (code == 0) {
[self dismissModalViewControllerAnimated:YES];
}
}
@synthesize barTitle = _barTitle, to = _to, delegate = _delegate, apiKey = _apiKey;

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == actionSheet.cancelButtonIndex) {
Expand All @@ -45,8 +39,10 @@ - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSIn

- (void)okayToSend {
if (_postmark == nil) {
_postmark = [[SSPostmark alloc] init];
_postmark.delegate = self;
_postmark = [[SSPostmark alloc] initWithApiKey:self.apiKey];
if (self.delegate != nil) {
_postmark.delegate = self.delegate;
}
}
SSPostmarkMessage *message = [SSPostmarkMessage new];
message.to = self.to;
Expand Down Expand Up @@ -185,7 +181,6 @@ - (void)sendMail:(id)sender {
}

- (void)keyboardNotification:(NSNotification *)notification {
NSLog(@"%@",notification);
CGFloat keyDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue] - .01;
CGRect frame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
if ([notification.name isEqualToString:UIKeyboardWillShowNotification]) {
Expand All @@ -209,7 +204,6 @@ - (void)keyboardNotification:(NSNotification *)notification {
}

- (void)dismissKeys:(id)sender {
NSLog(@"%s",__PRETTY_FUNCTION__);
if (sender == _sendButton) {
[_messageBodyView resignFirstResponder];
return;
Expand All @@ -235,4 +229,10 @@ - (void)setBarTitle:(NSString *)barTitle {
_barTitleLabel.text = barTitle;
[self.view bringSubviewToFront:_barTitleLabel];
}
- (void)setDelegate:(id<SSPostmarkViewDelegate>)delegate {
_delegate = delegate;
if (_postmark != nil) {
_postmark.delegate = delegate;
}
}
@end

0 comments on commit dd8b9b4

Please sign in to comment.