Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kayo5994 authored Dec 30, 2016
2 parents d412399 + 2666ac0 commit 0f3943c
Show file tree
Hide file tree
Showing 79 changed files with 735 additions and 685 deletions.
14 changes: 7 additions & 7 deletions QMUIKit/UICommon/QMUICommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ EndIgnoreAvailabilityWarning
#define UIFontMake(size) [UIFont systemFontOfSize:size]
#define UIFontBoldMake(size) [UIFont boldSystemFontOfSize:size]
#define UIFontBoldWithFont(_font) [UIFont boldSystemFontOfSize:_font.pointSize]
#define UIFontLightMake(size) [UIFont lightSystemFontOfSize:size] // 系统字体只对数字和字母有效,中文无效
#define UIFontLightWithFont(_font) [UIFont lightSystemFontOfSize:_font.pointSize]
#define UIDynamicFontMake(size) [UIFont dynamicFontWithSize:size bold:NO]
#define UIDynamicFontMakeWithLimit(size, upperLimit, lowerLimit) [UIFont dynamicFontWithSize:size upperLimitSize:upperLimit lowerLimitSize:lowerLimit bold:NO]
#define UIDynamicFontBoldMake(size) [UIFont dynamicFontWithSize:size bold:YES]
#define UIDynamicFontBoldMakeWithLimit(size, upperLimit, lowerLimit) [UIFont dynamicFontWithSize:size upperLimitSize:upperLimit lowerLimitSize:lowerLimit bold:YES]
#define UIFontLightMake(size) [UIFont qmui_lightSystemFontOfSize:size] // 系统字体只对数字和字母有效,中文无效
#define UIFontLightWithFont(_font) [UIFont qmui_lightSystemFontOfSize:_font.pointSize]
#define UIDynamicFontMake(size) [UIFont qmui_dynamicFontWithSize:size bold:NO]
#define UIDynamicFontMakeWithLimit(size, upperLimit, lowerLimit) [UIFont qmui_dynamicFontWithSize:size upperLimitSize:upperLimit lowerLimitSize:lowerLimit bold:NO]
#define UIDynamicFontBoldMake(size) [UIFont qmui_dynamicFontWithSize:size bold:YES]
#define UIDynamicFontBoldMakeWithLimit(size, upperLimit, lowerLimit) [UIFont qmui_dynamicFontWithSize:size upperLimitSize:upperLimit lowerLimitSize:lowerLimit bold:YES]

// UIColor相关创建器
#define UIColorMake(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define UIColorMakeWithRGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a/1.0]
#define UIColorMakeWithHex(hex) [UIColor colorWithHexString:hex]
#define UIColorMakeWithHex(hex) [UIColor qmui_colorWithHexString:hex]


#pragma mark - 数学计算
Expand Down
14 changes: 7 additions & 7 deletions QMUIKit/UICommon/QMUIConfigurationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ - (void)initDefaultConfiguration {
self.navBarTitleColor = nil;
self.navBarTitleFont = UIFontBoldMake(17);
self.navBarBackButtonTitlePositionAdjustment = UIOffsetZero;
self.navBarBackIndicatorImage = [UIImage imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(12, 20) tintColor:self.navBarTintColor];
self.navBarCloseButtonImage = [UIImage imageWithShape:QMUIImageShapeNavClose size:CGSizeMake(16, 16) tintColor:self.navBarTintColor];
self.navBarBackIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(12, 20) tintColor:self.navBarTintColor];
self.navBarCloseButtonImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavClose size:CGSizeMake(16, 16) tintColor:self.navBarTintColor];

self.navBarLoadingMarginRight = 3;
self.navBarAccessoryViewMarginLeft = 5;
self.navBarActivityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
self.navBarAccessoryViewTypeDisclosureIndicatorImage = [[UIImage imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:self.whiteColor] imageWithOrientation:UIImageOrientationDown];
self.navBarAccessoryViewTypeDisclosureIndicatorImage = [[UIImage qmui_imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:self.whiteColor] qmui_imageWithOrientation:UIImageOrientationDown];

#pragma mark - TabBar

