Commit b223b127 authored by David黄金龙's avatar David黄金龙

处理 资讯页面 图片的保存、分享

parent 3a80d9dd
...@@ -5,9 +5,12 @@ platform :ios, '13.0' ...@@ -5,9 +5,12 @@ platform :ios, '13.0'
target 'galaxy' do target 'galaxy' do
use_frameworks! use_frameworks!
#图片预览
pod 'JXPhotoBrowser',"3.1.4"
pod 'SDWebImage','5.18.10'
#与H5进行交互 #与H5进行交互
pod "dsBridge",'3.0.6' pod "dsBridge",'3.0.6'
#网络检查 #网络检查
pod 'ReachabilitySwift','5.0.0' pod 'ReachabilitySwift','5.0.0'
#键盘处理 #键盘处理
......
...@@ -589,6 +589,8 @@ ...@@ -589,6 +589,8 @@
A5EF21352BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF21342BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift */; }; A5EF21352BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF21342BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift */; };
A5EF21372BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF21362BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift */; }; A5EF21372BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF21362BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift */; };
A5EF213B2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF213A2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift */; }; A5EF213B2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5EF213A2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift */; };
A5F886B42C61CEA700B63CF5 /* YHPictureReviewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F886B32C61CEA700B63CF5 /* YHPictureReviewManager.swift */; };
A5F886B62C61F76200B63CF5 /* YHLongtapPictureSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F886B52C61F76100B63CF5 /* YHLongtapPictureSheetView.swift */; };
A5F8AC082B9F414000A21EFA /* YHCustomTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F8AC072B9F414000A21EFA /* YHCustomTextView.swift */; }; A5F8AC082B9F414000A21EFA /* YHCustomTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F8AC072B9F414000A21EFA /* YHCustomTextView.swift */; };
A5FD45232C523DD300908AD9 /* YHJsApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FD45222C523DD300908AD9 /* YHJsApi.swift */; }; A5FD45232C523DD300908AD9 /* YHJsApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FD45222C523DD300908AD9 /* YHJsApi.swift */; };
A5FD63BD2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FD63BC2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift */; }; A5FD63BD2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FD63BC2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift */; };
...@@ -1229,6 +1231,8 @@ ...@@ -1229,6 +1231,8 @@
A5EF21342BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHQuestionAndAnswerViewController.swift; sourceTree = "<group>"; }; A5EF21342BA6E05E005027E6 /* YHQuestionAndAnswerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHQuestionAndAnswerViewController.swift; sourceTree = "<group>"; };
A5EF21362BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHQuestionAndAnswerModel.swift; sourceTree = "<group>"; }; A5EF21362BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHQuestionAndAnswerModel.swift; sourceTree = "<group>"; };
A5EF213A2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHQuestionAndAnswerCell.swift; sourceTree = "<group>"; }; A5EF213A2BA6EC98005027E6 /* YHQuestionAndAnswerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHQuestionAndAnswerCell.swift; sourceTree = "<group>"; };
A5F886B32C61CEA700B63CF5 /* YHPictureReviewManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPictureReviewManager.swift; sourceTree = "<group>"; };
A5F886B52C61F76100B63CF5 /* YHLongtapPictureSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLongtapPictureSheetView.swift; sourceTree = "<group>"; };
A5F8AC072B9F414000A21EFA /* YHCustomTextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCustomTextView.swift; sourceTree = "<group>"; }; A5F8AC072B9F414000A21EFA /* YHCustomTextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHCustomTextView.swift; sourceTree = "<group>"; };
A5FD45222C523DD300908AD9 /* YHJsApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHJsApi.swift; sourceTree = "<group>"; }; A5FD45222C523DD300908AD9 /* YHJsApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHJsApi.swift; sourceTree = "<group>"; };
A5FD63BC2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInformationPerfectListVC.swift; sourceTree = "<group>"; }; A5FD63BC2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInformationPerfectListVC.swift; sourceTree = "<group>"; };
...@@ -3163,6 +3167,7 @@ ...@@ -3163,6 +3167,7 @@
A5ACE91B2B4564F7002C94D2 /* Modules */ = { A5ACE91B2B4564F7002C94D2 /* Modules */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A5F886B22C61CDAA00B63CF5 /* PictureReview(图片预览) */,
A5FD45212C523D3200908AD9 /* InteractionH5(与H5交互) */, A5FD45212C523D3200908AD9 /* InteractionH5(与H5交互) */,
F8BAADA12C4FAE820074D6C3 /* UatModule(灰度功能) */, F8BAADA12C4FAE820074D6C3 /* UatModule(灰度功能) */,
044D0BE82C2019AC00C5CF5E /* Community(社区) */, 044D0BE82C2019AC00C5CF5E /* Community(社区) */,
...@@ -3284,6 +3289,15 @@ ...@@ -3284,6 +3289,15 @@
path = radar; path = radar;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
A5F886B22C61CDAA00B63CF5 /* PictureReview(图片预览) */ = {
isa = PBXGroup;
children = (
A5F886B32C61CEA700B63CF5 /* YHPictureReviewManager.swift */,
A5F886B52C61F76100B63CF5 /* YHLongtapPictureSheetView.swift */,
);
path = "PictureReview(图片预览)";
sourceTree = "<group>";
};
A5FD45212C523D3200908AD9 /* InteractionH5(与H5交互) */ = { A5FD45212C523D3200908AD9 /* InteractionH5(与H5交互) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -3602,6 +3616,7 @@ ...@@ -3602,6 +3616,7 @@
045EEEDE2B9F171A0022A143 /* YHEducationInfoCell.swift in Sources */, 045EEEDE2B9F171A0022A143 /* YHEducationInfoCell.swift in Sources */,
0409BEEB2C5B41D4003FCFD7 /* YHPrincipleUnapprovedCell.swift in Sources */, 0409BEEB2C5B41D4003FCFD7 /* YHPrincipleUnapprovedCell.swift in Sources */,
A5ACE93A2B4564F7002C94D2 /* NSAttributedString+Extension.swift in Sources */, A5ACE93A2B4564F7002C94D2 /* NSAttributedString+Extension.swift in Sources */,
A5F886B42C61CEA700B63CF5 /* YHPictureReviewManager.swift in Sources */,
04E86E662B86EB6F00A35F4B /* YHLoginManager.swift in Sources */, 04E86E662B86EB6F00A35F4B /* YHLoginManager.swift in Sources */,
04A7BD112BA4218B00BD35A2 /* YHMyDocumentsListViewModel.swift in Sources */, 04A7BD112BA4218B00BD35A2 /* YHMyDocumentsListViewModel.swift in Sources */,
0472CBA82C5A11640096F48F /* YHPrincipleReviewListVC.swift in Sources */, 0472CBA82C5A11640096F48F /* YHPrincipleReviewListVC.swift in Sources */,
...@@ -4009,6 +4024,7 @@ ...@@ -4009,6 +4024,7 @@
045EEEBB2B9F171A0022A143 /* YHWorkIntroductionTableViewCell.swift in Sources */, 045EEEBB2B9F171A0022A143 /* YHWorkIntroductionTableViewCell.swift in Sources */,
045EEEED2B9F171A0022A143 /* YHParentInfoVC.swift in Sources */, 045EEEED2B9F171A0022A143 /* YHParentInfoVC.swift in Sources */,
04A7BC912B6B7B89000E8D47 /* YHTwoOptionAlertView.swift in Sources */, 04A7BC912B6B7B89000E8D47 /* YHTwoOptionAlertView.swift in Sources */,
A5F886B62C61F76200B63CF5 /* YHLongtapPictureSheetView.swift in Sources */,
045EEF1C2B9F171A0022A143 /* YHAddressPresentAnimated.swift in Sources */, 045EEF1C2B9F171A0022A143 /* YHAddressPresentAnimated.swift in Sources */,
04E86E0D2B70D51D00A35F4B /* YHWebViewViewController.swift in Sources */, 04E86E0D2B70D51D00A35F4B /* YHWebViewViewController.swift in Sources */,
A5EF21312BA6DF94005027E6 /* YHMineSchemeViewController.swift in Sources */, A5EF21312BA6DF94005027E6 /* YHMineSchemeViewController.swift in Sources */,
......
...@@ -249,76 +249,6 @@ extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerContro ...@@ -249,76 +249,6 @@ extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerContro
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil) picker.dismiss(animated: true, completion: nil)
} }
// //原生上传
// func uploadImage(imageURL: URL) {
// let url = URL(string: "https://test-comserver.galaxy-immi.com/oss/upload/storage")! // 设置上传接口地址
//
// var request = URLRequest(url: url)
// request.httpMethod = "POST"
//
// do {
// let imageData = try Data(contentsOf: imageURL) // 读取要上传的图片数据
//
// let boundary = UUID().uuidString // 生成随机边界字符串
// request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
// request.addValue("4001001", forHTTPHeaderField: "businessCode")
//
// var body = ""
// body += "--\(boundary)\r\n"
// body += "Content-Disposition: form-data; name=\"file\"; filename=\"image.jpg\"\r\n" // 根据需求修改文件名称
// body += "Content-Type: image/jpeg\r\n\r\n" // 根据实际情况指定正确的MIME类型
// if let data = imageData.base64EncodedString(options: .lineLength76Characters).addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics) {
// let encodedBody = body + "\r\n" + data + "\r\n" + "--" + boundary + "--"
// guard let postData = encodedBody.data(using: String.Encoding.utf8) else { return }
//
// request.httpBody = postData
//
// let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
// if let error = error {
// print("Error: \(error)")
// } else if let httpResponse = response as? HTTPURLResponse {
// switch httpResponse.statusCode {
// case 200..<300:
// if let data = data {
// let string = String(data: data, encoding: .utf8)
//
// }
// print("Upload successful.")
// default:
// print("Failed to upload the image with status code: \(httpResponse.statusCode)")
// }
// }
// }
// task.resume()
// }
// } catch {
// print("Error reading image file: \(error)")
// }
// }
// // Alamofire上传
// func uploadImage(image: UIImage) {
// // 获取图片的二进制数据
// guard let imageData = image.jpegData(compressionQuality: 1) else { return }
// let boundary = UUID().uuidString
// let headers: HTTPHeaders = [
// "Content-type": "multipart/form-data; boundary=\(boundary)",
// "businessCode": "4001001"
// ]
// // 创建MultipartFormData对象
// let multipartFormData = MultipartFormData()
//
// // 将图片添加到multipartFormData中
// multipartFormData.append(imageData, withName: "file", fileName: "image.jpg", mimeType: "image/jpeg")
//
// // 发送POST请求
// let uploadRequest = AF.upload(multipartFormData: multipartFormData, to: "https://test-comserver.galaxy-immi.com/oss/upload/storage", headers: headers)
//
// uploadRequest.responseString(completionHandler: { string in
// printLog("\n网络请求已返回 string=\(string)")
// })
// }
} }
extension YHImagePickerView { extension YHImagePickerView {
......
...@@ -157,6 +157,13 @@ class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget ...@@ -157,6 +157,13 @@ class YHMySettingViewController: YHBaseViewController, ConstraintRelatableTarget
} }
@objc func didLogoutBtnClicked() { @objc func didLogoutBtnClicked() {
let arr = ["https://img1.baidu.com/it/u=2032777443,4245182967&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422",
"http://img0.baidu.com/it/u=594725074,698294204&fm=253&app=138&f=JPEG?w=800&h=1422"]
YHPictureReviewManager.shared.showNetWorkPicturs(curIndex: 1, arrPicturs: arr)
return//for test hjl
YHCommonAlertView.show("", "您确定要退出登录吗?", "取消", "确定",fullGuestureEnable: false) { YHCommonAlertView.show("", "您确定要退出登录吗?", "取消", "确定",fullGuestureEnable: false) {
} callBack: { } callBack: {
......
//
// YHLongtapPictureSheetView.swift
// galaxy
//
// Created by davidhuangA on 2024/8/6.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import Photos
import PhotosUI
class YHLongtapPictureSheetView: UIView {
var uploadTypeArr = ["分享图片","保存图片","取消"]
private let testUrl = "https://img1.baidu.com/it/u=2032777443,4245182967&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422"
lazy var blackMaskView: UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x0F1214, alpha: 0.5)
let tap = UITapGestureRecognizer(target: self, action: #selector(dismiss))
view.addGestureRecognizer(tap)
return view
}()
lazy var whiteContentView: UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
lazy var topView:UIView = {
let view = UIView()
view.addSubview(titleLabel)
view.addSubview(closeBtn)
let line = UIView()
line.backgroundColor = .separatorColor
view.addSubview(line)
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16)
make.left.right.equalToSuperview()
make.height.equalTo(24)
}
closeBtn.snp.makeConstraints { make in
make.centerY.equalTo(titleLabel)
make.right.equalToSuperview().offset(-20)
make.width.height.equalTo(24)
}
line.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(1)
make.bottom.equalToSuperview()
}
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.mainTextColor
label.textAlignment = .center
label.font = UIFont.PFSC_B(ofSize:17)
label.text = "请选择"
return label
}()
lazy var closeBtn: UIButton = {
let btn = UIButton()
btn.setImage(UIImage(named:"my_cer_sheet_close"), for: .normal)
btn.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return btn
}()
lazy var shareBtn: UIButton = {
let btn = UIButton()
btn.addTarget(self, action: #selector(share), for: .touchUpInside)
btn.setTitle("分享图片", for:.normal)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize:14)
return btn
}()
lazy var saveBtn: UIButton = {
let btn = UIButton()
btn.addTarget(self, action: #selector(save), for: .touchUpInside)
btn.setTitle("保存图片", for:.normal)
btn.setTitleColor(UIColor.mainTextColor, for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize:14)
return btn
}()
lazy var closeBtn2: UIButton = {
let btn = UIButton()
btn.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
btn.setTitle("取消", for:.normal)
btn.setTitleColor(UIColor(hex: 0x909090, alpha: 1.0), for: .normal)
btn.titleLabel?.font = UIFont.PFSC_M(ofSize:14)
return btn
}()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
static func sheetView() -> YHLongtapPictureSheetView {
let view = YHLongtapPictureSheetView(frame:UIScreen.main.bounds)
return view
}
func createUI() {
self.addSubview(blackMaskView)
self.addSubview(whiteContentView)
whiteContentView.addSubview(topView)
whiteContentView.addSubview(shareBtn)
let line = UIView()
line.backgroundColor = .separatorColor
whiteContentView.addSubview(line)
whiteContentView.addSubview(saveBtn)
let line2 = UIView()
line2.backgroundColor = .separatorColor
whiteContentView.addSubview(line2)
whiteContentView.addSubview(closeBtn2)
let corner = UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue)
let path = UIBezierPath(roundedRect:bounds,byRoundingCorners: corner,cornerRadii:CGSizeMake(16.0, 16.0));
let layer = CAShapeLayer();
layer.frame = whiteContentView.bounds;
layer.path = path.cgPath;
whiteContentView.layer.mask = layer;
blackMaskView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let whiteHeight = calculateHeight()
whiteContentView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(whiteHeight)
}
topView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(53)
}
shareBtn.snp.makeConstraints { make in
make.top.equalTo(topView.snp.bottom)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(52)
}
line.snp.makeConstraints { make in
make.top.equalTo(shareBtn.snp.bottom)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(1)
}
saveBtn.snp.makeConstraints { make in
make.top.equalTo(line.snp.bottom)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(52)
}
line2.snp.makeConstraints { make in
make.top.equalTo(saveBtn.snp.bottom)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(1)
}
closeBtn2.snp.makeConstraints { make in
make.top.equalTo(line2.snp.bottom)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(52)
}
}
func calculateHeight() -> CGFloat {
// 底部四个操作行高度之和
let tableViewHeight = 52.0 * Double(self.uploadTypeArr.count) + (Double(self.uploadTypeArr.count - 1)) * 1
// 白色View总高度
var totalHeight = 52.0 + 1 + tableViewHeight + k_Height_safeAreaInsetsBottom()
return totalHeight
}
}
extension YHLongtapPictureSheetView {
func show() {
UIApplication.shared.yhKeyWindow()?.addSubview(self)
}
@objc func dismiss() {
DispatchQueue.main.async {
self.removeFromSuperview()
}
}
}
private extension YHLongtapPictureSheetView {
@objc func share() {
self.dismiss()
guard let url = URL(string: testUrl) else {
return
}
let task = URLSession.shared.dataTask(with: url) { data, response, error in
DispatchQueue.main.async {
guard let data = data, error == nil else { return }
let image = UIImage(data: data)
if let image = image {
YHShareManager.shared.sendImageContent(image)
}
}
}
task.resume()
}
@objc func save() {
saveLocalPictureSyn(testUrl)
self.dismiss()
}
func saveLocalPictureSyn(_ picUrl: String) {
let imageView = UIImageView()
imageView.kf.setImage(with: URL(string: picUrl)) { result in
switch result {
case .success(let value):
self.saveImage(value.image)
case .failure(_):
YHHUD.flash(message: "保存失败")
}
}
}
func saveImage(_ image: UIImage) {
// 确保应用有权访问相册
PHPhotoLibrary.requestAuthorization { status in
if status == .authorized {
// 保存图片到相册
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
DispatchQueue.main.async {
YHHUD.flash(message: "保存成功")
}
}
}
}
}
//
// YHPictureReviewManager.swift
// galaxy
//
// Created by davidhuangA on 2024/8/6.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXPhotoBrowser
import SDWebImage
class YHPictureReviewManager: NSObject {
static let shared = YHPictureReviewManager()
override init() {
super.init()
}
private var curIndex : Int = 0
private var arrPics : [String] = []
}
extension YHPictureReviewManager {
func showNetWorkPicturs(curIndex : Int,arrPicturs:[String]) {
self.curIndex = curIndex
self.arrPics = arrPicturs
let browser = JXPhotoBrowser()
browser.numberOfItems = {
self.arrPics.count
}
browser.reloadCellAtIndex = { context in
let url = URL(string: self.arrPics[context.index])//self.dataSource[context.index].secondLevelUrl.flatMap { URL(string: $0) }
let browserCell = context.cell as? JXPhotoBrowserImageCell
browserCell?.index = context.index
// let collectionPath = IndexPath(item: context.index, section: indexPath.section)
// let collectionCell = collectionView.cellForItem(at: collectionPath) as? BaseCollectionViewCell
let placeholder = UIImage(named: "global_default_image")//collectionCell?.imageView.image
browserCell?.imageView.sd_setImage(with: url, placeholderImage: placeholder, options: [], completed: { (_, _, _, _) in
browserCell?.setNeedsLayout()
})
// 添加长按事件
browserCell?.longPressedAction = { cell, _ in
self.longPress(cell: cell)
}
}
// browser.transitionAnimator = JXPhotoBrowserZoomAnimator(previousView: { index -> UIView? in
// let path = IndexPath(item: index, section: indexPath.section)
// let cell = collectionView.cellForItem(at: path) as? BaseCollectionViewCell
// return cell?.imageView
// })
// 数字样式的页码指示器
browser.pageIndicator = JXPhotoBrowserNumberPageIndicator()
browser.pageIndex = self.curIndex
browser.show()
}
}
extension YHPictureReviewManager {
private func longPress(cell: JXPhotoBrowserImageCell) {
// let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
// alert.addAction(UIAlertAction(title: "删除", style: .destructive, handler: { _ in
// self.dataSource.remove(at: cell.index)
// self.collectionView.reloadData()
// cell.photoBrowser?.reloadData()
// // 如果删没了,关闭
// cell.photoBrowser?.dismiss()
// }))
// alert.addAction(UIAlertAction(title: "取消", style: .cancel, handler: nil))
// cell.photoBrowser?.present(alert, animated: true, completion: nil)
let view = YHLongtapPictureSheetView.sheetView()
view.show()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment