Skip to content

Commit f981b65

Browse files
committed
整理代码
1 parent 9d09b62 commit f981b65

File tree

6 files changed

+47
-54
lines changed

6 files changed

+47
-54
lines changed

TZImagePickerController.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
570A348C26D7275C000EEF2E /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348B26D7275C000EEF2E /* Photos.framework */; };
1111
570A348E26D72762000EEF2E /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348D26D72762000EEF2E /* PhotosUI.framework */; };
1212
570A349026D72768000EEF2E /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570A348F26D72768000EEF2E /* PhotosUI.framework */; };
13-
57DD378A26D61592005090FF /* TZTipShowFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DD378926D61592005090FF /* TZTipShowFooterView.m */; };
14-
57DD378E26D619C9005090FF /* TZTipShowFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DD378926D61592005090FF /* TZTipShowFooterView.m */; };
13+
57DD378A26D61592005090FF /* TZAuthLimitedFooterTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */; };
14+
57DD378E26D619C9005090FF /* TZAuthLimitedFooterTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */; };
1515
6D32B9BD1CD83640005CE1E0 /* LxGridViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D32B9BC1CD83640005CE1E0 /* LxGridViewFlowLayout.m */; };
1616
6D4608311DFFC60D004FB009 /* TZGifPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D4608301DFFC60D004FB009 /* TZGifPhotoPreviewController.m */; };
1717
6D5358CD1D64600F00928CC6 /* NSBundle+TZImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D5358CC1D64600F00928CC6 /* NSBundle+TZImagePicker.m */; };
@@ -125,8 +125,8 @@
125125
570A348B26D7275C000EEF2E /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Photos.framework; sourceTree = DEVELOPER_DIR; };
126126
570A348D26D72762000EEF2E /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/iOSSupport/System/Library/Frameworks/PhotosUI.framework; sourceTree = DEVELOPER_DIR; };
127127
570A348F26D72768000EEF2E /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; };
128-
57DD378826D61592005090FF /* TZTipShowFooterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZTipShowFooterView.h; sourceTree = "<group>"; };
129-
57DD378926D61592005090FF /* TZTipShowFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZTipShowFooterView.m; sourceTree = "<group>"; };
128+
57DD378826D61592005090FF /* TZAuthLimitedFooterTipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZAuthLimitedFooterTipView.h; sourceTree = "<group>"; };
129+
57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZAuthLimitedFooterTipView.m; sourceTree = "<group>"; };
130130
6D12FC191D66B71E00182C44 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = "<group>"; };
131131
6D12FC1A1D66B71E00182C44 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
132132
6D32B9BB1CD83640005CE1E0 /* LxGridViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LxGridViewFlowLayout.h; sourceTree = "<group>"; };
@@ -347,8 +347,8 @@
347347
B662C36E2662914D006A672A /* TZVideoEditedPreviewController.m */,
348348
6DD050291DF659ED0057C78D /* TZProgressView.h */,
349349
6DD0502A1DF659ED0057C78D /* TZProgressView.m */,
350-
57DD378826D61592005090FF /* TZTipShowFooterView.h */,
351-
57DD378926D61592005090FF /* TZTipShowFooterView.m */,
350+
57DD378826D61592005090FF /* TZAuthLimitedFooterTipView.h */,
351+
57DD378926D61592005090FF /* TZAuthLimitedFooterTipView.m */,
352352
90CE84AC1C3A89EF003D0779 /* TZImageManager.h */,
353353
90CE84AD1C3A89EF003D0779 /* TZImageManager.m */,
354354
901CC3F821CB757500C55443 /* TZImageRequestOperation.h */,
@@ -611,7 +611,7 @@
611611
900EF0021C2BD7E400EA709B /* TZAssetCell.m in Sources */,
612612
6DD0502B1DF659ED0057C78D /* TZProgressView.m in Sources */,
613613
6D32B9BD1CD83640005CE1E0 /* LxGridViewFlowLayout.m in Sources */,
614-
57DD378A26D61592005090FF /* TZTipShowFooterView.m in Sources */,
614+
57DD378A26D61592005090FF /* TZAuthLimitedFooterTipView.m in Sources */,
615615
6D4608311DFFC60D004FB009 /* TZGifPhotoPreviewController.m in Sources */,
616616
900EF0161C2C134900EA709B /* TZPhotoPreviewCell.m in Sources */,
617617
900E65871C2BB8D5003D9A9E /* ViewController.m in Sources */,
@@ -652,7 +652,7 @@
652652
isa = PBXSourcesBuildPhase;
653653
buildActionMask = 2147483647;
654654
files = (
655-
57DD378E26D619C9005090FF /* TZTipShowFooterView.m in Sources */,
655+
57DD378E26D619C9005090FF /* TZAuthLimitedFooterTipView.m in Sources */,
656656
B662C37326629179006A672A /* TZVideoEditedPreviewController.m in Sources */,
657657
B6977B0A265FDB280028BA31 /* TZVideoCropController.m in Sources */,
658658
901CC3FB21CB757500C55443 /* TZImageRequestOperation.m in Sources */,

TZImagePickerController/TZImagePickerController/TZTipShowFooterView.h renamed to TZImagePickerController/TZImagePickerController/TZAuthLimitedFooterTipView.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// XYTipShowFooterView.h
3-
// XYUIComponents
2+
// TZAuthLimitedFooterTipView.h
3+
// TZImagePickerController
44
//
55
// Created by qiaoxy on 2021/8/24.
66
//
@@ -9,7 +9,7 @@
99

1010
NS_ASSUME_NONNULL_BEGIN
1111

12-
@interface TZTipShowFooterView : UIView
12+
@interface TZAuthLimitedFooterTipView : UIView
1313

1414
@end
1515

TZImagePickerController/TZImagePickerController/TZTipShowFooterView.m renamed to TZImagePickerController/TZImagePickerController/TZAuthLimitedFooterTipView.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
//
2-
// XYTipShowFooterView.m
3-
// XYUIComponents
2+
// TZAuthLimitedFooterTipView.m
3+
// TZImagePickerController
44
//
55
// Created by qiaoxy on 2021/8/24.
66
//
77

8-
#import "TZTipShowFooterView.h"
8+
#import "TZAuthLimitedFooterTipView.h"
99
#import "TZImagePickerController.h"
1010

11-
@interface TZTipShowFooterView()
11+
@interface TZAuthLimitedFooterTipView()
1212
@property (nonatomic,strong) UIImageView *tipImgView;
1313
@property (nonatomic,strong) UILabel *tipLable;
1414
@property (nonatomic,strong) UIImageView *detailImgView;
1515
@end
1616

17-
@implementation TZTipShowFooterView
17+
@implementation TZAuthLimitedFooterTipView
1818

1919
- (instancetype)init {
2020
self = [super init];

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
@property (nonatomic, copy) NSString *photoPreviewOriginDefImageName __attribute__((deprecated("Use -photoPreviewOriginDefImage.")));
233233
@property (nonatomic, copy) NSString *photoNumberIconImageName __attribute__((deprecated("Use -photoNumberIconImage.")));
234234
@property (nonatomic, strong) UIImage *takePictureImage;
235-
@property (nonatomic, strong) UIImage *xy_addMoreLimitImage;
235+
@property (nonatomic, strong) UIImage *addMorePhotoImage;
236236
@property (nonatomic, strong) UIImage *photoSelImage;
237237
@property (nonatomic, strong) UIImage *photoDefImage;
238238
@property (nonatomic, strong) UIImage *photoOriginSelImage;

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ - (void)configDefaultImageName {
322322
self.photoPreviewOriginDefImageName = @"preview_original_def";
323323
self.photoOriginDefImageName = @"photo_original_def";
324324
self.photoOriginSelImageName = @"photo_original_sel";
325-
_xy_addMoreLimitImage = [UIImage tz_imageNamedFromMyBundle:@"addMore"];
325+
self.addMorePhotoImage = [UIImage tz_imageNamedFromMyBundle:@"addMore"];
326326
}
327327

328328
- (void)setTakePictureImageName:(NSString *)takePictureImageName {

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#import "TZLocationManager.h"
1919
#import <MobileCoreServices/MobileCoreServices.h>
2020
#import "TZImageRequestOperation.h"
21-
#import "TZTipShowFooterView.h"
21+
#import "TZAuthLimitedFooterTipView.h"
2222
#import <PhotosUI/PhotosUI.h>
2323
@interface TZPhotoPickerController ()<UICollectionViewDataSource,UICollectionViewDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate, PHPhotoLibraryChangeObserver> {
2424
NSMutableArray *_models;
@@ -34,14 +34,14 @@ @interface TZPhotoPickerController ()<UICollectionViewDataSource,UICollectionVie
3434

3535
BOOL _shouldScrollToBottom;
3636
BOOL _showTakePhotoBtn;
37-
BOOL _authorizationStatusLimited;
37+
BOOL _authorizationLimited;
3838

3939
CGFloat _offsetItemCount;
4040
}
4141
@property CGRect previousPreheatRect;
4242
@property (nonatomic, assign) BOOL isSelectOriginalPhoto;
4343
@property (nonatomic, strong) TZCollectionView *collectionView;
44-
@property (nonatomic,strong) TZTipShowFooterView *footerTipView;//底部提示
44+
@property (nonatomic, strong) TZAuthLimitedFooterTipView *authFooterTipView;
4545
@property (nonatomic, strong) UILabel *noDataLabel;
4646
@property (strong, nonatomic) UICollectionViewFlowLayout *layout;
4747
@property (nonatomic, strong) UIImagePickerController *imagePickerVc;
@@ -110,7 +110,7 @@ - (void)viewDidLoad {
110110
[tzImagePickerVc.childViewControllers firstObject].navigationItem.backBarButtonItem = backItem;
111111
}
112112
_showTakePhotoBtn = _model.isCameraRoll && ((tzImagePickerVc.allowTakePicture && tzImagePickerVc.allowPickingImage) || (tzImagePickerVc.allowTakeVideo && tzImagePickerVc.allowPickingVideo));
113-
_authorizationStatusLimited = [[TZImageManager manager] isPHAuthorizationStatusLimited];
113+
_authorizationLimited = [[TZImageManager manager] isPHAuthorizationStatusLimited];
114114
// [self resetCachedAssets];
115115
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
116116

@@ -195,29 +195,25 @@ - (void)configCollectionView {
195195
[_collectionView reloadData];
196196
}
197197

198-
if (!_footerTipView && _authorizationStatusLimited) {
199-
_footerTipView = [[TZTipShowFooterView alloc] initWithFrame:CGRectMake(0, 0, self.view.tz_width, 80)];
198+
if (!_authFooterTipView && _authorizationLimited) {
199+
_authFooterTipView = [[TZAuthLimitedFooterTipView alloc] initWithFrame:CGRectMake(0, 0, self.view.tz_width, 80)];
200200
UITapGestureRecognizer *footTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openSettingsApplication)];
201-
[_footerTipView addGestureRecognizer:footTap];
202-
[self.view addSubview:_footerTipView];
201+
[_authFooterTipView addGestureRecognizer:footTap];
202+
[self.view addSubview:_authFooterTipView];
203203
}
204204

205-
if (_showTakePhotoBtn) {
206-
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber) / self.columnNumber) * self.view.tz_width);
207-
} else {
208-
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + self.columnNumber - 1) / self.columnNumber) * self.view.tz_width);
209-
if (_models.count == 0) {
210-
_noDataLabel = [UILabel new];
211-
_noDataLabel.textAlignment = NSTextAlignmentCenter;
212-
_noDataLabel.text = [NSBundle tz_localizedStringForKey:@"No Photos or Videos"];
213-
CGFloat rgb = 153 / 256.0;
214-
_noDataLabel.textColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
215-
_noDataLabel.font = [UIFont boldSystemFontOfSize:20];
216-
[_collectionView addSubview:_noDataLabel];
217-
} else if (_noDataLabel) {
218-
[_noDataLabel removeFromSuperview];
219-
_noDataLabel = nil;
220-
}
205+
_collectionView.contentSize = CGSizeMake(self.view.tz_width, (([self getAllCellCount] + self.columnNumber - 1) / self.columnNumber) * self.view.tz_width);
206+
if (_models.count == 0) {
207+
_noDataLabel = [UILabel new];
208+
_noDataLabel.textAlignment = NSTextAlignmentCenter;
209+
_noDataLabel.text = [NSBundle tz_localizedStringForKey:@"No Photos or Videos"];
210+
CGFloat rgb = 153 / 256.0;
211+
_noDataLabel.textColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
212+
_noDataLabel.font = [UIFont boldSystemFontOfSize:20];
213+
[_collectionView addSubview:_noDataLabel];
214+
} else if (_noDataLabel) {
215+
[_noDataLabel removeFromSuperview];
216+
_noDataLabel = nil;
221217
}
222218
}
223219