Expand Down Expand Up @@ -178,8 +178,8 @@ - (void)initDefaultConfiguration {
self.tableViewCellWarningBackgroundColor = self.yellowColor;
self.tableViewCellNormalHeight = 44;

self.tableViewCellDisclosureIndicatorImage = [UIImage imageWithShape:QMUIImageShapeDisclosureIndicator size:CGSizeMake(8, 13) tintColor:UIColorMakeWithRGBA(0, 0, 0, .2)];
self.tableViewCellCheckmarkImage = [UIImage imageWithShape:QMUIImageShapeCheckmark size:CGSizeMake(15, 12) tintColor:UIColorBlue];
self.tableViewCellDisclosureIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeDisclosureIndicator size:CGSizeMake(8, 13) tintColor:UIColorMakeWithRGBA(0, 0, 0, .2)];
self.tableViewCellCheckmarkImage = [UIImage qmui_imageWithShape:QMUIImageShapeCheckmark size:CGSizeMake(15, 12) tintColor:UIColorBlue];
self.tableViewSectionHeaderBackgroundColor = UIColorMake(244, 244, 244);
self.tableViewSectionFooterBackgroundColor = UIColorMake(244, 244, 244);
self.tableViewSectionHeaderFont = UIFontBoldMake(12);
Expand Down Expand Up @@ -233,13 +233,13 @@ + (void)renderGlobalAppearances {
UIToolbar *toolBarAppearance = [UIToolbar appearance];
[toolBarAppearance setBarTintColor:ToolBarBarTintColor];
[toolBarAppearance setBackgroundImage:ToolBarBackgroundImage forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[toolBarAppearance setShadowImage:[UIImage imageWithColor:ToolBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0] forToolbarPosition:UIBarPositionAny];
[toolBarAppearance setShadowImage:[UIImage qmui_imageWithColor:ToolBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0] forToolbarPosition:UIBarPositionAny];

// UITabBar
UITabBar *tabBarAppearance = [UITabBar appearance];
[tabBarAppearance setBarTintColor:TabBarBarTintColor];
[tabBarAppearance setBackgroundImage:TabBarBackgroundImage];
[tabBarAppearance setShadowImage:[UIImage imageWithColor:TabBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0]];
[tabBarAppearance setShadowImage:[UIImage qmui_imageWithColor:TabBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0]];


// UITabBarItem
Expand Down
10 changes: 5 additions & 5 deletions QMUIKit/UICommon/QMUIConfigurationTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.navBarTitleColor = NavBarTintColor; // NavBarTitleColor
//- QMUICMI.navBarTitleFont = UIFontBoldMake(17); // NavBarTitleFont
//- QMUICMI.navBarBackButtonTitlePositionAdjustment = UIOffsetZero; // NavBarBarBackButtonTitlePositionAdjustment
//- QMUICMI.navBarBackIndicatorImage = [UIImage imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(12, 20) tintColor:NavBarTintColor]; // NavBarBackIndicatorImage
//- QMUICMI.navBarCloseButtonImage = [UIImage imageWithShape:QMUIImageShapeNavClose size:CGSizeMake(16, 16) tintColor:NavBarTintColor]; // NavBarCloseButtonImage
//- QMUICMI.navBarBackIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(12, 20) tintColor:NavBarTintColor]; // NavBarBackIndicatorImage
//- QMUICMI.navBarCloseButtonImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavClose size:CGSizeMake(16, 16) tintColor:NavBarTintColor]; // NavBarCloseButtonImage

//- QMUICMI.navBarLoadingMarginRight = 3; // NavBarLoadingMarginRight
//- QMUICMI.navBarAccessoryViewMarginLeft = 5; // NavBarAccessoryViewMarginLeft
//- QMUICMI.navBarActivityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; // NavBarActivityIndicatorViewStyle
//- QMUICMI.navBarAccessoryViewTypeDisclosureIndicatorImage = [UIImage imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:UIColorWhite]; // NavBarAccessoryViewTypeDisclosureIndicatorImage
//- QMUICMI.navBarAccessoryViewTypeDisclosureIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:UIColorWhite]; // NavBarAccessoryViewTypeDisclosureIndicatorImage

#pragma mark - TabBar

Expand Down Expand Up @@ -170,8 +170,8 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.tableViewCellWarningBackgroundColor = UIColorYellow; // TableViewCellWarningBackgroundColor
//- QMUICMI.tableViewCellNormalHeight = 44; // TableViewCellNormalHeight

//- QMUICMI.tableViewCellDisclosureIndicatorImage = [UIImage imageWithShape:QMUIImageShapeDisclosureIndicator size:CGSizeMake(8, 13) tintColor:UIColorMakeWithRGBA(0, 0, 0, .2)]; // TableViewCellDisclosureIndicatorImage
//- QMUICMI.tableViewCellCheckmarkImage = [UIImage imageWithShape:QMUIImageShapeCheckmark size:CGSizeMake(15, 12) tintColor:UIColorBlue]; // TableViewCellCheckmarkImage
//- QMUICMI.tableViewCellDisclosureIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeDisclosureIndicator size:CGSizeMake(8, 13) tintColor:UIColorMakeWithRGBA(0, 0, 0, .2)]; // TableViewCellDisclosureIndicatorImage
//- QMUICMI.tableViewCellCheckmarkImage = [UIImage qmui_imageWithShape:QMUIImageShapeCheckmark size:CGSizeMake(15, 12) tintColor:UIColorBlue]; // TableViewCellCheckmarkImage
//- QMUICMI.tableViewSectionHeaderBackgroundColor = UIColorMake(244, 244, 244); // TableViewSectionHeaderBackgroundColor
//- QMUICMI.tableViewSectionFooterBackgroundColor = UIColorMake(244, 244, 244); // TableViewSectionFooterBackgroundColor
//- QMUICMI.tableViewSectionHeaderFont = UIFontBoldMake(12); // TableViewSectionHeaderFont
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/UICommon/QMUIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ @implementation QMUIHelper (ViewController)

+ (nullable UIViewController *)visibleViewController {
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
UIViewController *visibleViewController = [rootViewController visibleViewControllerIfExist];
UIViewController *visibleViewController = [rootViewController qmui_visibleViewControllerIfExist];
return visibleViewController;
}

Expand Down
5 changes: 5 additions & 0 deletions QMUIKit/UIComponents/AssetLibrary/QMUIAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,9 @@ typedef enum {
/// 更新下载资源的结果
- (void)updateDownloadStatusWithDownloadResult:(BOOL)succeed;

/**
* 获取 Asset 的体积(数据大小)
*/
- (long long)assetSize;

@end
19 changes: 18 additions & 1 deletion QMUIKit/UIComponents/AssetLibrary/QMUIAsset.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ @implementation QMUIAsset {
ALAsset *_alAsset;
ALAssetRepresentation *_alAssetRepresentation;
NSDictionary *_phAssetInfo;
float imageSize;

UIImage *_thumbnailImage;
UIImage *_originImage;
Expand Down Expand Up @@ -275,7 +276,7 @@ - (NSString *)assetIdentity {
identity = [[_alAssetRepresentation url] absoluteString];
}
// 系统输出的 identity 可能包含特殊字符,为了避免引起问题,统一使用 md5 转换
_assetIdentityHash = [identity md5];
_assetIdentityHash = [identity qmui_md5];
return _assetIdentityHash;
}

Expand All @@ -295,6 +296,7 @@ - (void)requestPhAssetInfo {
[tempInfo setObject:dataUTI forKey:@"dataUTI"];
}
[tempInfo setObject:@(orientation) forKey:@"orientation"];
[tempInfo setObject:@(imageData.length) forKey:@"imageSize"];
_phAssetInfo = tempInfo;
}
}];
Expand All @@ -309,4 +311,19 @@ - (void)updateDownloadStatusWithDownloadResult:(BOOL)succeed {
_downloadStatus = succeed ? QMUIAssetDownloadStatusSucceed : QMUIAssetDownloadStatusFailed;
}

