@@ -59,6 +59,8 @@ TZImagePickerControllerDelegate>
@ property ( nonatomic , assign ) CGFloat maxWidth ;
@ property ( nonatomic , assign ) BOOL isPhotoPickerDisplayGIF ;
@ end
@ implementation XPMineUserInfoEditViewController
@@ -117,7 +119,7 @@ TZImagePickerControllerDelegate>
} ] ;
} ] ;
TTActionSheetConfig * photoLibrayConfig = [ TTActionSheetConfig normalTitle : YMLocalizedString ( @ "XPMineUserInfoEditViewController6" ) clickAction : ^ {
TTActionSheetConfig * photoLibrar yConfig = [ TTActionSheetConfig normalTitle : YMLocalizedString ( @ "XPMineUserInfoEditViewController6" ) clickAction : ^ {
[ YYUtility checkAssetsLibrayAvailable : ^ {
@ strongify ( self ) ;
// UIImagePickerController * imagePicker = [ [ UIImagePickerController alloc ] init ] ;
@@ -131,22 +133,9 @@ TZImagePickerControllerDelegate>
// [ imagePicker setDidSelectedAsset : ^ ( PHAsset * _Nonnull asset ) {
//
// } ] ;
TZImagePickerController * imagePickerVc = [ [ TZImagePickerController alloc ] initWithMaxImagesCount : 1
delegate : self ] ;
imagePickerVc . modalPresentationStyle = UIModalPresentationOverFullScreen ;
imagePickerVc . allowPickingVideo = NO ;
imagePickerVc . allowTakeVideo = NO ;
imagePickerVc . allowPickingGif = YES ;
imagePickerVc . allowCrop = YES ;
CGFloat cropWidth = KScreenWidth ;
imagePickerVc . cropRect = CGRectMake ( 0 , ( self . view . bounds . size . height - cropWidth ) / 2 , cropWidth , cropWidth ) ;
imagePickerVc . naviBgColor = [ DJDKMIMOMColor appCellBackgroundColor ] ;
imagePickerVc . naviTitleColor = [ DJDKMIMOMColor mainTextColor ] ;
imagePickerVc . barItemTextColor = [ DJDKMIMOMColor mainTextColor ] ;
[ self presentViewController : imagePickerVc animated : YES completion : nil ] ;
[ self presentViewController : [ self photoPickerWillDisplayGIF : NO ]
animated : YES
completion : nil ] ;
} denied : ^ {
@ strongify ( self ) ;
[ self showNotPhoto : YMLocalizedString ( @ "XPMineUserInfoEditViewController7" ) content : YMLocalizedString ( @ "XPMineUserInfoEditViewController8" ) ] ;
@@ -156,7 +145,43 @@ TZImagePickerControllerDelegate>
} ] ;
} ] ;
[ TTPopup actionSheetWithItems : @ [ cameraConfig , photoLibrayConfig ] ] ;
if ( self . userInfo . userVipInfoVO . vipLevel >= 1 ) {
TTActionSheetConfig * gifLibraryConfig = [ TTActionSheetConfig normalTitle : YMLocalizedString ( @ "UserInfoEdit_1.0.17_0" ) clickAction : ^ {
[ YYUtility checkAssetsLibrayAvailable : ^ {
@ strongify ( self ) ;
[ self presentViewController : [ self photoPickerWillDisplayGIF : YES ]
animated : YES
completion : nil ] ;
} denied : ^ {
@ strongify ( self ) ;
[ self showNotPhoto : YMLocalizedString ( @ "XPMineUserInfoEditViewController7" ) content : YMLocalizedString ( @ "XPMineUserInfoEditViewController8" ) ] ;
} restriction : ^ {
@ strongify ( self ) ;
[ self showNotPhoto : YMLocalizedString ( @ "XPMineUserInfoEditViewController9" ) content : YMLocalizedString ( @ "XPMineUserInfoEditViewController10" ) ] ;
} ] ;
} ] ;
[ TTPopup actionSheetWithItems : @ [ cameraConfig , photoLibraryConfig , gifLibraryConfig ] ] ;
} else {
[ TTPopup actionSheetWithItems : @ [ cameraConfig , photoLibraryConfig ] ] ;
}
}
- ( TZImagePickerController * ) photoPickerWillDisplayGIF : ( BOOL ) displayGIF {
self . isPhotoPickerDisplayGIF = displayGIF ;
TZImagePickerController * imagePickerVc = [ [ TZImagePickerController alloc ] initWithMaxImagesCount : 1
delegate : self ] ;
imagePickerVc . modalPresentationStyle = UIModalPresentationOverFullScreen ;
imagePickerVc . allowPickingVideo = NO ;
imagePickerVc . allowTakeVideo = NO ;
imagePickerVc . allowPickingGif = displayGIF ;
imagePickerVc . allowCrop = YES ;
CGFloat cropWidth = KScreenWidth ;
imagePickerVc . cropRect = CGRectMake ( 0 , ( self . view . bounds . size . height - cropWidth ) / 2 , cropWidth , cropWidth ) ;
imagePickerVc . naviBgColor = [ DJDKMIMOMColor appCellBackgroundColor ] ;
imagePickerVc . naviTitleColor = [ DJDKMIMOMColor mainTextColor ] ;
imagePickerVc . barItemTextColor = [ DJDKMIMOMColor mainTextColor ] ;
return imagePickerVc ;
}
- ( void ) showNotPhoto : ( NSString * ) title content : ( NSString * ) content {
@@ -364,17 +389,20 @@ TZImagePickerControllerDelegate>
# pragma mark - TZImagePickerControllerDelegate
- ( BOOL ) isAssetCanBeDisplayed : ( PHAsset * ) asset {
if ( self . isPhotoPickerDisplayGIF ) {
return [ [ asset valueForKey : @ "filename" ] containsString : @ "GIF" ] ;
} else {
return ! [ [ asset valueForKey : @ "filename" ] containsString : @ "GIF" ] ;
}
// if ( [ [ asset valueForKey : @ "filename" ] containsString : @ "GIF" ] ) {
// // TODO : 新 增 参 数 , 通 过 参 数 判 断 是 否 显 示 GIF
// if ( self . userInfo . userVipInfoVO . vipLevel > 2 ) {
// return NO ;
// }
// }
return YES ; // 其 他 类 型 的 资 源 正 常 显 示
// return YES ; // 其 他 类 型 的 资 源 正 常 显 示
}
- ( void ) imagePickerController : ( TZImagePickerController * ) picker
didFinishPickingPhotos : ( NSArray < UIImage * > * ) photos
sourceAssets : ( NSArray * ) assets