From 23ea09aa28ebe702baef53b59ac1f6dea072f6e3 Mon Sep 17 00:00:00 2001 From: Paul Jones Date: Thu, 18 Aug 2016 11:45:11 -0400 Subject: [PATCH 1/3] #11 customizable fonts --- .../YMSPhotoPicker/Private/YMSAlbumCell.h | 6 ++++++ .../YMSPhotoPicker/Private/YMSAlbumCell.m | 6 ++++++ .../Private/YMSAlbumPickerViewController.m | 1 + .../YMSPhotoPicker/Private/YMSPhotoCell.h | 6 ++++++ .../YMSPhotoPicker/Private/YMSPhotoCell.m | 5 +++++ .../YMSPhotoPicker/Public/YMSPhotoPickerTheme.h | 17 +++++++++++++++++ .../Public/YMSPhotoPickerViewController.m | 3 ++- 7 files changed, 43 insertions(+), 1 deletion(-) diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h index ff68ad9..aa64582 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h +++ b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h @@ -36,5 +36,11 @@ * */ @property (nonatomic, assign) NSUInteger photosCount; + +/** + * @brief Set the font used by the two labels displaying album name and the album count + * + */ +@property (nonatomic, assign) UIFont* fontForAlbumNameAndCount; @end diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m index 07b8730..dfa3e8e 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m +++ b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m @@ -46,4 +46,10 @@ - (void)setPhotosCount:(NSUInteger)photosCount _photosCount = photosCount; } +- (void)setFontForAlbumNameAndCount:(UIFont *)fontForAlbumNameAndCount +{ + self.photosCountLabel.font = fontForAlbumNameAndCount; + self.albumNameLabel.font = fontForAlbumNameAndCount; +} + @end diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m index c363625..1f67a45 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m +++ b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m @@ -126,6 +126,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N PHCollection *collection = collectionItem[@"collection"]; cell.albumName = collection.localizedTitle; + cell.fontForAlbumNameAndCount = [YMSPhotoPickerTheme sharedInstance].fontForAlbumNameAndCount ?: [UIFont systemFontOfSize:18.0]; cell.photosCount = fetchResult.count; if ([collectionItem isEqual:self.selectedCollectionItem]) { cell.accessoryType = UITableViewCellAccessoryCheckmark; diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h index e143359..8ba98f6 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h +++ b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h @@ -33,6 +33,12 @@ */ @property (nonatomic, assign) NSUInteger selectionOrder; +/** + * @brief Set the font used for the number in the bottom right corner of the cell, specifying which order that photo was picked in + * + */ +@property (nonatomic, assign) UIFont *fontForSelectionOrder; + /** * @brief Load the photo from photo library and display it on cell. * diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m index 39732c9..267c14e 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m +++ b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m @@ -83,6 +83,11 @@ - (void)dealloc [self cancelImageRequest]; } +- (void)setFontForSelectionOrder:(UIFont *)fontForSelectionOrder +{ + self.selectionOrderLabel.font = fontForSelectionOrder; +} + #pragma mark - Publics - (void)loadPhotoWithManager:(PHImageManager *)manager forAsset:(PHAsset *)asset targetSize:(CGSize)size diff --git a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h index 4c81a30..19aa460 100644 --- a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h +++ b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h @@ -27,6 +27,12 @@ */ @property (nonatomic, strong) UIColor *titleLabelTextColor; +/** + * @brief Specify a UIFont that you want to apply on title label text and drop down arrow image in the middle of navigation bar to display current album localized name. + * + */ +@property (nonatomic, strong) UIFont *titleLabelFont; + /** * @brief Describe a specific UIColor that you want to apply on whole picker view controllers' navigation bar. * @@ -63,6 +69,17 @@ */ @property (nonatomic, assign) UIStatusBarStyle statusBarStyle; +/** + * @brief Specify a UIFont that you want to apply to the table view showing album and album count information + * + */ +@property (nonatomic, assign) UIFont *fontForAlbumNameAndCount; + +/** + * @brief Specify a UIFont that you want to apply to the number in the bottom right of photo cells after they're selected, denoting order of selection + */ +@property (nonatomic, assign) UIFont *fontForPhotoSelectionOrder; + /** * @brief Getting a shared instance of YMSPhotoPickerTheme. * diff --git a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m index 4be1942..d86bf89 100644 --- a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m +++ b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m @@ -203,6 +203,7 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtInde YMSPhotoCell *photoCell = (YMSPhotoCell *)cell; [photoCell setNeedsAnimateSelection]; photoCell.selectionOrder = self.selectedPhotos.count+1; + photoCell.fontForSelectionOrder = self.theme.fontForPhotoSelectionOrder; } return YES; } @@ -419,7 +420,7 @@ - (void)updateViewWithCollectionItem:(NSDictionary *)collectionItem UIButton *albumButton = [UIButton buttonWithType:UIButtonTypeSystem]; albumButton.tintColor = self.theme.titleLabelTextColor; - albumButton.titleLabel.font = [UIFont systemFontOfSize:18.0]; + albumButton.titleLabel.font = self.theme.titleLabelFont ?: [UIFont systemFontOfSize:18.0]; [albumButton addTarget:self action:@selector(presentAlbumPickerView:) forControlEvents:UIControlEventTouchUpInside]; [albumButton setTitle:photoCollection.localizedTitle forState:UIControlStateNormal]; UIImage *arrowDownImage = [UIImage imageNamed:@"YMSIconSpinnerDropdwon" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil]; From 191e03e619098dd24ab5fb2d6020e34fd41a4492 Mon Sep 17 00:00:00 2001 From: Howard Huang Date: Fri, 19 Aug 2016 18:12:18 +0800 Subject: [PATCH 2/3] Trim a little for fitting code convention --- .../YMSPhotoPicker/Private/YMSAlbumCell.h | 6 ----- .../YMSPhotoPicker/Private/YMSAlbumCell.m | 15 ++++++----- .../Private/YMSAlbumPickerViewController.m | 1 - .../YMSPhotoPicker/Private/YMSPhotoCell.h | 6 ----- .../YMSPhotoPicker/Private/YMSPhotoCell.m | 6 +---- .../Public/YMSPhotoPickerTheme.h | 26 ++++++++++++------- .../Public/YMSPhotoPickerTheme.m | 4 +++ .../Public/YMSPhotoPickerViewController.m | 1 - 8 files changed, 30 insertions(+), 35 deletions(-) diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h index aa64582..ff68ad9 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h +++ b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.h @@ -36,11 +36,5 @@ * */ @property (nonatomic, assign) NSUInteger photosCount; - -/** - * @brief Set the font used by the two labels displaying album name and the album count - * - */ -@property (nonatomic, assign) UIFont* fontForAlbumNameAndCount; @end diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m index dfa3e8e..de2e463 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m +++ b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumCell.m @@ -7,6 +7,7 @@ // #import "YMSAlbumCell.h" +#import "YMSPhotoPickerTheme.h" @interface YMSAlbumCell() @@ -18,6 +19,14 @@ @interface YMSAlbumCell() @implementation YMSAlbumCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + + self.photosCountLabel.font = [YMSPhotoPickerTheme sharedInstance].photosCountLabelFont; + self.albumNameLabel.font = [YMSPhotoPickerTheme sharedInstance].albumNameLabelFont; +} + - (NSString *)YMS_cellIdentifier { return @"YMSAlbumCell"; @@ -46,10 +55,4 @@ - (void)setPhotosCount:(NSUInteger)photosCount _photosCount = photosCount; } -- (void)setFontForAlbumNameAndCount:(UIFont *)fontForAlbumNameAndCount -{ - self.photosCountLabel.font = fontForAlbumNameAndCount; - self.albumNameLabel.font = fontForAlbumNameAndCount; -} - @end diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m index 1f67a45..c363625 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m +++ b/YangMingShan/YMSPhotoPicker/Private/YMSAlbumPickerViewController.m @@ -126,7 +126,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N PHCollection *collection = collectionItem[@"collection"]; cell.albumName = collection.localizedTitle; - cell.fontForAlbumNameAndCount = [YMSPhotoPickerTheme sharedInstance].fontForAlbumNameAndCount ?: [UIFont systemFontOfSize:18.0]; cell.photosCount = fetchResult.count; if ([collectionItem isEqual:self.selectedCollectionItem]) { cell.accessoryType = UITableViewCellAccessoryCheckmark; diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h index 8ba98f6..e143359 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h +++ b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.h @@ -33,12 +33,6 @@ */ @property (nonatomic, assign) NSUInteger selectionOrder; -/** - * @brief Set the font used for the number in the bottom right corner of the cell, specifying which order that photo was picked in - * - */ -@property (nonatomic, assign) UIFont *fontForSelectionOrder; - /** * @brief Load the photo from photo library and display it on cell. * diff --git a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m index 267c14e..989147c 100644 --- a/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m +++ b/YangMingShan/YMSPhotoPicker/Private/YMSPhotoCell.m @@ -45,6 +45,7 @@ - (void)awakeFromNib [self addGestureRecognizer:self.longPressGestureRecognizer]; self.selectionOrderLabel.textColor = [YMSPhotoPickerTheme sharedInstance].orderLabelTextColor; + self.selectionOrderLabel.font = [YMSPhotoPickerTheme sharedInstance].selectionOrderLabelFont; self.selectionVeil.layer.borderWidth = 4.0; @@ -83,11 +84,6 @@ - (void)dealloc [self cancelImageRequest]; } -- (void)setFontForSelectionOrder:(UIFont *)fontForSelectionOrder -{ - self.selectionOrderLabel.font = fontForSelectionOrder; -} - #pragma mark - Publics - (void)loadPhotoWithManager:(PHImageManager *)manager forAsset:(PHAsset *)asset targetSize:(CGSize)size diff --git a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h index 19aa460..0a71f1f 100644 --- a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h +++ b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.h @@ -27,12 +27,6 @@ */ @property (nonatomic, strong) UIColor *titleLabelTextColor; -/** - * @brief Specify a UIFont that you want to apply on title label text and drop down arrow image in the middle of navigation bar to display current album localized name. - * - */ -@property (nonatomic, strong) UIFont *titleLabelFont; - /** * @brief Describe a specific UIColor that you want to apply on whole picker view controllers' navigation bar. * @@ -70,15 +64,27 @@ @property (nonatomic, assign) UIStatusBarStyle statusBarStyle; /** - * @brief Specify a UIFont that you want to apply to the table view showing album and album count information + * @brief Describe a specify UIFont that you want to apply on title label text and drop down arrow image in the middle of navigation bar to display current album localized name. + * + */ +@property (nonatomic, strong) UIFont *titleLabelFont; + +/** + * @brief Describe a specify UIFont that you want to apply to the table view showing album localized name. + * + */ +@property (nonatomic, strong) UIFont *albumNameLabelFont; + +/** + * @brief Describe a specify UIFont that you want to apply to the table view showing photo count insdie album. * */ -@property (nonatomic, assign) UIFont *fontForAlbumNameAndCount; +@property (nonatomic, strong) UIFont *photosCountLabelFont; /** - * @brief Specify a UIFont that you want to apply to the number in the bottom right of photo cells after they're selected, denoting order of selection + * @brief Describe a specify UIFont that you want to apply to the number in the bottom right of photo cells after they're selected, denoting order of selection. */ -@property (nonatomic, assign) UIFont *fontForPhotoSelectionOrder; +@property (nonatomic, strong) UIFont *selectionOrderLabelFont; /** * @brief Getting a shared instance of YMSPhotoPickerTheme. diff --git a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.m b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.m index 5c1e524..e779353 100644 --- a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.m +++ b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerTheme.m @@ -41,6 +41,10 @@ - (void)reset self.orderLabelTextColor = self.navigationBarBackgroundColor = self.cameraIconColor = [UIColor whiteColor]; self.titleLabelTextColor = [UIColor blackColor]; self.statusBarStyle = UIStatusBarStyleDefault; + self.titleLabelFont = [UIFont systemFontOfSize:18.0]; + self.albumNameLabelFont = [UIFont systemFontOfSize:18.0 weight:UIFontWeightLight]; + self.photosCountLabelFont = [UIFont systemFontOfSize:18.0 weight:UIFontWeightLight]; + self.selectionOrderLabelFont = [UIFont systemFontOfSize:17.0]; } @end diff --git a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m index d86bf89..9b7ef7c 100644 --- a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m +++ b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m @@ -203,7 +203,6 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtInde YMSPhotoCell *photoCell = (YMSPhotoCell *)cell; [photoCell setNeedsAnimateSelection]; photoCell.selectionOrder = self.selectedPhotos.count+1; - photoCell.fontForSelectionOrder = self.theme.fontForPhotoSelectionOrder; } return YES; } From 40e57727b31d54e6bc891d2c9e880c17062c120c Mon Sep 17 00:00:00 2001 From: Paul Jones Date: Fri, 19 Aug 2016 10:50:17 -0400 Subject: [PATCH 3/3] #11 removed non-needed default value for a newly non-null font property from theme --- .../YMSPhotoPicker/Public/YMSPhotoPickerViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m index 9b7ef7c..7339805 100644 --- a/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m +++ b/YangMingShan/YMSPhotoPicker/Public/YMSPhotoPickerViewController.m @@ -419,7 +419,7 @@ - (void)updateViewWithCollectionItem:(NSDictionary *)collectionItem UIButton *albumButton = [UIButton buttonWithType:UIButtonTypeSystem]; albumButton.tintColor = self.theme.titleLabelTextColor; - albumButton.titleLabel.font = self.theme.titleLabelFont ?: [UIFont systemFontOfSize:18.0]; + albumButton.titleLabel.font = self.theme.titleLabelFont; [albumButton addTarget:self action:@selector(presentAlbumPickerView:) forControlEvents:UIControlEventTouchUpInside]; [albumButton setTitle:photoCollection.localizedTitle forState:UIControlStateNormal]; UIImage *arrowDownImage = [UIImage imageNamed:@"YMSIconSpinnerDropdwon" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];