From bd5ec19027a665ec1c68e93df6f784b5a0e27706 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 16:12:54 +0100 Subject: [PATCH 1/9] Added support for loading avatar image from a URl --- EBPhotoPagesController/EBCommentCell.m | 27 ++++++++++++++++++- .../EBPhotoCommentProtocol.h | 3 +++ .../DEMOViewController.h | 1 + .../DEMOViewController.m | 2 -- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/EBPhotoPagesController/EBCommentCell.m b/EBPhotoPagesController/EBCommentCell.m index 6e49cc3..18ca3cb 100644 --- a/EBPhotoPagesController/EBCommentCell.m +++ b/EBPhotoPagesController/EBCommentCell.m @@ -131,6 +131,22 @@ - (void)loadDateLabel [self setDateLabel:dateLabel]; [self addSubview:dateLabel]; } + + - (void)downloadImageWithURL:(NSURL *)url completionBlock:(void (^)(BOOL succeeded, UIImage *image))completionBlock + { + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [NSURLConnection sendAsynchronousRequest:request + queue:[NSOperationQueue mainQueue] + completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { + if ( !error ) + { + UIImage *image = [[UIImage alloc] initWithData:data]; + completionBlock(YES,image); + } else{ + completionBlock(NO,nil); + } + }]; + } - (void)setComment:(id)comment @@ -147,7 +163,16 @@ - (void)setComment:(id)comment } if([comment respondsToSelector:@selector(authorAvatar)]){ - [self.authorAvatar setImage:[comment authorAvatar]]; + if (comment.authorAvatar != nil) { + [self.authorAvatar setImage:[comment authorAvatar]]; + } + + if (comment.authorAvatarURL != nil) { + [self downloadImageWithURL:comment.authorAvatarURL completionBlock:^(BOOL succeeded, UIImage *image) { + [self.authorAvatar setImage:image]; + }]; + } + [self.authorAvatar.layer setMasksToBounds:YES]; [self.authorAvatar.layer setRasterizationScale:[UIScreen mainScreen].scale]; [self.authorAvatar.layer setShouldRasterize:YES]; diff --git a/EBPhotoPagesController/EBPhotoCommentProtocol.h b/EBPhotoPagesController/EBPhotoCommentProtocol.h index f7d58fd..ad80718 100644 --- a/EBPhotoPagesController/EBPhotoCommentProtocol.h +++ b/EBPhotoPagesController/EBPhotoCommentProtocol.h @@ -34,6 +34,9 @@ //This is an image of the person who posted the comment - (UIImage *)authorAvatar; + +/// A URL that represents the image that is shown on the comment +- (NSURL *)authorAvatarURL; //This may contain additional application specific information you want to provide about the comment. - (NSDictionary *)metaInfo; diff --git a/EBPhotoPagesControllerDemo/DEMOViewController.h b/EBPhotoPagesControllerDemo/DEMOViewController.h index ca120d7..0f8424b 100644 --- a/EBPhotoPagesControllerDemo/DEMOViewController.h +++ b/EBPhotoPagesControllerDemo/DEMOViewController.h @@ -22,6 +22,7 @@ @property (assign) BOOL simulateLatency; @property (strong, nonatomic) IBOutlet UIButton *viewPhotosButton; @property (strong) NSArray *photos; + @property NSArray *braclets; - (IBAction)didSelectViewPhotos:(id)sender; - (IBAction)didToggleLatency:(id)sender; diff --git a/EBPhotoPagesControllerDemo/DEMOViewController.m b/EBPhotoPagesControllerDemo/DEMOViewController.m index aef4d43..a638f61 100644 --- a/EBPhotoPagesControllerDemo/DEMOViewController.m +++ b/EBPhotoPagesControllerDemo/DEMOViewController.m @@ -208,8 +208,6 @@ - (void)loadView @"authorImage": [UIImage imageNamed:@"kerem.jpg"], @"authorName" : @"Kerem"}], ]; - - [self setPhotos:@[ [DEMOPhoto photoWithProperties: @{@"imageFile": @"photo1.jpg", From e0849c723afdcfd49e189b56624ef522de4109e1 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 16:20:08 +0100 Subject: [PATCH 2/9] Updated --- EBPhotoPagesControllerDemo/DEMOViewController.h | 1 - 1 file changed, 1 deletion(-) diff --git a/EBPhotoPagesControllerDemo/DEMOViewController.h b/EBPhotoPagesControllerDemo/DEMOViewController.h index 0f8424b..ca120d7 100644 --- a/EBPhotoPagesControllerDemo/DEMOViewController.h +++ b/EBPhotoPagesControllerDemo/DEMOViewController.h @@ -22,7 +22,6 @@ @property (assign) BOOL simulateLatency; @property (strong, nonatomic) IBOutlet UIButton *viewPhotosButton; @property (strong) NSArray *photos; - @property NSArray *braclets; - (IBAction)didSelectViewPhotos:(id)sender; - (IBAction)didToggleLatency:(id)sender; From 992beeb1d05baa8f847ada4c399b69f42c21ea99 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 18:17:16 +0100 Subject: [PATCH 3/9] Added support for customizing the user interface via EBConfig --- EBConfig.h | 74 +++++++++++ EBConfig.m | 115 ++++++++++++++++++ EBPhotoPagesController/EBCaptionView.m | 11 +- EBPhotoPagesController/EBCommentCell.m | 42 +++++-- EBPhotoPagesController/EBCommentsView.m | 16 ++- EBPhotoPagesController/EBPhotoPagesFactory.m | 22 ++++ EBPhotoPagesController/EBTagPopover.m | 3 +- .../project.pbxproj | 20 +++ EBPhotoPagesControllerDemo/DEMOComment.m | 4 + .../DEMOViewController.m | 8 ++ NSDate+TimeAgo.h | 15 +++ NSDate+TimeAgo.m | 67 ++++++++++ 12 files changed, 385 insertions(+), 12 deletions(-) create mode 100644 EBConfig.h create mode 100644 EBConfig.m create mode 100644 NSDate+TimeAgo.h create mode 100644 NSDate+TimeAgo.m diff --git a/EBConfig.h b/EBConfig.h new file mode 100644 index 0000000..28dd7ee --- /dev/null +++ b/EBConfig.h @@ -0,0 +1,74 @@ +// +// EBConfig.h +// EBPhotoPagesControllerDemo +// +// Created by Jesse Onolememen on 11/08/2017. +// Copyright © 2017 Eddy Borja. All rights reserved. +// + +#import + +@interface EBConfig : NSObject + +@property (nonatomic, retain) UIFont* bodyFont; +@property (nonatomic, retain) UIFont* titleFont; +@property (nonatomic, retain) UIFont* commentTitleFont; + +@property (nonatomic, retain) UIColor* textColor; +@property (nonatomic, retain) UIColor* tintColor; +@property (nonatomic, retain) NSString* postButtonTitle; +@property (nonatomic, retain) NSDateFormatter* dateFormatter; +@property BOOL shouldUseRelativeTimeFormatting; + +/// This is the font used for the captions and comments +- (UIFont *)bodyFont; + +/// Sets the font used for the captions and comments +- (void)setBodyFont: (UIFont *) font; + +/// This is the font used for the comment titles +- (UIFont *)commentTitleFont; + +/// Sets the font used for the comment avatar title +- (void)setCommentTitleFont: (UIFont *) font; + +/// This is the font used for buttons and titles +- (UIFont *)titleFont; + +/// Sets the font used for buttons and titles +- (void)setTitleFont: (UIFont *) font; + +/// This is the colour for all of the titles +- (UIColor *)textColor; + +/// Sets the colour for all of the titles +- (void)setTextColor: (UIColor *) textColor; + +/// This is the color used for all of the buttons +- (UIColor *)tintColor; + +/// Sets the color used for all of the buttons +- (void)setTintColor: (UIColor *) tintColor; + +/// This is the title for the post button +- (NSString *)postButtonTitle; + +/// Sets the title for the post button +- (void)setPostButtonTitle: (NSString *) postButtonTitle; + +/// This is the formatter used to format the dates for each comment +- (NSDateFormatter *)dateFormatter; + +/// Sets the formatter used to format the dates for each comment +- (void)setDateFormatter: (NSDateFormatter *) dateFormatter; + +/// This is the formatter used to format the dates for each comment +- (BOOL)shouldUseRelativeTimeFormatting; + +/// This is the formatter used to format the dates for each comment +- (void)setShouldUseRelativeTimeFormatting: (BOOL) shouldUseRelativeTimeFormatting; + +/// Global configuration ++(EBConfig *)sharedConfig; + +@end diff --git a/EBConfig.m b/EBConfig.m new file mode 100644 index 0000000..763ae70 --- /dev/null +++ b/EBConfig.m @@ -0,0 +1,115 @@ +// +// EBConfig.m +// EBPhotoPagesControllerDemo +// +// Created by Jesse Onolememen on 11/08/2017. +// Copyright © 2017 Eddy Borja. All rights reserved. +// + +#import "EBConfig.h" + +@implementation EBConfig + +@synthesize bodyFont = _bodyFont; +@synthesize titleFont = _titleFont; +@synthesize commentTitleFont = _commentTitleFont; + +@synthesize textColor = _textColor; +@synthesize tintColor = _tintColor; + +@synthesize postButtonTitle = _postButtonTitle; + +@synthesize dateFormatter = _dateFormatter; +@synthesize shouldUseRelativeTimeFormatting = _shouldUseRelativeTimeFormatting; + ++ (EBConfig *)sharedConfig { + static EBConfig *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[EBConfig alloc] init]; + }); + return sharedInstance; +} + +#pragma mark Body Font + +- (UIFont *)bodyFont { + return _bodyFont; +} + +- (void)setBodyFont: (UIFont *) font { + _bodyFont = font; +} + +#pragma mark Title Font + +- (UIFont *)titleFont { + return _titleFont; +} + +- (void)setTitleFont: (UIFont *) font { + _titleFont = font; +} + +#pragma mark Comment Title Font + +- (UIFont *)commentTitleFont { + return _commentTitleFont; +} + +- (void)setCommentTitleFont:(UIFont *)font { + _commentTitleFont = font; +} + +#pragma mark Text Color + +- (UIColor *)textColor { + return _textColor; +} + +- (void)setTextColor: (UIColor *) textColor { + _textColor = textColor; +} + +#pragma mark Tint Color + +- (UIColor *)tintColor { + return _tintColor; +} + +- (void)setTintColor:(UIColor *)tintColor { + _tintColor = tintColor; +} + +#pragma mark Date Formatter + +- (NSDateFormatter *)dateFormatter { + return _dateFormatter; +} + +- (void)setDateFormatter:(NSDateFormatter *)dateFormatter { + _dateFormatter = dateFormatter; +} + +#pragma mark Post Button Title + +- (NSString *)postButtonTitle { + return _postButtonTitle; +} + +- (void)setPostButtonTitle:(NSString *)postButtonTitle { + _postButtonTitle = postButtonTitle; +} + +#pragma mark Relative Timing + +- (BOOL)shouldUseRelativeTimeFormatting { + return _shouldUseRelativeTimeFormatting; +} + +- (void)setShouldUseRelativeTimeFormatting:(BOOL)shouldUseRelativeTimeFormatting { + _shouldUseRelativeTimeFormatting = shouldUseRelativeTimeFormatting; +} + + +@end diff --git a/EBPhotoPagesController/EBCaptionView.m b/EBPhotoPagesController/EBCaptionView.m index 1f27f0c..b7e6ad6 100644 --- a/EBPhotoPagesController/EBCaptionView.m +++ b/EBPhotoPagesController/EBCaptionView.m @@ -11,6 +11,7 @@ #import "EBCaptionView.h" +#import "EBConfig.h" #import const NSInteger MaximumNumberOfCaptionLines = 1000000; @@ -304,9 +305,15 @@ - (UILabel *)newCaptionLabel [label setNumberOfLines:MaximumNumberOfCaptionLines]; [label setBackgroundColor:[UIColor clearColor]]; [label setTextColor:[UIColor whiteColor]]; - [label setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:15]]; + + if ([[EBConfig sharedConfig] bodyFont] != nil) { + [label setFont:[[EBConfig sharedConfig] bodyFont]]; + } else { + [label setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:15]]; + } + [label setShadowColor:[UIColor colorWithWhite:0 alpha:0.5]]; [label setShadowOffset:CGSizeMake(0, 1)]; return label; } -@end \ No newline at end of file +@end diff --git a/EBPhotoPagesController/EBCommentCell.m b/EBPhotoPagesController/EBCommentCell.m index 18ca3cb..d1138cf 100644 --- a/EBPhotoPagesController/EBCommentCell.m +++ b/EBPhotoPagesController/EBCommentCell.m @@ -10,8 +10,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - +#import "EBConfig.h" #import "EBCommentCell.h" +#import "NSDate+TimeAgo.h" @implementation EBCommentCell @@ -81,7 +82,12 @@ - (void)loadAuthorNameButton { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - [button.titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + if ([[EBConfig sharedConfig] commentTitleFont] != nil) { + [button.titleLabel setFont:[[EBConfig sharedConfig] commentTitleFont]]; + } else { + [button.titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + } + [button.titleLabel setTextColor:[UIColor colorWithWhite:0.8 alpha:1]]; [button.titleLabel setShadowColor:[UIColor colorWithWhite:0 alpha:0.5]]; [button.titleLabel setShadowOffset:CGSizeMake(0, 1)]; @@ -102,7 +108,13 @@ - (void)loadCommentTextLabel UILabel *textLabel = [UILabel new]; [textLabel setBackgroundColor:[UIColor redColor]]; [textLabel setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; - [textLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16]]; + + if ([[EBConfig sharedConfig] bodyFont] != nil) { + [textLabel setFont:[[EBConfig sharedConfig] bodyFont]]; + } else { + [textLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16]]; + } + [textLabel setTextColor:[UIColor whiteColor]]; [textLabel setShadowColor:[UIColor colorWithWhite:0 alpha:0.5]]; [textLabel setShadowOffset:CGSizeMake(0, 1)]; @@ -120,7 +132,13 @@ - (void)loadDateLabel UILabel *dateLabel = [UILabel new]; [dateLabel setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin]; - [dateLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + + if ([[EBConfig sharedConfig] commentTitleFont] != nil) { + [dateLabel setFont:[[EBConfig sharedConfig] commentTitleFont]]; + } else { + [dateLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Medium" size:12]]; + } + [dateLabel setTextColor:[UIColor colorWithWhite:0.8 alpha:1]]; [dateLabel setShadowColor:[UIColor colorWithWhite:0 alpha:0.5]]; [dateLabel setShadowOffset:CGSizeMake(0, 1)]; @@ -192,9 +210,19 @@ - (void)setComment:(id)comment if([comment respondsToSelector:@selector(postDate)]){ NSDate *postDate = [comment postDate]; - NSDateFormatter *dateFormatter = [self dateFormatter]; - NSString *dateString = [dateFormatter stringFromDate:postDate]; - [self.dateLabel setText:dateString]; + + if ([[EBConfig sharedConfig] dateFormatter] != nil) { + NSString *dateString = [[[EBConfig sharedConfig] dateFormatter] stringFromDate:postDate]; + [self.dateLabel setText:dateString]; + } else { + NSDateFormatter *dateFormatter = [self dateFormatter]; + NSString *dateString = [dateFormatter stringFromDate:postDate]; + [self.dateLabel setText:dateString]; + } + + if ([[EBConfig sharedConfig] shouldUseRelativeTimeFormatting] == YES) { + [self.dateLabel setText:[postDate relativeDateString]]; + } } } diff --git a/EBPhotoPagesController/EBCommentsView.m b/EBPhotoPagesController/EBCommentsView.m index 5b89dcb..c239cd2 100644 --- a/EBPhotoPagesController/EBCommentsView.m +++ b/EBPhotoPagesController/EBCommentsView.m @@ -14,6 +14,7 @@ #import "EBCommentsView.h" #import #import "EBCommentsTableView.h" +#import "EBConfig.h" @interface EBCommentsView () @property (weak, readwrite) EBCommentsTableView *tableView; @@ -141,8 +142,15 @@ - (void)loadPostButton buttonSize.height); UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setFrame:buttonFrame]; - [button setTitle:NSLocalizedString(@"post", @"Appears on a button that posts a comment when tapped.") - forState:UIControlStateNormal]; + + if ([[EBConfig sharedConfig] postButtonTitle] != nil) { + [button setTitle:[[EBConfig sharedConfig] postButtonTitle] + forState:UIControlStateNormal]; + } else { + [button setTitle:NSLocalizedString(@"Post", @"Appears on a button that posts a comment when tapped.") + forState:UIControlStateNormal]; + } + [button addTarget:self action:@selector(didSelectPostButton:) forControlEvents:UIControlEventTouchUpInside]; @@ -250,6 +258,10 @@ - (void)cancelCommenting - (UIColor *)postButtonColor { + if ([[EBConfig sharedConfig] tintColor] != nil) { + return [[EBConfig sharedConfig] tintColor]; + } + return [UIColor colorWithRed:0 green:118/255.0 blue:1.0 alpha:1.0]; } diff --git a/EBPhotoPagesController/EBPhotoPagesFactory.m b/EBPhotoPagesController/EBPhotoPagesFactory.m index 1295954..e466be9 100644 --- a/EBPhotoPagesController/EBPhotoPagesFactory.m +++ b/EBPhotoPagesController/EBPhotoPagesFactory.m @@ -22,6 +22,7 @@ #import "EBCommentsView.h" #import "EBCommentsTableView.h" #import "EBCommentCell.h" +#import "EBConfig.h" #include //static inline double radians (double degrees) {return degrees * M_PI/180;} @@ -1056,26 +1057,47 @@ - (UIImage *)iconForCommentsBarButtonItemForPhotoPagesController:(EBPhotoPagesCo - (NSString *)photoPagesDefaultFontName { + if ([[EBConfig sharedConfig] bodyFont] != nil) { + return [[EBConfig sharedConfig] bodyFont].fontName; + } + return @"HelveticaNeue-Light"; } - (NSString *)photoPagesBoldFontName { + if ([[EBConfig sharedConfig] titleFont] != nil) { + return [[EBConfig sharedConfig] titleFont].fontName; + } + return @"HelveticaNeue-Bold"; } - (UIColor *)upperToolbarTintColor { + if ([[EBConfig sharedConfig] tintColor] != nil) { + return [[EBConfig sharedConfig] tintColor]; + } + return [self photoPagesTintColor]; } - (UIColor *)lowerToolbarTintColor { + + if ([[EBConfig sharedConfig] tintColor] != nil) { + return [[EBConfig sharedConfig] tintColor]; + } + return [self photoPagesTintColor]; } - (UIColor *)commentCellTintColor { + if ([[EBConfig sharedConfig] tintColor] != nil) { + return [[[EBConfig sharedConfig] tintColor] colorWithAlphaComponent:0.35]; + } + UIColor *photoPagesColor = [self photoPagesTintColor]; return [photoPagesColor colorWithAlphaComponent:0.35]; } diff --git a/EBPhotoPagesController/EBTagPopover.m b/EBPhotoPagesController/EBTagPopover.m index e9b3562..7762713 100644 --- a/EBPhotoPagesController/EBTagPopover.m +++ b/EBPhotoPagesController/EBTagPopover.m @@ -9,7 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - +#import "EBConfig.h" #import "EBTagPopover.h" #import "EBPhotoPagesController.h" #import "EBPhotoPagesNotifications.h" @@ -115,6 +115,7 @@ - (UIView *)newContentView { NSString *placeholderText = NSLocalizedString(@"New Tag", @"Appears as placeholder text before a user enters text for a photo tag."); + UIFont *textFieldFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:12]; CGSize tagSize = [placeholderText sizeWithAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Bold" size:12]}]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, tagSize.width, tagSize.height)]; diff --git a/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj b/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj index 0ef0e62..72e4099 100644 --- a/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj +++ b/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj @@ -86,6 +86,8 @@ 8583A59118022E1400D694A5 /* EBTagPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = 8583A58318022E1400D694A5 /* EBTagPopover.m */; }; 8583A59818022FE500D694A5 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8583A59718022FE500D694A5 /* AVFoundation.framework */; }; 8583A59A18022FF400D694A5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8583A59918022FF400D694A5 /* QuartzCore.framework */; }; + 956FF9B11F3E0F1B007F7712 /* EBConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 956FF9B01F3E0F1B007F7712 /* EBConfig.m */; }; + 956FF9B41F3E171C007F7712 /* NSDate+TimeAgo.m in Sources */ = {isa = PBXBuildFile; fileRef = 956FF9B31F3E171C007F7712 /* NSDate+TimeAgo.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -214,6 +216,10 @@ 8583A59718022FE500D694A5 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 8583A59918022FF400D694A5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 8583A5A11802322900D694A5 /* EBPhotoPagesNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EBPhotoPagesNotifications.h; path = EBPhotoPagesController/EBPhotoPagesNotifications.h; sourceTree = ""; }; + 956FF9AF1F3E0F1B007F7712 /* EBConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EBConfig.h; sourceTree = ""; }; + 956FF9B01F3E0F1B007F7712 /* EBConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EBConfig.m; sourceTree = ""; }; + 956FF9B21F3E171C007F7712 /* NSDate+TimeAgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+TimeAgo.h"; sourceTree = ""; }; + 956FF9B31F3E171C007F7712 /* NSDate+TimeAgo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TimeAgo.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -419,6 +425,7 @@ 8583A59E180230F500D694A5 /* Photos */, 8583A59D180230D500D694A5 /* Caption */, 8583A59C180230C300D694A5 /* Tags */, + 956FF9AE1F3E0EEC007F7712 /* Config */, 8583A59B180230AF00D694A5 /* Comments */, ); name = EBPhotoPagesController; @@ -493,10 +500,21 @@ 8583A58018022E1400D694A5 /* EBShadedView.h */, 8583A58118022E1400D694A5 /* EBShadedView.m */, 8583A5A11802322900D694A5 /* EBPhotoPagesNotifications.h */, + 956FF9B21F3E171C007F7712 /* NSDate+TimeAgo.h */, + 956FF9B31F3E171C007F7712 /* NSDate+TimeAgo.m */, ); name = Helpers; sourceTree = ""; }; + 956FF9AE1F3E0EEC007F7712 /* Config */ = { + isa = PBXGroup; + children = ( + 956FF9AF1F3E0F1B007F7712 /* EBConfig.h */, + 956FF9B01F3E0F1B007F7712 /* EBConfig.m */, + ); + name = Config; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -641,6 +659,7 @@ 8583A58D18022E1400D694A5 /* EBPhotoToolbar.m in Sources */, 8583A54318022D3800D694A5 /* DEMOPhoto.m in Sources */, 8583A58C18022E1400D694A5 /* EBPhotoPagesState.m in Sources */, + 956FF9B11F3E0F1B007F7712 /* EBConfig.m in Sources */, 8583A58E18022E1400D694A5 /* EBPhotoView.m in Sources */, 8583A54518022D3800D694A5 /* DEMOComment.m in Sources */, 8583A58518022E1400D694A5 /* EBCaptionView.m in Sources */, @@ -648,6 +667,7 @@ 8583A58618022E1400D694A5 /* EBCommentCell.m in Sources */, 8583A58718022E1400D694A5 /* EBCommentsTableView.m in Sources */, 8583A58B18022E1400D694A5 /* EBPhotoPagesOperation.m in Sources */, + 956FF9B41F3E171C007F7712 /* NSDate+TimeAgo.m in Sources */, 8583A54418022D3800D694A5 /* DEMOTag.m in Sources */, 8583A58918022E1400D694A5 /* EBPhotoPagesController.m in Sources */, 8583A54218022D3800D694A5 /* DEMOViewController.m in Sources */, diff --git a/EBPhotoPagesControllerDemo/DEMOComment.m b/EBPhotoPagesControllerDemo/DEMOComment.m index b4ec834..fbbc385 100644 --- a/EBPhotoPagesControllerDemo/DEMOComment.m +++ b/EBPhotoPagesControllerDemo/DEMOComment.m @@ -63,5 +63,9 @@ - (UIImage *)authorAvatar { return self.image; } + +- (NSURL *)authorAvatarURL { + return nil; +} @end diff --git a/EBPhotoPagesControllerDemo/DEMOViewController.m b/EBPhotoPagesControllerDemo/DEMOViewController.m index a638f61..fcbe808 100644 --- a/EBPhotoPagesControllerDemo/DEMOViewController.m +++ b/EBPhotoPagesControllerDemo/DEMOViewController.m @@ -21,6 +21,7 @@ #import "EBPhotoPagesController.h" #import "EBPhotoPagesFactory.h" #import "EBTagPopover.h" +#import "EBConfig.h" @interface DEMOViewController () @@ -332,6 +333,8 @@ - (void)loadView [photo setDisabledDeleteForTags:YES]; [photo setDisabledActivities:YES]; + [self customize]; + } - (void)viewDidLoad @@ -356,6 +359,11 @@ - (void)didReceiveMemoryWarning [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } + +- (void) customize { + [[EBConfig sharedConfig] setBodyFont: [UIFont fontWithName:@"Avenir-Book" size:17]]; + [[EBConfig sharedConfig] setShouldUseRelativeTimeFormatting:YES]; +} - (IBAction)didSelectViewPhotos:(id)sender { diff --git a/NSDate+TimeAgo.h b/NSDate+TimeAgo.h new file mode 100644 index 0000000..e40ed2b --- /dev/null +++ b/NSDate+TimeAgo.h @@ -0,0 +1,15 @@ +// +// NSDate+TimeAgo.h +// EBPhotoPagesControllerDemo +// +// Created by Jesse Onolememen on 11/08/2017. +// Copyright © 2017 Eddy Borja. All rights reserved. +// + +#import + +@interface NSDate (TimeAgo) + +- (NSString *)relativeDateString; + +@end diff --git a/NSDate+TimeAgo.m b/NSDate+TimeAgo.m new file mode 100644 index 0000000..964bca0 --- /dev/null +++ b/NSDate+TimeAgo.m @@ -0,0 +1,67 @@ +// +// NSDate+TimeAgo.m +// EBPhotoPagesControllerDemo +// +// Created by Jesse Onolememen on 11/08/2017. +// Copyright © 2017 Eddy Borja. All rights reserved. +// + +#import "NSDate+TimeAgo.h" + +@implementation NSDate (TimeAgo) + + + - (NSString *)relativeDateString + { + const int SECOND = 1; + const int MINUTE = 60 * SECOND; + const int HOUR = 60 * MINUTE; + const int DAY = 24 * HOUR; + const int MONTH = 30 * DAY; + + NSDate *now = [NSDate date]; + NSTimeInterval delta = [self timeIntervalSinceDate:now] * -1.0; + + NSCalendar *calendar = [NSCalendar currentCalendar]; + NSCalendarUnit unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; +// NSDateComponents *components = [calendar components:units fromDate:self toDate:now options:0]; + NSDateComponents *components = [calendar components:unitFlags fromDate:self toDate:now options:0]; + NSString *relativeString; + + if (delta < 0) { + relativeString = @"!n the future!"; + + } else if (delta < 1 * MINUTE) { + relativeString = (components.second == 1) ? @"One second ago" : [NSString stringWithFormat:@"%ld seconds ago",(long)components.second]; + + } else if (delta < 2 * MINUTE) { + relativeString = @"a minute ago"; + + } else if (delta < 45 * MINUTE) { + relativeString = [NSString stringWithFormat:@"%ld minutes ago",(long)components.minute]; + + } else if (delta < 90 * MINUTE) { + relativeString = @"an hour ago"; + + } else if (delta < 24 * HOUR) { + relativeString = [NSString stringWithFormat:@"%ld hours ago",(long)components.hour]; + + } else if (delta < 48 * HOUR) { + relativeString = @"yesterday"; + + } else if (delta < 30 * DAY) { + relativeString = [NSString stringWithFormat:@"%ld days ago",(long)components.day]; + + } else if (delta < 12 * MONTH) { + relativeString = (components.month <= 1) ? @"one month ago" : [NSString stringWithFormat:@"%ld months ago",(long)components.month]; + + } else { + relativeString = (components.year <= 1) ? @"one year ago" : [NSString stringWithFormat:@"%ld years ago",(long)components.year]; + + } + + return relativeString; + } + + + @end From fa28f17173f855a6e0c804bdadee7347abb8a779 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 18:19:24 +0100 Subject: [PATCH 4/9] Refactored structure to add changes in the correct directory --- .../EBConfig.h | 0 .../EBConfig.m | 0 .../NSDate+TimeAgo.h | 0 .../NSDate+TimeAgo.m | 0 .../project.pbxproj | 24 +++++++++---------- 5 files changed, 12 insertions(+), 12 deletions(-) rename EBConfig.h => EBPhotoPagesController/EBConfig.h (100%) rename EBConfig.m => EBPhotoPagesController/EBConfig.m (100%) rename NSDate+TimeAgo.h => EBPhotoPagesController/NSDate+TimeAgo.h (100%) rename NSDate+TimeAgo.m => EBPhotoPagesController/NSDate+TimeAgo.m (100%) diff --git a/EBConfig.h b/EBPhotoPagesController/EBConfig.h similarity index 100% rename from EBConfig.h rename to EBPhotoPagesController/EBConfig.h diff --git a/EBConfig.m b/EBPhotoPagesController/EBConfig.m similarity index 100% rename from EBConfig.m rename to EBPhotoPagesController/EBConfig.m diff --git a/NSDate+TimeAgo.h b/EBPhotoPagesController/NSDate+TimeAgo.h similarity index 100% rename from NSDate+TimeAgo.h rename to EBPhotoPagesController/NSDate+TimeAgo.h diff --git a/NSDate+TimeAgo.m b/EBPhotoPagesController/NSDate+TimeAgo.m similarity index 100% rename from NSDate+TimeAgo.m rename to EBPhotoPagesController/NSDate+TimeAgo.m diff --git a/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj b/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj index 72e4099..8adc383 100644 --- a/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj +++ b/EBPhotoPagesControllerDemo.xcodeproj/project.pbxproj @@ -86,8 +86,8 @@ 8583A59118022E1400D694A5 /* EBTagPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = 8583A58318022E1400D694A5 /* EBTagPopover.m */; }; 8583A59818022FE500D694A5 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8583A59718022FE500D694A5 /* AVFoundation.framework */; }; 8583A59A18022FF400D694A5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8583A59918022FF400D694A5 /* QuartzCore.framework */; }; - 956FF9B11F3E0F1B007F7712 /* EBConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 956FF9B01F3E0F1B007F7712 /* EBConfig.m */; }; - 956FF9B41F3E171C007F7712 /* NSDate+TimeAgo.m in Sources */ = {isa = PBXBuildFile; fileRef = 956FF9B31F3E171C007F7712 /* NSDate+TimeAgo.m */; }; + 956FF9B71F3E1E5B007F7712 /* NSDate+TimeAgo.m in Sources */ = {isa = PBXBuildFile; fileRef = 956FF9B61F3E1E5B007F7712 /* NSDate+TimeAgo.m */; }; + 956FF9BA1F3E1E64007F7712 /* EBConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 956FF9B91F3E1E64007F7712 /* EBConfig.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -216,10 +216,10 @@ 8583A59718022FE500D694A5 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 8583A59918022FF400D694A5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 8583A5A11802322900D694A5 /* EBPhotoPagesNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EBPhotoPagesNotifications.h; path = EBPhotoPagesController/EBPhotoPagesNotifications.h; sourceTree = ""; }; - 956FF9AF1F3E0F1B007F7712 /* EBConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EBConfig.h; sourceTree = ""; }; - 956FF9B01F3E0F1B007F7712 /* EBConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EBConfig.m; sourceTree = ""; }; - 956FF9B21F3E171C007F7712 /* NSDate+TimeAgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+TimeAgo.h"; sourceTree = ""; }; - 956FF9B31F3E171C007F7712 /* NSDate+TimeAgo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TimeAgo.m"; sourceTree = ""; }; + 956FF9B51F3E1E5B007F7712 /* NSDate+TimeAgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDate+TimeAgo.h"; path = "EBPhotoPagesController/NSDate+TimeAgo.h"; sourceTree = ""; }; + 956FF9B61F3E1E5B007F7712 /* NSDate+TimeAgo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDate+TimeAgo.m"; path = "EBPhotoPagesController/NSDate+TimeAgo.m"; sourceTree = ""; }; + 956FF9B81F3E1E64007F7712 /* EBConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EBConfig.h; path = EBPhotoPagesController/EBConfig.h; sourceTree = ""; }; + 956FF9B91F3E1E64007F7712 /* EBConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EBConfig.m; path = EBPhotoPagesController/EBConfig.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -500,8 +500,8 @@ 8583A58018022E1400D694A5 /* EBShadedView.h */, 8583A58118022E1400D694A5 /* EBShadedView.m */, 8583A5A11802322900D694A5 /* EBPhotoPagesNotifications.h */, - 956FF9B21F3E171C007F7712 /* NSDate+TimeAgo.h */, - 956FF9B31F3E171C007F7712 /* NSDate+TimeAgo.m */, + 956FF9B51F3E1E5B007F7712 /* NSDate+TimeAgo.h */, + 956FF9B61F3E1E5B007F7712 /* NSDate+TimeAgo.m */, ); name = Helpers; sourceTree = ""; @@ -509,8 +509,8 @@ 956FF9AE1F3E0EEC007F7712 /* Config */ = { isa = PBXGroup; children = ( - 956FF9AF1F3E0F1B007F7712 /* EBConfig.h */, - 956FF9B01F3E0F1B007F7712 /* EBConfig.m */, + 956FF9B81F3E1E64007F7712 /* EBConfig.h */, + 956FF9B91F3E1E64007F7712 /* EBConfig.m */, ); name = Config; sourceTree = ""; @@ -659,7 +659,6 @@ 8583A58D18022E1400D694A5 /* EBPhotoToolbar.m in Sources */, 8583A54318022D3800D694A5 /* DEMOPhoto.m in Sources */, 8583A58C18022E1400D694A5 /* EBPhotoPagesState.m in Sources */, - 956FF9B11F3E0F1B007F7712 /* EBConfig.m in Sources */, 8583A58E18022E1400D694A5 /* EBPhotoView.m in Sources */, 8583A54518022D3800D694A5 /* DEMOComment.m in Sources */, 8583A58518022E1400D694A5 /* EBCaptionView.m in Sources */, @@ -667,11 +666,12 @@ 8583A58618022E1400D694A5 /* EBCommentCell.m in Sources */, 8583A58718022E1400D694A5 /* EBCommentsTableView.m in Sources */, 8583A58B18022E1400D694A5 /* EBPhotoPagesOperation.m in Sources */, - 956FF9B41F3E171C007F7712 /* NSDate+TimeAgo.m in Sources */, 8583A54418022D3800D694A5 /* DEMOTag.m in Sources */, 8583A58918022E1400D694A5 /* EBPhotoPagesController.m in Sources */, + 956FF9B71F3E1E5B007F7712 /* NSDate+TimeAgo.m in Sources */, 8583A54218022D3800D694A5 /* DEMOViewController.m in Sources */, 8583A58A18022E1400D694A5 /* EBPhotoPagesFactory.m in Sources */, + 956FF9BA1F3E1E64007F7712 /* EBConfig.m in Sources */, 8583A54118022D3800D694A5 /* DEMOAppDelegate.m in Sources */, 8583A58818022E1400D694A5 /* EBCommentsView.m in Sources */, ); From d70394c9a2d36f4add475aa56bce28c058ab4d8a Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 20:12:56 +0100 Subject: [PATCH 5/9] Removed read only function from the bar button items to allow customizing them --- EBPhotoPagesController/EBConfig.h | 5 +++++ .../EBPhotoPagesController.h | 20 +++++++++---------- .../EBPhotoPagesController.m | 11 ---------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/EBPhotoPagesController/EBConfig.h b/EBPhotoPagesController/EBConfig.h index 28dd7ee..7fe6832 100644 --- a/EBPhotoPagesController/EBConfig.h +++ b/EBPhotoPagesController/EBConfig.h @@ -16,8 +16,13 @@ @property (nonatomic, retain) UIColor* textColor; @property (nonatomic, retain) UIColor* tintColor; + +@property (nonatomic, retain) UIBarButtonItem* doneBarButtonItem; + @property (nonatomic, retain) NSString* postButtonTitle; + @property (nonatomic, retain) NSDateFormatter* dateFormatter; + @property BOOL shouldUseRelativeTimeFormatting; /// This is the font used for the captions and comments diff --git a/EBPhotoPagesController/EBPhotoPagesController.h b/EBPhotoPagesController/EBPhotoPagesController.h index fb8b637..b98d29c 100644 --- a/EBPhotoPagesController/EBPhotoPagesController.h +++ b/EBPhotoPagesController/EBPhotoPagesController.h @@ -27,16 +27,16 @@ @property (strong) id photosDataSource; @property (strong) EBPhotoPagesFactory *photoPagesFactory; -@property (nonatomic, readonly) UIBarButtonItem *doneBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *cancelBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *tagBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *doneTaggingBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *activityBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *miscBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *commentsBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *commentsExitBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *hideCommentsBarButtonItem; -@property (nonatomic, readonly) UIBarButtonItem *toggleTagsBarButtonItem; +@property (nonatomic) UIBarButtonItem *doneBarButtonItem; +@property (nonatomic) UIBarButtonItem *cancelBarButtonItem; +@property (nonatomic) UIBarButtonItem *tagBarButtonItem; +@property (nonatomic) UIBarButtonItem *doneTaggingBarButtonItem; +@property (nonatomic) UIBarButtonItem *activityBarButtonItem; +@property (nonatomic) UIBarButtonItem *miscBarButtonItem; +@property (nonatomic) UIBarButtonItem *commentsBarButtonItem; +@property (nonatomic) UIBarButtonItem *commentsExitBarButtonItem; +@property (nonatomic) UIBarButtonItem *hideCommentsBarButtonItem; +@property (nonatomic) UIBarButtonItem *toggleTagsBarButtonItem; //Set to NO to prevent tags from showing on photos diff --git a/EBPhotoPagesController/EBPhotoPagesController.m b/EBPhotoPagesController/EBPhotoPagesController.m index e627234..2a95978 100644 --- a/EBPhotoPagesController/EBPhotoPagesController.m +++ b/EBPhotoPagesController/EBPhotoPagesController.m @@ -35,17 +35,6 @@ @interface EBPhotoPagesController () @property (strong) NSDictionary *actionSheetTargetInfo; //info about the object the action sheet is currently handling @property (assign) BOOL originalStatusBarVisibility; -@property (nonatomic, strong) UIBarButtonItem *doneBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *cancelBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *tagBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *doneTaggingBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *activityBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *commentsBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *miscBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *commentsExitBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *hideCommentsBarButtonItem; -@property (nonatomic, strong) UIBarButtonItem *toggleTagsBarButtonItem; - @property (weak) UIToolbar *upperToolbar; @property (weak) UIToolbar *lowerToolbar; @property (weak) UIView *screenDimmer; From 927e2f321a14bd2c31860614470289ff3527a081 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 20:57:28 +0100 Subject: [PATCH 6/9] Updated EBConfig --- .../EBPhotoPagesController.h | 20 +++++------ .../EBPhotoPagesController.m | 11 ++++++ EBPhotoPagesController/EBPhotoPagesFactory.m | 36 +++++++++++++++++++ 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/EBPhotoPagesController/EBPhotoPagesController.h b/EBPhotoPagesController/EBPhotoPagesController.h index b98d29c..fb8b637 100644 --- a/EBPhotoPagesController/EBPhotoPagesController.h +++ b/EBPhotoPagesController/EBPhotoPagesController.h @@ -27,16 +27,16 @@ @property (strong) id photosDataSource; @property (strong) EBPhotoPagesFactory *photoPagesFactory; -@property (nonatomic) UIBarButtonItem *doneBarButtonItem; -@property (nonatomic) UIBarButtonItem *cancelBarButtonItem; -@property (nonatomic) UIBarButtonItem *tagBarButtonItem; -@property (nonatomic) UIBarButtonItem *doneTaggingBarButtonItem; -@property (nonatomic) UIBarButtonItem *activityBarButtonItem; -@property (nonatomic) UIBarButtonItem *miscBarButtonItem; -@property (nonatomic) UIBarButtonItem *commentsBarButtonItem; -@property (nonatomic) UIBarButtonItem *commentsExitBarButtonItem; -@property (nonatomic) UIBarButtonItem *hideCommentsBarButtonItem; -@property (nonatomic) UIBarButtonItem *toggleTagsBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *doneBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *cancelBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *tagBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *doneTaggingBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *activityBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *miscBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *commentsBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *commentsExitBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *hideCommentsBarButtonItem; +@property (nonatomic, readonly) UIBarButtonItem *toggleTagsBarButtonItem; //Set to NO to prevent tags from showing on photos diff --git a/EBPhotoPagesController/EBPhotoPagesController.m b/EBPhotoPagesController/EBPhotoPagesController.m index 2a95978..15abeee 100644 --- a/EBPhotoPagesController/EBPhotoPagesController.m +++ b/EBPhotoPagesController/EBPhotoPagesController.m @@ -47,6 +47,17 @@ @interface EBPhotoPagesController () @property (assign) NSInteger currentPhotoIndex; +@property (nonatomic) UIBarButtonItem *doneBarButtonItem; +@property (nonatomic) UIBarButtonItem *cancelBarButtonItem; +@property (nonatomic) UIBarButtonItem *tagBarButtonItem; +@property (nonatomic) UIBarButtonItem *doneTaggingBarButtonItem; +@property (nonatomic) UIBarButtonItem *activityBarButtonItem; +@property (nonatomic) UIBarButtonItem *miscBarButtonItem; +@property (nonatomic) UIBarButtonItem *commentsBarButtonItem; +@property (nonatomic) UIBarButtonItem *commentsExitBarButtonItem; +@property (nonatomic) UIBarButtonItem *hideCommentsBarButtonItem; +@property (nonatomic) UIBarButtonItem *toggleTagsBarButtonItem; + @end #pragma mark - diff --git a/EBPhotoPagesController/EBPhotoPagesFactory.m b/EBPhotoPagesController/EBPhotoPagesFactory.m index e466be9..c3da0eb 100644 --- a/EBPhotoPagesController/EBPhotoPagesFactory.m +++ b/EBPhotoPagesController/EBPhotoPagesFactory.m @@ -318,6 +318,15 @@ - (UIBarButtonItem *)doneBarButtonItemForPhotoPagesController:(EBPhotoPagesContr style:UIBarButtonItemStyleDone target:controller selector:@selector(didSelectDoneButton:)]; + + if ([[EBConfig sharedConfig] titleFont] != nil) { + [doneButton setTitleTextAttributes: + @{ + NSFontAttributeName: [[EBConfig sharedConfig] titleFont], + NSForegroundColorAttributeName: [[EBConfig sharedConfig] textColor] != nil ? [[EBConfig sharedConfig] textColor] : [UIColor whiteColor] + } forState:UIControlStateNormal]; + } + return doneButton; } @@ -328,6 +337,15 @@ - (UIBarButtonItem *)cancelBarButtonItemForPhotoPagesController:(EBPhotoPagesCon style:UIBarButtonItemStyleDone target:controller selector:@selector(didSelectCancelButton:)]; + + if ([[EBConfig sharedConfig] titleFont] != nil) { + [cancelButton setTitleTextAttributes: + @{ + NSFontAttributeName: [[EBConfig sharedConfig] titleFont], + NSForegroundColorAttributeName: [[EBConfig sharedConfig] textColor] != nil ? [[EBConfig sharedConfig] textColor] : [UIColor whiteColor] + } forState:UIControlStateNormal]; + } + return cancelButton; } @@ -338,6 +356,15 @@ - (UIBarButtonItem *)tagBarButtonItemForPhotoPagesController:(EBPhotoPagesContro style:UIBarButtonItemStylePlain target:controller selector:@selector(didSelectTagButton:)]; + + if ([[EBConfig sharedConfig] titleFont] != nil) { + [tagButton setTitleTextAttributes: + @{ + NSFontAttributeName: [[EBConfig sharedConfig] titleFont], + NSForegroundColorAttributeName: [[EBConfig sharedConfig] textColor] != nil ? [[EBConfig sharedConfig] textColor] : [UIColor whiteColor] + } forState:UIControlStateNormal]; + } + return tagButton; } @@ -348,6 +375,15 @@ - (UIBarButtonItem *)doneTaggingBarButtonItemForPhotoPagesController:(EBPhotoPag style:UIBarButtonItemStyleDone target:controller selector:@selector(didSelectTagDoneButton:)]; + + if ([[EBConfig sharedConfig] titleFont] != nil) { + [doneTaggingButton setTitleTextAttributes: + @{ + NSFontAttributeName: [[EBConfig sharedConfig] titleFont], + NSForegroundColorAttributeName: [[EBConfig sharedConfig] textColor] != nil ? [[EBConfig sharedConfig] textColor] : [UIColor whiteColor] + } forState:UIControlStateNormal]; + } + return doneTaggingButton; } From b2156610920628d5b75d4194e7a9f2bf1ef183d1 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Fri, 11 Aug 2017 21:06:16 +0100 Subject: [PATCH 7/9] Latest --- EBPhotoPagesController/EBPhotoPagesFactory.m | 8 -------- 1 file changed, 8 deletions(-) diff --git a/EBPhotoPagesController/EBPhotoPagesFactory.m b/EBPhotoPagesController/EBPhotoPagesFactory.m index c3da0eb..6295985 100644 --- a/EBPhotoPagesController/EBPhotoPagesFactory.m +++ b/EBPhotoPagesController/EBPhotoPagesFactory.m @@ -357,14 +357,6 @@ - (UIBarButtonItem *)tagBarButtonItemForPhotoPagesController:(EBPhotoPagesContro target:controller selector:@selector(didSelectTagButton:)]; - if ([[EBConfig sharedConfig] titleFont] != nil) { - [tagButton setTitleTextAttributes: - @{ - NSFontAttributeName: [[EBConfig sharedConfig] titleFont], - NSForegroundColorAttributeName: [[EBConfig sharedConfig] textColor] != nil ? [[EBConfig sharedConfig] textColor] : [UIColor whiteColor] - } forState:UIControlStateNormal]; - } - return tagButton; } From 58b610e4638c71c7005bcc10336ef5ab260e987b Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Sat, 12 Aug 2017 11:16:19 +0100 Subject: [PATCH 8/9] Updated comment textfield --- EBPhotoPagesController/EBCommentsView.m | 20 ++++++++--- EBPhotoPagesController/EBConfig.h | 35 ++++++++++++++------ EBPhotoPagesController/EBConfig.m | 10 ++++++ EBPhotoPagesController/EBPhotoPagesFactory.m | 9 +++++ 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/EBPhotoPagesController/EBCommentsView.m b/EBPhotoPagesController/EBCommentsView.m index c239cd2..8cf59d7 100644 --- a/EBPhotoPagesController/EBCommentsView.m +++ b/EBPhotoPagesController/EBCommentsView.m @@ -99,7 +99,13 @@ - (void)loadCommentTextView UITextView *textView = [[UITextView alloc] initWithFrame:textViewFrame]; [textView setBackgroundColor:[UIColor clearColor]]; - [textView setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16]]; + + if ([[EBConfig sharedConfig] bodyFont] != nil) { + [textView setFont:[[EBConfig sharedConfig] bodyFont]]; + } else { + [textView setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16]]; + } + [textView setKeyboardAppearance:UIKeyboardAppearanceAlert]; [textView setTextColor:[UIColor whiteColor]]; //[self setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin| UIViewAutoresizingFlexibleWidth]; @@ -113,7 +119,13 @@ - (void)loadPlaceholderForTextView:(UITextView *)textView { UILabel *label = [[UILabel alloc] initWithFrame:textView.frame]; [label setTextAlignment:NSTextAlignmentLeft]; - [label setFont:textView.font]; + + if ([[EBConfig sharedConfig] bodyFont] != nil) { + [textView setFont:[[EBConfig sharedConfig] bodyFont]]; + } else { + [label setFont:textView.font]; + } + [label setBackgroundColor:[UIColor clearColor]]; [label setTextColor:[UIColor colorWithWhite:0.5 alpha:1]]; [textView.superview insertSubview:label belowSubview:textView]; @@ -258,8 +270,8 @@ - (void)cancelCommenting - (UIColor *)postButtonColor { - if ([[EBConfig sharedConfig] tintColor] != nil) { - return [[EBConfig sharedConfig] tintColor]; + if ([[EBConfig sharedConfig] postButtonBackgroundColor] != nil) { + return [[EBConfig sharedConfig] postButtonBackgroundColor]; } return [UIColor colorWithRed:0 green:118/255.0 blue:1.0 alpha:1.0]; diff --git a/EBPhotoPagesController/EBConfig.h b/EBPhotoPagesController/EBConfig.h index 7fe6832..2a4d03e 100644 --- a/EBPhotoPagesController/EBConfig.h +++ b/EBPhotoPagesController/EBConfig.h @@ -10,21 +10,31 @@ @interface EBConfig : NSObject +/// This is the font used for the captions and comments @property (nonatomic, retain) UIFont* bodyFont; + +/// This is the font used for buttons and titles @property (nonatomic, retain) UIFont* titleFont; + +/// This is the font used for the comment titles @property (nonatomic, retain) UIFont* commentTitleFont; - + +/// This is the colour for all of the titles @property (nonatomic, retain) UIColor* textColor; +@property (nonatomic, retain) UIColor* postButtonBackgroundColor; + +/// This is the color used for all of the excluding the post button @property (nonatomic, retain) UIColor* tintColor; - -@property (nonatomic, retain) UIBarButtonItem* doneBarButtonItem; - + +/// This is the title for the post button @property (nonatomic, retain) NSString* postButtonTitle; - + +/// This is the formatter used to format the dates for each comment @property (nonatomic, retain) NSDateFormatter* dateFormatter; - @property BOOL shouldUseRelativeTimeFormatting; + + /// This is the font used for the captions and comments - (UIFont *)bodyFont; @@ -49,10 +59,16 @@ /// Sets the colour for all of the titles - (void)setTextColor: (UIColor *) textColor; -/// This is the color used for all of the buttons +/// This is the background color for the post button +- (UIColor *)postButtonBackgroundColor; + +/// Sets the background color for the post button +- (void)setPostButtonBackgroundColor: (UIColor *) postButtonBackgroundColor; + +/// This is the color used for all of the excluding the post button - (UIColor *)tintColor; -/// Sets the color used for all of the buttons +/// Sets the color used for all of the excluding the post button - (void)setTintColor: (UIColor *) tintColor; /// This is the title for the post button @@ -67,10 +83,7 @@ /// Sets the formatter used to format the dates for each comment - (void)setDateFormatter: (NSDateFormatter *) dateFormatter; -/// This is the formatter used to format the dates for each comment - (BOOL)shouldUseRelativeTimeFormatting; - -/// This is the formatter used to format the dates for each comment - (void)setShouldUseRelativeTimeFormatting: (BOOL) shouldUseRelativeTimeFormatting; /// Global configuration diff --git a/EBPhotoPagesController/EBConfig.m b/EBPhotoPagesController/EBConfig.m index 763ae70..1d9ae1f 100644 --- a/EBPhotoPagesController/EBConfig.m +++ b/EBPhotoPagesController/EBConfig.m @@ -16,6 +16,7 @@ @implementation EBConfig @synthesize textColor = _textColor; @synthesize tintColor = _tintColor; +@synthesize postButtonBackgroundColor = _postButtonBackgroundColor; @synthesize postButtonTitle = _postButtonTitle; @@ -100,6 +101,15 @@ - (NSString *)postButtonTitle { - (void)setPostButtonTitle:(NSString *)postButtonTitle { _postButtonTitle = postButtonTitle; } + +#pragma mark Post Button Background Color +- (UIColor *)postButtonBackgroundColor { + return _postButtonBackgroundColor +} + +- (void)setPostButtonBackgroundColor:(UIColor *)postButtonBackgroundColor { + _postButtonBackgroundColor = postButtonBackgroundColor +} #pragma mark Relative Timing diff --git a/EBPhotoPagesController/EBPhotoPagesFactory.m b/EBPhotoPagesController/EBPhotoPagesFactory.m index 6295985..525a140 100644 --- a/EBPhotoPagesController/EBPhotoPagesFactory.m +++ b/EBPhotoPagesController/EBPhotoPagesFactory.m @@ -273,6 +273,15 @@ - (UIBarButtonItem *)hideCommentsBarButtonItemForPhotoPagesController:(EBPhotoPa style:UIBarButtonItemStyleDone target:controller selector:@selector(didSelectCancelButton:)]; + + if ([[EBConfig sharedConfig] titleFont] != nil) { + [hideCommentsButton setTitleTextAttributes: + @{ + NSFontAttributeName: [[EBConfig sharedConfig] titleFont], + NSForegroundColorAttributeName: [[EBConfig sharedConfig] textColor] != nil ? [[EBConfig sharedConfig] textColor] : [UIColor whiteColor] + } forState:UIControlStateNormal]; + } + return hideCommentsButton; } From 9a53caf990fba47482be8fd28f6e7553de7d0124 Mon Sep 17 00:00:00 2001 From: Jesse Onolememen Date: Sat, 12 Aug 2017 11:23:51 +0100 Subject: [PATCH 9/9] Resolved errors --- EBPhotoPagesController/EBConfig.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EBPhotoPagesController/EBConfig.m b/EBPhotoPagesController/EBConfig.m index 1d9ae1f..f507a61 100644 --- a/EBPhotoPagesController/EBConfig.m +++ b/EBPhotoPagesController/EBConfig.m @@ -104,11 +104,11 @@ - (void)setPostButtonTitle:(NSString *)postButtonTitle { #pragma mark Post Button Background Color - (UIColor *)postButtonBackgroundColor { - return _postButtonBackgroundColor + return _postButtonBackgroundColor; } - (void)setPostButtonBackgroundColor:(UIColor *)postButtonBackgroundColor { - _postButtonBackgroundColor = postButtonBackgroundColor + _postButtonBackgroundColor = postButtonBackgroundColor; } #pragma mark Relative Timing