HXPhotoConfiguration.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. //
  2. // HXPhotoConfiguration.m
  3. // HXPhotoPickerExample
  4. //
  5. // Created by Silence on 2017/11/21.
  6. // Copyright © 2017年 Silence. All rights reserved.
  7. //
  8. #import "HXPhotoConfiguration.h"
  9. #import "HXPhotoTools.h"
  10. #import "UIColor+HXExtension.h"
  11. @implementation HXPhotoConfiguration
  12. - (instancetype)init {
  13. self = [super init];
  14. if (self) {
  15. [self setup];
  16. }
  17. return self;
  18. }
  19. - (void)setup {
  20. self.open3DTouchPreview = YES;
  21. self.openCamera = YES;
  22. self.lookLivePhoto = NO;
  23. self.lookGifPhoto = YES;
  24. self.selectTogether = NO;
  25. self.showOriginalBytesLoading = NO;
  26. self.exportVideoURLForHighestQuality = NO;
  27. self.maxNum = 10;
  28. self.photoMaxNum = 9;
  29. self.videoMaxNum = 1;
  30. self.showBottomPhotoDetail = YES;
  31. self.videoMaximumSelectDuration = 3 * 60.f;
  32. self.videoMinimumSelectDuration = 0.f;
  33. self.videoMaximumDuration = 60.f;
  34. self.videoMinimumDuration = 3.f;
  35. if ([UIScreen mainScreen].bounds.size.width != 320 && [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
  36. self.cameraCellShowPreview = YES;
  37. }
  38. self.customAlbumName = [NSBundle mainBundle].infoDictionary[(NSString *)kCFBundleNameKey];
  39. self.horizontalRowCount = 6;
  40. self.supportRotation = YES;
  41. self.pushTransitionDuration = 0.45f;
  42. self.popTransitionDuration = 0.35f;
  43. self.popInteractiveTransitionDuration = 0.45f;
  44. self.doneBtnShowDetail = YES;
  45. self.videoCanEdit = YES;
  46. self.photoCanEdit = YES;
  47. self.localFileName = @"HXPhotoPickerModelArray";
  48. self.languageType = HXPhotoLanguageTypeSys;
  49. self.popupTableViewCellHeight = 65.f;
  50. if (HX_IS_IPhoneX_All) {
  51. // self.editVideoExportPresetName = AVAssetExportPresetHighestQuality;
  52. self.popupTableViewHeight = 450;
  53. }else {
  54. // self.editVideoExportPresetName = AVAssetExportPresetMediumQuality;
  55. self.popupTableViewHeight = 350;
  56. }
  57. self.editVideoExportPreset = HXVideoEditorExportPresetRatio_960x540;
  58. self.videoQuality = 6;
  59. self.popupTableViewHorizontalHeight = 250;
  60. self.albumShowMode = HXPhotoAlbumShowModeDefault;
  61. self.cellDarkSelectTitleColor = [UIColor whiteColor];
  62. self.cellDarkSelectBgColor = [UIColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:1];
  63. self.previewDarkSelectBgColor = [UIColor whiteColor];
  64. self.previewDarkSelectTitleColor = [UIColor blackColor];
  65. [HXPhotoCommon photoCommon].photoStyle = HXPhotoStyleDefault;
  66. self.defaultFrontCamera = NO;
  67. self.popupTableViewBgColor = [UIColor whiteColor];
  68. self.albumListViewBgColor = [UIColor whiteColor];
  69. self.photoListViewBgColor = [UIColor whiteColor];
  70. self.previewPhotoViewBgColor = [UIColor whiteColor];
  71. self.albumListViewCellBgColor = [UIColor whiteColor];
  72. self.albumListViewCellTextColor = [UIColor blackColor];
  73. self.albumListViewCellSelectBgColor = nil;
  74. self.albumListViewCellLineColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.15];
  75. self.photoListBottomPhotoCountTextColor = [UIColor colorWithRed:51.f / 255.f green:51.f / 255.f blue:51.f / 255.f alpha:1];
  76. self.limitPhotoSize = 0;
  77. self.limitVideoSize = 0;
  78. self.selectPhotoLimitSize = NO;
  79. self.selectVideoLimitSize = NO;
  80. self.navBarTranslucent = YES;
  81. self.bottomViewTranslucent = YES;
  82. self.selectVideoBeyondTheLimitTimeAutoEdit = NO;
  83. self.videoAutoPlayType = HXVideoAutoPlayTypeOnce;
  84. self.previewSelectedBtnBgColor = self.themeColor;
  85. self.changeOriginalTinColor = YES;
  86. self.downloadNetworkVideo = YES;
  87. self.cameraCanLocation = YES;
  88. self.editAssetSaveSystemAblum = NO;
  89. self.photoEditCustomRatios = @[@{@"原始值" : @"{0, 0}"}, @{@"正方形" : @"{1, 1}"}, @{@"2:3" : @"{2, 3}"}, @{@"3:4" : @"{3, 4}"}, @{@"9:16" : @"{9, 16}"}, @{@"16:9" : @"{16, 9}"}];
  90. self.useWxPhotoEdit = YES;
  91. if (HX_IS_IPhoneX_All) {
  92. _clarityScale = 1.9;
  93. }else {
  94. _clarityScale = 1.5;
  95. }
  96. if ([UIScreen mainScreen].bounds.size.width == 320) {
  97. self.rowCount = 3;
  98. }else {
  99. if ([HXPhotoTools isIphone6]) {
  100. self.rowCount = 3;
  101. }else {
  102. self.rowCount = 4;
  103. }
  104. }
  105. self.allowSlidingSelection = YES;
  106. self.livePhotoAutoPlay = YES;
  107. self.photoListLimitBlurStyle = UIBlurEffectStyleLight;
  108. self.photoListLimitTextColor = [UIColor hx_colorWithHexStr:@"#666666"];
  109. self.photoListLimitSettingColor = self.themeColor;
  110. self.photoListLimitCloseColor = self.themeColor;
  111. self.photoListLimitCellBackgroundColor = [UIColor hx_colorWithHexStr:@"#f1f1f1"];
  112. self.photoListLimitCellBackgroundDarkColor = [UIColor hx_colorWithHexStr:@"#333333"];
  113. self.photoListLimitCellLineColor = [UIColor hx_colorWithHexStr:@"#999999"];
  114. self.photoListLimitCellLineDarkColor = [UIColor hx_colorWithHexStr:@"#ffffff"];
  115. self.photoListLimitCellTextColor = [UIColor hx_colorWithHexStr:@"#999999"];
  116. self.photoListLimitCellTextDarkColor = [UIColor hx_colorWithHexStr:@"#ffffff"];
  117. self.photoListLimitCellTextFont = [UIFont hx_mediumPingFangOfSize:14];
  118. }
  119. - (void)setLivePhotoAutoPlay:(BOOL)livePhotoAutoPlay {
  120. _livePhotoAutoPlay = livePhotoAutoPlay;
  121. [HXPhotoCommon photoCommon].livePhotoAutoPlay = livePhotoAutoPlay;
  122. }
  123. - (UIColor *)cameraFocusBoxColor {
  124. if (!_cameraFocusBoxColor) {
  125. _cameraFocusBoxColor = [UIColor colorWithRed:0 green:0.47843137254901963 blue:1 alpha:1];
  126. }
  127. return _cameraFocusBoxColor;
  128. }
  129. - (void)setVideoAutoPlayType:(HXVideoAutoPlayType)videoAutoPlayType {
  130. _videoAutoPlayType = videoAutoPlayType;
  131. [HXPhotoCommon photoCommon].videoAutoPlayType = videoAutoPlayType;
  132. }
  133. - (void)setDownloadNetworkVideo:(BOOL)downloadNetworkVideo {
  134. _downloadNetworkVideo = downloadNetworkVideo;
  135. [HXPhotoCommon photoCommon].downloadNetworkVideo = downloadNetworkVideo;
  136. }
  137. - (void)setPhotoStyle:(HXPhotoStyle)photoStyle {
  138. _photoStyle = photoStyle;
  139. [HXPhotoCommon photoCommon].photoStyle = photoStyle;
  140. }
  141. - (void)setCreationDateSort:(BOOL)creationDateSort {
  142. if ([HXPhotoCommon photoCommon].creationDateSort != creationDateSort) {
  143. [HXPhotoCommon photoCommon].cameraRollResult = nil;
  144. }
  145. _creationDateSort = creationDateSort;
  146. [HXPhotoCommon photoCommon].creationDateSort = creationDateSort;
  147. }
  148. - (void)setLanguageType:(HXPhotoLanguageType)languageType {
  149. if ([HXPhotoCommon photoCommon].languageType != languageType) {
  150. [HXPhotoCommon photoCommon].languageBundle = nil;
  151. }
  152. _languageType = languageType;
  153. [HXPhotoCommon photoCommon].languageType = languageType;
  154. }
  155. - (void)setClarityScale:(CGFloat)clarityScale {
  156. if (clarityScale <= 0.f) {
  157. if (HX_IS_IPhoneX_All) {
  158. _clarityScale = 1.9;
  159. }else {
  160. _clarityScale = 1.5;
  161. }
  162. }else {
  163. _clarityScale = clarityScale;
  164. }
  165. CGFloat width = ([UIScreen mainScreen].bounds.size.width - 1 * self.rowCount - 1 ) / self.rowCount;
  166. [HXPhotoCommon photoCommon].requestWidth = width * clarityScale;
  167. }
  168. - (void)setRowCount:(NSUInteger)rowCount {
  169. _rowCount = rowCount;
  170. CGFloat width = ([UIScreen mainScreen].bounds.size.width - 1 * rowCount - 1 ) / rowCount;
  171. [HXPhotoCommon photoCommon].requestWidth = width * self.clarityScale;
  172. }
  173. - (UIColor *)themeColor {
  174. if (!_themeColor) {
  175. _themeColor = [UIColor colorWithRed:0 green:0.47843137254901963 blue:1 alpha:1];
  176. }
  177. return _themeColor;
  178. }
  179. - (NSString *)originalNormalImageName {
  180. if (!_originalNormalImageName) {
  181. _originalNormalImageName = @"hx_original_normal";
  182. }
  183. return _originalNormalImageName;
  184. }
  185. - (NSString *)originalSelectedImageName {
  186. if (!_originalSelectedImageName) {
  187. _originalSelectedImageName = @"hx_original_selected";
  188. }
  189. return _originalSelectedImageName;
  190. }
  191. - (void)setVideoMaximumSelectDuration:(NSInteger)videoMaximumSelectDuration {
  192. if (videoMaximumSelectDuration <= 0) {
  193. videoMaximumSelectDuration = MAXFLOAT;
  194. }
  195. _videoMaximumSelectDuration = videoMaximumSelectDuration;
  196. }
  197. - (void)setVideoMaximumDuration:(NSTimeInterval)videoMaximumDuration {
  198. if (videoMaximumDuration <= self.videoMinimumDuration) {
  199. videoMaximumDuration = self.videoMinimumDuration + 1.f;
  200. }
  201. _videoMaximumDuration = videoMaximumDuration;
  202. }
  203. - (CGPoint)movableCropBoxCustomRatio {
  204. return _movableCropBoxCustomRatio;
  205. }
  206. - (NSInteger)minVideoClippingTime {
  207. if (_minVideoClippingTime < 1) {
  208. _minVideoClippingTime = 1;
  209. }
  210. return _minVideoClippingTime;
  211. }
  212. - (NSInteger)maxVideoClippingTime {
  213. if (!_maxVideoClippingTime) {
  214. _maxVideoClippingTime = 15;
  215. }
  216. return _maxVideoClippingTime;
  217. }
  218. - (UIColor *)authorizationTipColor {
  219. if (!_authorizationTipColor) {
  220. _authorizationTipColor = [UIColor blackColor];
  221. }
  222. return _authorizationTipColor;
  223. }
  224. - (void)setType:(HXConfigurationType)type {
  225. _type = type;
  226. if (type == HXConfigurationTypeWXChat) {
  227. [self setWxConfiguration];
  228. self.videoMaximumSelectDuration = 60.f * 5.f;
  229. self.selectVideoBeyondTheLimitTimeAutoEdit = NO;
  230. self.photoMaxNum = 0;
  231. self.videoMaxNum = 0;
  232. self.maxNum = 9;
  233. self.selectTogether = YES;
  234. }else if (type == HXConfigurationTypeWXMoment) {
  235. [self setWxConfiguration];
  236. self.videoMaximumDuration = 15;
  237. self.videoMaximumSelectDuration = 15;
  238. self.selectVideoBeyondTheLimitTimeAutoEdit = YES;
  239. self.photoMaxNum = 9;
  240. self.videoMaxNum = 1;
  241. self.maxNum = 9;
  242. self.selectTogether = NO;
  243. }
  244. }
  245. - (void)setWxConfiguration {
  246. self.videoCanEdit = YES;
  247. self.specialModeNeedHideVideoSelectBtn = YES;
  248. self.cameraPhotoJumpEdit = YES;
  249. self.saveSystemAblum = YES;
  250. self.albumShowMode = HXPhotoAlbumShowModePopup;
  251. self.photoListCancelLocation = HXPhotoListCancelButtonLocationTypeLeft;
  252. self.cameraCellShowPreview = NO;
  253. // 原图按钮设置
  254. self.changeOriginalTinColor = NO;
  255. self.originalNormalImageName = @"hx_original_normal_wx";
  256. self.originalSelectedImageName = @"hx_original_selected_wx";
  257. // 颜色设置
  258. UIColor *wxColor = [UIColor hx_colorWithHexStr:@"#07C160"];
  259. self.statusBarStyle = UIStatusBarStyleLightContent;
  260. self.themeColor = [UIColor whiteColor];
  261. self.photoEditConfigur.themeColor = wxColor;
  262. self.previewBottomSelectColor = wxColor;
  263. self.navBarBackgroudColor = nil;
  264. self.navBarStyle = UIBarStyleBlack;
  265. self.navigationTitleArrowColor = [UIColor hx_colorWithHexStr:@"#B2B2B2"];
  266. self.navigationTitleArrowDarkColor = [UIColor hx_colorWithHexStr:@"#B2B2B2"];
  267. self.cameraFocusBoxColor = wxColor;
  268. self.authorizationTipColor = [UIColor whiteColor];
  269. self.navigationTitleSynchColor = YES;
  270. self.cellSelectedBgColor = wxColor;
  271. self.cellSelectedTitleColor = [UIColor whiteColor];
  272. self.cellDarkSelectBgColor = wxColor;
  273. self.cellDarkSelectTitleColor = [UIColor whiteColor];
  274. self.photoListLimitBlurStyle = UIBlurEffectStyleDark;
  275. self.photoListLimitTextColor = [UIColor hx_colorWithHexStr:@"#999999"];
  276. self.photoListLimitSettingColor = wxColor;
  277. self.photoListLimitCloseColor = [UIColor whiteColor];
  278. self.previewSelectedBtnBgColor = wxColor;
  279. self.selectedTitleColor = [UIColor whiteColor];
  280. self.previewDarkSelectBgColor = wxColor;
  281. self.previewDarkSelectTitleColor = [UIColor whiteColor];
  282. self.bottomDoneBtnBgColor = wxColor;
  283. self.bottomDoneBtnDarkBgColor = wxColor;
  284. self.bottomDoneBtnEnabledBgColor = [[UIColor hx_colorWithHexStr:@"#666666"] colorWithAlphaComponent:0.3];
  285. self.bottomDoneBtnTitleColor = [UIColor whiteColor];
  286. // self.bottomViewBgColor = [UIColor hx_colorWithHexStr:@"#141414"];
  287. self.bottomViewBgColor = nil;
  288. self.bottomViewBarStyle = UIBarStyleBlack;
  289. self.popupTableViewCellBgColor = [UIColor hx_colorWithHexStr:@"#2E2F30"];
  290. self.popupTableViewCellLineColor = [[UIColor hx_colorWithHexStr:@"#434344"] colorWithAlphaComponent:0.6];
  291. self.popupTableViewCellSelectColor = [UIColor clearColor];
  292. self.popupTableViewCellSelectIconColor = wxColor;
  293. self.popupTableViewCellHighlightedColor = [UIColor colorWithRed:0.125 green:0.125 blue:0.125 alpha:1];
  294. self.popupTableViewBgColor = [UIColor colorWithRed:0.125 green:0.125 blue:0.125 alpha:1];
  295. self.popupTableViewCellPhotoCountColor = [UIColor whiteColor];
  296. self.popupTableViewCellAlbumNameColor = [UIColor whiteColor];
  297. self.popupTableViewHeight = HX_ScreenHeight * 0.65;
  298. self.albumListViewBgColor = [UIColor hx_colorWithHexStr:@"#2E2F30"];
  299. self.albumListViewCellBgColor = [UIColor hx_colorWithHexStr:@"#2E2F30"];
  300. self.albumListViewCellSelectBgColor = [UIColor colorWithRed:0.125 green:0.125 blue:0.125 alpha:1];
  301. self.albumListViewCellLineColor = [[UIColor hx_colorWithHexStr:@"#434344"] colorWithAlphaComponent:0.6];
  302. self.albumListViewCellTextColor = [UIColor whiteColor];
  303. self.photoListViewBgColor = [UIColor hx_colorWithHexStr:@"#2E2F30"];
  304. self.photoListBottomPhotoCountTextColor = [UIColor whiteColor];
  305. self.previewPhotoViewBgColor = [UIColor blackColor];
  306. self.photoListLimitCellBackgroundColor = [UIColor hx_colorWithHexStr:@"#383838"];
  307. self.photoListLimitCellLineColor = [UIColor hx_colorWithHexStr:@"#ffffff"];
  308. self.photoListLimitCellTextColor = [UIColor hx_colorWithHexStr:@"#ffffff"];
  309. }
  310. - (HXPhotoEditConfiguration *)photoEditConfigur {
  311. if (!_photoEditConfigur) {
  312. _photoEditConfigur = [[HXPhotoEditConfiguration alloc] init];
  313. _photoEditConfigur.themeColor = self.themeColor;
  314. _photoEditConfigur.supportRotation = self.supportRotation;
  315. }
  316. return _photoEditConfigur;
  317. }
  318. @end