@@ -367,6 +363,7 @@ - (void)viewDidLayoutSubviews {
367363
CGFloat top = 0;
368364
CGFloat collectionViewHeight = 0;
369365
CGFloat naviBarHeight = self.navigationController.navigationBar.tz_height;
366+
CGFloat footerTipViewH = _authorizationLimited ? 80 : 0;
370367
BOOL isStatusBarHidden = [UIApplication sharedApplication].isStatusBarHidden;
371368
BOOL isFullScreen = self.view.tz_height == [UIScreen mainScreen].bounds.size.height;
372369
CGFloat toolBarHeight = 50 + [TZCommonTools tz_safeAreaInsets].bottom;
@@ -377,9 +374,9 @@ - (void)viewDidLayoutSubviews {
377374
} else {
378375
collectionViewHeight = tzImagePickerVc.showSelectBtn ? self.view.tz_height - toolBarHeight : self.view.tz_height;
379376
}
377+
collectionViewHeight -= footerTipViewH;
380378

381-
CGFloat tipViewH = _authorizationStatusLimited ? 80 : 0;
382-
_collectionView.frame = CGRectMake(0, top, self.view.tz_width, collectionViewHeight - tipViewH);
379+
_collectionView.frame = CGRectMake(0, top, self.view.tz_width, collectionViewHeight);
383380
_noDataLabel.frame = _collectionView.bounds;
384381
CGFloat itemWH = (self.view.tz_width - (self.columnNumber + 1) * itemMargin) / self.columnNumber;
385382
_layout.itemSize = CGSizeMake(itemWH, itemWH);
@@ -399,13 +396,9 @@ - (void)viewDidLayoutSubviews {
399396
toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight;
400397
}
401398
_bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
402-
if (_authorizationStatusLimited) {
403-
CGFloat tipY = toolBarTop - tipViewH;
404-
CGRect tipRect = CGRectMake(0, self.view.tz_height - tipViewH, self.view.tz_width, tipViewH);;
405-
if (_bottomToolBar) {
406-
tipRect = CGRectMake(0, tipY, self.view.tz_width, tipViewH);
407-
}
408-
_footerTipView.frame = tipRect;
399+
if (_authFooterTipView) {
400+
CGFloat footerTipViewY = _bottomToolBar ? toolBarTop - footerTipViewH : self.view.tz_height - footerTipViewH;
401+
_authFooterTipView.frame = CGRectMake(0, footerTipViewY, self.view.tz_width, footerTipViewH);;
409402
}
410403
CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width + 2;
411404
if (!tzImagePickerVc.allowPreview) {
@@ -584,7 +577,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
584577
// the cell lead to add more photo / 去添加更多照片的cell
585578
if (indexPath.item == [self getAddMorePhotoCellIndex]) {
586579
TZAssetCameraCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZAssetCameraCell" forIndexPath:indexPath];
587-
cell.imageView.image = tzImagePickerVc.xy_addMoreLimitImage;
580+
cell.imageView.image = tzImagePickerVc.addMorePhotoImage;
588581
cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
589582
cell.imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
590583
return cell;
@@ -751,7 +744,7 @@ - (NSInteger)getAllCellCount {
751744
if (_showTakePhotoBtn) {
752745
count += 1;
753746
}
754-
if (_authorizationStatusLimited) {
747+
if (_authorizationLimited) {
755748
count += 1;
756749
}
757750
return count;
@@ -771,7 +764,7 @@ - (NSInteger)getTakePhotoCellIndex {
771764

772765
- (NSInteger)getAddMorePhotoCellIndex {
773766
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
774-
if (!_authorizationStatusLimited) {
767+
if (!_authorizationLimited) {
775768
return -1;
776769
}
777770
if (tzImagePickerVc.sortAscendingByModificationDate) {

0 commit comments

Comments
 (0)