123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- import Foundation
- import TLPhotoPicker
- class NCPhotosPickerViewController: NSObject {
-
- let appDelegate = UIApplication.shared.delegate as! AppDelegate
- var sourceViewController: UIViewController
- var maxSelectedAssets = 1
- @objc init (_ viewController: UIViewController, maxSelectedAssets: Int) {
- sourceViewController = viewController
- self.maxSelectedAssets = maxSelectedAssets
- }
-
- @objc func openPhotosPickerViewController(phAssets: @escaping ([PHAsset]) -> ()) {
-
- var selectedPhAssets = [PHAsset]()
- var configure = TLPhotosPickerConfigure()
-
- configure.cancelTitle = NSLocalizedString("_cancel_", comment: "")
- configure.doneTitle = NSLocalizedString("_done_", comment: "")
- configure.emptyMessage = NSLocalizedString("_no_albums_", comment: "")
- configure.tapHereToChange = NSLocalizedString("_tap_here_to_change_", comment: "")
-
- configure.maxSelectedAssets = self.maxSelectedAssets
- configure.selectedColor = NCBrandColor.sharedInstance.brand
-
- if maxSelectedAssets == 1 {
- configure.singleSelectedMode = true
- }
-
- let viewController = customPhotoPickerViewController(withTLPHAssets: { (assets) in
-
- for asset: TLPHAsset in assets {
- if asset.phAsset != nil {
- selectedPhAssets.append(asset.phAsset!)
- }
- }
-
- phAssets(selectedPhAssets)
-
- }, didCancel: nil)
-
- viewController.didExceedMaximumNumberOfSelection = { (picker) in
- NCContentPresenter.shared.messageNotification("_info_", description: "_limited_dimension_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
- }
-
- viewController.handleNoAlbumPermissions = { (picker) in
- NCContentPresenter.shared.messageNotification("_info_", description: "_denied_album_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
- }
-
- viewController.handleNoCameraPermissions = { (picker) in
- NCContentPresenter.shared.messageNotification("_info_", description: "_denied_camera_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
- }
-
- viewController.configure = configure
- sourceViewController.present(viewController, animated: true, completion: nil)
- }
- }
- class customPhotoPickerViewController: TLPhotosPickerViewController {
-
- override var preferredStatusBarStyle: UIStatusBarStyle {
- return .lightContent
- }
-
- override func makeUI() {
- super.makeUI()
-
- self.customNavItem.leftBarButtonItem?.tintColor = NCBrandColor.sharedInstance.textView
- self.customNavItem.rightBarButtonItem?.tintColor = NCBrandColor.sharedInstance.textView
-
- self.titleLabel.textColor = NCBrandColor.sharedInstance.icon
- self.subTitleLabel.textColor = NCBrandColor.sharedInstance.graySoft
- self.subTitleArrowImageView.image = CCGraphics.changeThemingColorImage(self.subTitleArrowImageView.image, multiplier: 1, color: NCBrandColor.sharedInstance.graySoft)
-
- self.collectionView.backgroundColor = NCBrandColor.sharedInstance.backgroundView
- self.view.backgroundColor = NCBrandColor.sharedInstance.backgroundView
- if CCUtility.getDarkMode() {
- self.navigationBar.barStyle = .black
- }
- self.titleLabel.textColor = NCBrandColor.sharedInstance.textView
- self.subTitleLabel.textColor = NCBrandColor.sharedInstance.textView
- }
- }
|