- (long long)assetSize {
long long size;
if (_usePhotoKit) {
if (!_phAssetInfo) {
// PHAsset 的 UIImageOrientation 需要调用过 requestImageDataForAsset 才能获取
[self requestPhAssetInfo];
}
// 从 PhAssetInfo 中获取 UIImageOrientation 对应的字段
size = [_phAssetInfo[@"imageSize"] longLongValue];
} else {
size = [_alAsset defaultRepresentation].size;
}
return size;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ - (void)layoutSubviews {

CGFloat contentViewPaddingRight = 10;
self.imageView.frame = CGRectMake(0, 0, CGRectGetHeight(self.contentView.bounds), CGRectGetHeight(self.contentView.bounds));
self.textLabel.frame = CGRectSetXY(self.textLabel.frame, CGRectGetMaxX(self.imageView.frame) + self.albumNameInsets.left, flatf([self.textLabel minYWhenCenterInSuperview]));
self.textLabel.frame = CGRectSetXY(self.textLabel.frame, CGRectGetMaxX(self.imageView.frame) + self.albumNameInsets.left, flatf([self.textLabel qmui_minYWhenCenterInSuperview]));
CGFloat textLabelMaxWidth = CGRectGetWidth(self.contentView.bounds) - contentViewPaddingRight - CGRectGetWidth(self.detailTextLabel.frame) - self.albumNameInsets.right - CGRectGetMinX(self.textLabel.frame);
if (CGRectGetWidth(self.textLabel.frame) > textLabelMaxWidth) {
self.textLabel.frame = CGRectSetWidth(self.textLabel.frame, textLabelMaxWidth);
}

self.detailTextLabel.frame = CGRectSetXY(self.detailTextLabel.frame, CGRectGetMaxX(self.textLabel.frame) + self.albumNameInsets.right, flatf([self.detailTextLabel minYWhenCenterInSuperview]));
self.detailTextLabel.frame = CGRectSetXY(self.detailTextLabel.frame, CGRectGetMaxX(self.textLabel.frame) + self.albumNameInsets.right, flatf([self.detailTextLabel qmui_minYWhenCenterInSuperview]));
_bottomLineLayer.frame = CGRectMake(0, CGRectGetHeight(self.contentView.bounds) - PixelOne, CGRectGetWidth(self.bounds), PixelOne);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ - (void)initImagePickerCollectionViewCellUI {
[self.contentView addSubview:_contentImageView];

self.checkboxButton = [[UIButton alloc] init];
self.checkboxButton.outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.checkboxButton.qmui_outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.checkboxButton.hidden = YES;
[self.contentView addSubview:self.checkboxButton];

Expand All @@ -67,7 +67,7 @@ - (void)initImagePickerCollectionViewCellUI {
[self.contentView addSubview:self.progressView];

_downloadRetryButton = [[UIButton alloc] init];
self.downloadRetryButton.outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.downloadRetryButton.qmui_outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.downloadRetryButton.hidden = YES;
[self.contentView addSubview:self.downloadRetryButton];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
* @param currentImageIndex 当前展示的图片在 imageAssetArray 的索引
* @param singleCheckMode 是否为单选模式,如果是单选模式,则不显示 checkbox
*/
- (void)updateImagePickerPreviewViewWithImagesAssetArray:(NSArray *)imageAssetArray
selectedImageAssetArray:(NSArray *)selectedImageAssetArray
- (void)updateImagePickerPreviewViewWithImagesAssetArray:(NSArray<QMUIAsset *> *)imageAssetArray
selectedImageAssetArray:(NSArray<QMUIAsset *> *)selectedImageAssetArray
currentImageIndex:(NSInteger)currentImageIndex
singleCheckMode:(BOOL)singleCheckMode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ - (void)initSubviews {
self.backButton.tintColor = self.topToolBarView.tintColor;
[self.backButton sizeToFit];
[self.backButton addTarget:self action:@selector(handleCancelPreviewImage:) forControlEvents:UIControlEventTouchUpInside];
self.backButton.outsideEdge = UIEdgeInsetsMake(-30, -20, -50, -80);
self.backButton.qmui_outsideEdge = UIEdgeInsetsMake(-30, -20, -50, -80);
[self.topToolBarView addSubview:self.backButton];

_checkboxButton = [[QMUIButton alloc] init];
Expand All @@ -99,7 +99,7 @@ - (void)initSubviews {
self.checkboxButton.tintColor = self.topToolBarView.tintColor;
[self.checkboxButton sizeToFit];
[self.checkboxButton addTarget:self action:@selector(handleCheckButtonClick:) forControlEvents:UIControlEventTouchUpInside];
self.checkboxButton.outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.checkboxButton.qmui_outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
[self.topToolBarView addSubview:self.checkboxButton];

_progressView = [[QMUIPieProgressView alloc] init];
Expand All @@ -110,7 +110,7 @@ - (void)initSubviews {
[self.downloadRetryButton setImage:[QMUIHelper imageWithName:@"QMUI_icloud_download_fault"] forState:UIControlStateNormal];
[self.downloadRetryButton sizeToFit];
[self.downloadRetryButton addTarget:self action:@selector(handleDownloadRetryButtonClick:) forControlEvents:UIControlEventTouchUpInside];
self.downloadRetryButton.outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.downloadRetryButton.qmui_outsideEdge = UIEdgeInsetsMake(-6, -6, -6, -6);
self.downloadRetryButton.hidden = YES;
[self.topToolBarView addSubview:self.downloadRetryButton];
}
Expand All @@ -134,12 +134,12 @@ - (void)viewWillDisappear:(BOOL)animated {
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.topToolBarView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), TopToolBarViewHeight);
self.backButton.frame = CGRectSetXY(self.backButton.frame, 8, [self.backButton minYWhenCenterInSuperview]);
self.backButton.frame = CGRectSetXY(self.backButton.frame, 8, [self.backButton qmui_minYWhenCenterInSuperview]);
if (!_singleCheckMode) {
self.checkboxButton.frame = CGRectFlatted(CGRectSetXY(self.checkboxButton.frame, CGRectGetWidth(self.topToolBarView.frame) - 10 - CGRectGetWidth(self.checkboxButton.frame), [self.checkboxButton minYWhenCenterInSuperview]));
self.checkboxButton.frame = CGRectFlatted(CGRectSetXY(self.checkboxButton.frame, CGRectGetWidth(self.topToolBarView.frame) - 10 - CGRectGetWidth(self.checkboxButton.frame), [self.checkboxButton qmui_minYWhenCenterInSuperview]));
}
UIImage *downloadRetryImage = [self.downloadRetryButton imageForState:UIControlStateNormal];
self.downloadRetryButton.frame = CGRectFlatted(CGRectSetXY(self.downloadRetryButton.frame, CGRectGetWidth(self.topToolBarView.frame) - 10 - downloadRetryImage.size.width, [self.downloadRetryButton minYWhenCenterInSuperview]));
self.downloadRetryButton.frame = CGRectFlatted(CGRectSetXY(self.downloadRetryButton.frame, CGRectGetWidth(self.topToolBarView.frame) - 10 - downloadRetryImage.size.width, [self.downloadRetryButton qmui_minYWhenCenterInSuperview]));
/* 理论上 progressView 作为进度按钮,应该需要跟错误重试按钮 downloadRetryButton 的 frame 保持一致,但这里并没有直接使用
* self.progressView.frame = self.downloadRetryButton.frame,这是因为 self.downloadRetryButton 具有 1pt 的 top
* contentEdgeInsets,因此最终的 frame 是椭圆型,如果按上面的操作,progressView 内部绘制出的饼状图形就会变成椭圆型,
Expand Down Expand Up @@ -194,8 +194,8 @@ - (void)setDownloadStatus:(QMUIAssetDownloadStatus)downloadStatus {
}
}

- (void)updateImagePickerPreviewViewWithImagesAssetArray:(NSMutableArray *)imageAssetArray
selectedImageAssetArray:(NSMutableArray *)selectedImageAssetArray
- (void)updateImagePickerPreviewViewWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imageAssetArray
selectedImageAssetArray:(NSMutableArray<QMUIAsset *> *)selectedImageAssetArray
currentImageIndex:(NSInteger)currentImageIndex
singleCheckMode:(BOOL)singleCheckMode {
self.imagesAssetArray = imageAssetArray;
Expand Down
Loading

0 comments on commit 0f3943c

Please sign in to comment.