Commit 56ff6516 authored by yqz's avatar yqz

Merge branch 'dev_main' of http://gitlab.zhangxindiet.com/ShuMing/phonemanager into dev_main

* 'dev_main' of http://gitlab.zhangxindiet.com/ShuMing/phonemanager:
  1
  fix bugs
parents 9c116077 eb771ea4
...@@ -13,6 +13,7 @@ import UserMessagingPlatform ...@@ -13,6 +13,7 @@ import UserMessagingPlatform
import GoogleSignIn import GoogleSignIn
import AdjustSdk import AdjustSdk
@main @main
class AppDelegate: UIResponder, UIApplicationDelegate { class AppDelegate: UIResponder, UIApplicationDelegate {
...@@ -78,17 +79,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -78,17 +79,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
Adjust.attribution { attribution in Adjust.attribution { attribution in
Print("获取归因数据11",attribution?.jsonResponse) // Print("获取归因数据11",attribution?.jsonResponse)
// let trackerToken = attribution?.trackerToken // let pram = [
// let trackerName = attribution?.trackerName // "trackerToken":attribution?.trackerToken ?? "",
// let network = attribution?.network // "trackerName":attribution?.trackerName ?? "",
// let campaign = attribution?.campaign // "network":attribution?.network ?? "",
// let adgroup = attribution?.adgroup // "campaign":attribution?.campaign ?? "",
// let creative = attribution?.creative // "adgroup":attribution?.adgroup ?? "",
// let clickLabel = attribution?.clickLabel // "creative":attribution?.creative ?? "",
// let costType = attribution?.costType // "clickLabel":attribution?.clickLabel ?? "",
// let costAmount = attribution?.costAmount // "costType":attribution?.costType ?? "",
// let costCurrency = attribution?.costCurrency // "costAmount":attribution?.costAmount ?? "",
// "costCurrency":attribution?.costCurrency ?? "",
// ]
// let dic = attribution.jso
Print("获取当前归因信息",attribution?.jsonResponse as Any)
// APIReportManager.shared.startReport(type: .source_atrribute,ext: pram)
} }
......
...@@ -29,6 +29,7 @@ extension AppDelegate{ ...@@ -29,6 +29,7 @@ extension AppDelegate{
switch shortcutItem.type { switch shortcutItem.type {
case "com.app.phonemanager.iap.distance": case "com.app.phonemanager.iap.distance":
// 执行相应操作 // 执行相应操作
IAPManager.share.config()
IAPManager.share.showYearPage = true IAPManager.share.showYearPage = true
if IAPManager.share.isHotLaunch{ if IAPManager.share.isHotLaunch{
// 热启动走这里 // 热启动走这里
...@@ -57,13 +58,12 @@ extension AppDelegate{ ...@@ -57,13 +58,12 @@ extension AppDelegate{
extension AppDelegate:AdjustDelegate{ extension AppDelegate:AdjustDelegate{
// 因变化时触发函数
func adjustAttributionChanged(_ attribution: ADJAttribution?) { func adjustAttributionChanged(_ attribution: ADJAttribution?) {
guard let attribution = attribution else { return } guard let attribution = attribution else { return }
// 可以将这些数据上报给自己的服务器或者做其他处理 // 可以将这些数据上报给自己的服务器或者做其他处理
print("归因数据:", attribution) print("归因变化数据:", attribution.jsonResponse)
} }
} }
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "logo_phone_manager@2x.png", "filename" : "Group_1171275248@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "logo_phone_manager@3x.png", "filename" : "Group_1171275248@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "phone_manager@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "phone_manager@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -120,6 +120,8 @@ class IAPManager: NSObject { ...@@ -120,6 +120,8 @@ class IAPManager: NSObject {
} }
} }
func config(){}
// MARK: - Initialization // MARK: - Initialization
private override init() { private override init() {
......
...@@ -224,7 +224,7 @@ extension PhotoDuplicateManager { ...@@ -224,7 +224,7 @@ extension PhotoDuplicateManager {
return fetchResult.firstObject == nil return fetchResult.firstObject == nil
} }
return SimilarGroupModel(groupId: group.groupId, assets: validAssets) return SimilarGroupModel(groupId: group.groupId, assets: validAssets)
}.filter { !$0.assets.isEmpty } }.filter { $0.assets.count > 1}
} }
// 移除本地文件资源 // 移除本地文件资源
......
...@@ -348,7 +348,7 @@ extension PhotoSimilarManager{ ...@@ -348,7 +348,7 @@ extension PhotoSimilarManager{
return fetchResult.firstObject == nil return fetchResult.firstObject == nil
} }
return SimilarGroupModel(groupId: group.groupId, assets: validAssets) return SimilarGroupModel(groupId: group.groupId, assets: validAssets)
}.filter { !$0.assets.isEmpty } }.filter { $0.assets.count > 1}
} }
// 移除本地文件资源 // 移除本地文件资源
......
...@@ -380,7 +380,7 @@ extension ScreenshotSimilarJSONManager{ ...@@ -380,7 +380,7 @@ extension ScreenshotSimilarJSONManager{
return fetchResult.firstObject == nil return fetchResult.firstObject == nil
} }
return SimilarGroupModel(groupId: group.groupId, assets: validAssets) return SimilarGroupModel(groupId: group.groupId, assets: validAssets)
}.filter { !$0.assets.isEmpty } }.filter { $0.assets.count > 1}
} }
......
...@@ -687,7 +687,7 @@ extension VideoSimilarJSONManager { ...@@ -687,7 +687,7 @@ extension VideoSimilarJSONManager {
return fetchResult.firstObject == nil return fetchResult.firstObject == nil
} }
return SimilarGroupModel(groupId: group.groupId, assets: validAssets) return SimilarGroupModel(groupId: group.groupId, assets: validAssets)
}.filter { !$0.assets.isEmpty } }.filter { $0.assets.count > 1}
} }
} }
......
...@@ -30,6 +30,8 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -30,6 +30,8 @@ class AdvManager : NSObject, FullScreenContentDelegate {
static let shared : AdvManager = AdvManager() static let shared : AdvManager = AdvManager()
var currentVCName:String = ""
// 看完广告的回调 // 看完广告的回调
var finisedCallBack:()->Void = {} var finisedCallBack:()->Void = {}
...@@ -105,7 +107,7 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -105,7 +107,7 @@ class AdvManager : NSObject, FullScreenContentDelegate {
/// 获取激励插页广告 /// 获取激励插页广告
/// ///
func loadRewardedInterstitialAd() async { func loadRewardedInterstitialAd() async {
APIReportManager.shared.startReport(type: .ad_pull_start, ext: ["ad_type":"rewardAd","from":""]) APIReportManager.shared.startReport(type: .ad_pull_start, ext: ["ad_type":"rewardAd"])
do { do {
rewardedInterstitialAd = try await RewardedInterstitialAd.load( rewardedInterstitialAd = try await RewardedInterstitialAd.load(
with: AdvManager.REWARDED_INTERSTITIALAD_KEY, request: Request()) with: AdvManager.REWARDED_INTERSTITIALAD_KEY, request: Request())
...@@ -133,7 +135,7 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -133,7 +135,7 @@ class AdvManager : NSObject, FullScreenContentDelegate {
/// 获取单纯的插页广告 /// 获取单纯的插页广告
fileprivate func loadInterstitial() async { fileprivate func loadInterstitial() async {
APIReportManager.shared.startReport(type: .ad_pull_start, ext: ["ad_type":"interAd","from":""]) APIReportManager.shared.startReport(type: .ad_pull_start, ext: ["ad_type":"interAd"])
do { do {
interstitial = try await InterstitialAd.load( interstitial = try await InterstitialAd.load(
with: AdvManager.INTERSTITIALAD_KEY, request: Request()) with: AdvManager.INTERSTITIALAD_KEY, request: Request())
...@@ -176,9 +178,10 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -176,9 +178,10 @@ class AdvManager : NSObject, FullScreenContentDelegate {
} }
return return
} }
self.currentVCName = NSStringFromClass(type(of: vc))
APIReportManager.shared.startReport( APIReportManager.shared.startReport(
type: .ad_prepare_show, type: .ad_prepare_show,
ext: ["ad_type": "rewardAd","from":""]) ext: ["ad_type": "rewardAd","from":self.currentVCName])
ad.present(from: vc) {} ad.present(from: vc) {}
} }
...@@ -191,9 +194,10 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -191,9 +194,10 @@ class AdvManager : NSObject, FullScreenContentDelegate {
return return
} }
self.currentAdvType = .interstitialType self.currentAdvType = .interstitialType
self.currentVCName = NSStringFromClass(type(of: vc))
APIReportManager.shared.startReport( APIReportManager.shared.startReport(
type: .ad_prepare_show, type: .ad_prepare_show,
ext: ["ad_type": "interAd","from":""]) ext: ["ad_type": "interAd","from":currentVCName])
ad.present(from: vc) ad.present(from: vc)
} }
...@@ -202,12 +206,12 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -202,12 +206,12 @@ class AdvManager : NSObject, FullScreenContentDelegate {
func adWillPresentFullScreenContent(_ ad: FullScreenPresentingAd) { func adWillPresentFullScreenContent(_ ad: FullScreenPresentingAd) {
print("Ad did present full screen content.") print("Ad did present full screen content.")
var ad_type = "interAd" var ad_type = "interAd"
if let ad = ad as? RewardedInterstitialAd{ if let _ = ad as? RewardedInterstitialAd{
ad_type = "rewardAd" ad_type = "rewardAd"
} }
APIReportManager.shared.startReport( APIReportManager.shared.startReport(
type: .ad_show, type: .ad_show,
ext: ["ad_type": ad_type,"from":""]) ext: ["ad_type": ad_type,"from":currentVCName])
} }
...@@ -220,7 +224,7 @@ class AdvManager : NSObject, FullScreenContentDelegate { ...@@ -220,7 +224,7 @@ class AdvManager : NSObject, FullScreenContentDelegate {
} }
APIReportManager.shared.startReport( APIReportManager.shared.startReport(
type: .ad_show_error, type: .ad_show_error,
ext: ["ad_type": ad_type,"from":"","reason":error.localizedDescription]) ext: ["ad_type": ad_type,"from":currentVCName,"reason":error.localizedDescription])
self.rewardedInterstitialAd = nil self.rewardedInterstitialAd = nil
...@@ -326,7 +330,7 @@ extension AdvManager{ ...@@ -326,7 +330,7 @@ extension AdvManager{
let pram = [ let pram = [
"ad_type": ad_type, "ad_type": ad_type,
"from":"", "from":currentVCName,
"networkname":adNetworkName, "networkname":adNetworkName,
"source":adSourceName, "source":adSourceName,
"adSourceInstanceName":adSourceInstanceName, "adSourceInstanceName":adSourceInstanceName,
......
...@@ -364,7 +364,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie ...@@ -364,7 +364,7 @@ extension HomeVideoDetailController:WaterfallMutiSectionDelegate,UICollectionVie
cell.resourceIdent = self.resourceData[indexPath.row] cell.resourceIdent = self.resourceData[indexPath.row]
cell.currentOrder = indexPath.row cell.currentOrder = indexPath.row
cell.backImageView.image = nil // cell.backImageView.image = nil
if self.selectedModel.contains(where: { $0.localIdentifier == cell.resourceIdent!.localIdentifier }) { if self.selectedModel.contains(where: { $0.localIdentifier == cell.resourceIdent!.localIdentifier }) {
cell.choose = true cell.choose = true
}else{ }else{
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import UIKit import UIKit
import AppTrackingTransparency import AppTrackingTransparency
import SVProgressHUD
class HomeViewController:BaseViewController { class HomeViewController:BaseViewController {
...@@ -225,29 +226,33 @@ class HomeViewController:BaseViewController { ...@@ -225,29 +226,33 @@ class HomeViewController:BaseViewController {
func showIAPVC(){ func showIAPVC(){
IAPManager.share.isHotLaunch = true IAPManager.share.isHotLaunch = true
IAPManager.share.checkSubscriptionState { isSubscribed,type,expiresDate in IAPManager.share.checkSubscriptionState {[weak self] isSubscribed,type,expiresDate in
guard let self = self else { return }
Print("是否内购---",isSubscribed) Print("是否内购---",isSubscribed)
if IAPManager.share.showYearPage{ DispatchQueue.main.async {
//按钮启动 if IAPManager.share.showYearPage{
switch type { //按钮启动
case .none,.week: switch type {
let vc:PayDistanceViewController = PayDistanceViewController() case .none,.week:
let nav:BaseNavViewController = BaseNavViewController(rootViewController: vc) let vc = PayDistanceViewController()
nav.modalPresentationStyle = .fullScreen let nav:BaseNavViewController = BaseNavViewController(rootViewController: vc)
self.present(nav, animated: true) nav.modalPresentationStyle = .fullScreen
break self.present(nav, animated: true)
case .lifetime,.year:
let vc : PayCompletedViewController = PayCompletedViewController() break
vc.modalPresentationStyle = .fullScreen case .lifetime,.year:
self.present(vc, animated: true) let vc : PayCompletedViewController = PayCompletedViewController()
} vc.modalPresentationStyle = .fullScreen
}else{ self.present(vc, animated: true)
// 正常启动 }
if !isSubscribed{ }else{
DispatchQueue.main.async { // 正常启动
if !IAPManager.share.showYearPage{ if !isSubscribed{
HomePayViewController.show { DispatchQueue.main.async {
NotificationManager().configNotifications() if !IAPManager.share.showYearPage{
HomePayViewController.show {
NotificationManager().configNotifications()
}
} }
} }
} }
......
...@@ -393,17 +393,19 @@ extension HomeInfoView:UITableViewDataSource,UITableViewDelegate { ...@@ -393,17 +393,19 @@ extension HomeInfoView:UITableViewDataSource,UITableViewDelegate {
let cell = tableView.dequeueReusableCell(withIdentifier: HomeInfoTableViewCell.identifier, for: indexPath) as! HomeInfoTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: HomeInfoTableViewCell.identifier, for: indexPath) as! HomeInfoTableViewCell
cell.saveKeepListFinishedCallback = {[weak self] index in cell.saveKeepListFinishedCallback = {[weak self] index in
guard let self else {return} guard let self else {return}
self.ids?.remove(at: index.section) self.ids?.remove(at:indexPath.row)
self.models.remove(at: index.section) self.models.remove(at:indexPath.row)
DispatchQueue.main.async { DispatchQueue.main.async {
self.setTitleView() self.setTitleView()
} }
// 禁用动画 // 禁用动画
UIView.performWithoutAnimation { UIView.performWithoutAnimation {
tableView.beginUpdates() // tableView.beginUpdates()
tableView.deleteRows(at: [index], with: .fade) // tableView.deleteRows(at: [indexPath], with: .fade)
tableView.endUpdates() // tableView.endUpdates()
tableView.reloadData()
} }
// tableView.reloadData()
if let data = self.ids { if let data = self.ids {
if data.count <= 0 { if data.count <= 0 {
self.keepAllNoDataCallBack() self.keepAllNoDataCallBack()
......
...@@ -82,17 +82,17 @@ class HomeView:UIView { ...@@ -82,17 +82,17 @@ class HomeView:UIView {
viewModel.homeDataChanged = {[weak self] section,row in viewModel.homeDataChanged = {[weak self] section,row in
guard let weakSelf = self else { return } guard let weakSelf = self else { return }
DispatchQueue.main.async { DispatchQueue.main.async {
// if let cell = weakSelf.collectionView.cellForItem(at: IndexPath(row: row, section: section)) as? HomeTitleCollectionCell { if let cell = weakSelf.collectionView.cellForItem(at: IndexPath(row: row, section: section)) as? HomeTitleCollectionCell {
// // 只更新需要改变的内容 // 只更新需要改变的内容
// let model = weakSelf.viewModel.headerGroup[row] let model = weakSelf.viewModel.headerGroup[row]
// cell.reloadUIWithModel(model: model) cell.reloadUIWithModel(model: model)
// } }
// if let cell = weakSelf.collectionView.cellForItem(at: IndexPath(row: row, section: section)) as? HomeOtherCollectionCell { if let cell = weakSelf.collectionView.cellForItem(at: IndexPath(row: row, section: section)) as? HomeOtherCollectionCell {
// // 只更新需要改变的内容 // 只更新需要改变的内容
// let model = weakSelf.viewModel.cardGroup[row] let model = weakSelf.viewModel.cardGroup[row]
// cell.reloadUIWithModel(model: model) cell.reloadUIWithModel(model: model)
// } }
weakSelf.collectionView.reloadData() // weakSelf.collectionView.reloadData()
weakSelf.homeHeader?.progressBar.chaoticProgress = CGFloat(weakSelf.viewModel.totalSize) weakSelf.homeHeader?.progressBar.chaoticProgress = CGFloat(weakSelf.viewModel.totalSize)
weakSelf.reloadHeadSize() weakSelf.reloadHeadSize()
} }
......
...@@ -116,10 +116,11 @@ class HomeInfoTableViewCell:UITableViewCell { ...@@ -116,10 +116,11 @@ class HomeInfoTableViewCell:UITableViewCell {
collectionView?.x = (backView?.x ?? 0) + marginLR collectionView?.x = (backView?.x ?? 0) + marginLR
collectionView?.y = (backView?.y ?? 0) + (backView?.height ?? 0) - (collectionView?.height ?? 0) - 16 collectionView?.y = (backView?.y ?? 0) + (backView?.height ?? 0) - (collectionView?.height ?? 0) - 16
self.collectionView?.reloadData()
UIView.transition(with: collectionView!, duration: 0.3, options: .transitionCrossDissolve, animations: { // UIView.transition(with: collectionView!, duration: 0.3, options: .transitionCrossDissolve, animations: {
self.collectionView?.reloadData() // self.collectionView?.reloadData()
}, completion: nil) // }, completion: nil)
} }
} }
......
...@@ -216,14 +216,13 @@ extension HomeVideoCoverCell{ ...@@ -216,14 +216,13 @@ extension HomeVideoCoverCell{
if videoURL == videoUrl{ if videoURL == videoUrl{
// Print("地址相同,无需刷新") // Print("地址相同,无需刷新")
if videoPlayer.rate == 0{
videoPlayer.play()
}
return return
} }
videoUrl = videoURL videoUrl = videoURL
// if videoPlayer
// Print("地址不同,需刷新")
let item = AVPlayerItem.init(url: videoURL) let item = AVPlayerItem.init(url: videoURL)
videoPlayer.replaceCurrentItem(with: item) videoPlayer.replaceCurrentItem(with: item)
......
...@@ -18,48 +18,65 @@ class HomeVideoDetailCell : UICollectionViewCell { ...@@ -18,48 +18,65 @@ class HomeVideoDetailCell : UICollectionViewCell {
var resourceIdent : AssetModel? { var resourceIdent : AssetModel? {
didSet{ didSet{
// 定义请求选项来获取视频的第一帧
let options = PHImageRequestOptions() guard let model = resourceIdent else{
// 获取当前版本的照片或视频 return
options.version = .current }
// 尽可能快地提供结果
options.deliveryMode = .opportunistic self.backImageView.asset.load(withLocalIdentifier: model.localIdentifier,placeholder: UIImage.init(named: "videosmoren"))
// 允许从iCloud请求
options.isNetworkAccessAllowed = true let sizeKB : Double = Double(model.assetSize / 1000)
// 异步请求 if sizeKB < 1000{
options.isSynchronous = false self.saveSizeLabel.text = String(format: "%.2f KB" ,sizeKB)
// 从 PHAsset 获取 AVAsset }else if sizeKB < (1000 * 1000) && sizeKB > 1000{
if let videoAsset = PhotoAndVideoMananger.mananger.getPHAsssetwithID(ids: [resourceIdent!.localIdentifier]){ self.saveSizeLabel.text = String(format: "%.2f MB" ,sizeKB/1000)
// 使用requestImageForAsset方法请求视频的第一帧图片 }else{
PHImageManager.default().requestImage(for: videoAsset, targetSize: CGSize(width: 400, height: 400), contentMode: PHImageContentMode.aspectFit, options: options) { image, _ in self.saveSizeLabel.text = String(format: "%.2f GB" ,sizeKB/(1000 * 1000))
// 处理获取到的图片
if let thumbnailImage = image {
// 图片大小
let resources = PHAssetResource.assetResources(for: videoAsset)
var assetSize : Int = 0
for resource in resources {
if let fileSize = resource.value(forKey: "fileSize") as? Int64 {
assetSize += Int(fileSize)
}
}
DispatchQueue.main.async {
// 确保在主线程更新UI
self.backImageView.image = thumbnailImage
let sizeKB : Double = Double(assetSize / 1000)
if sizeKB < 1000{
self.saveSizeLabel.text = String(format: "%.2f KB" ,sizeKB)
}else if sizeKB < (1000 * 1000) && sizeKB > 1000{
self.saveSizeLabel.text = String(format: "%.2f MB" ,sizeKB/1000)
}else{
self.saveSizeLabel.text = String(format: "%.2f GB" ,sizeKB/(1000 * 1000))
}
}
} else {
print("无法获取图片")
}
}
} }
// // 定义请求选项来获取视频的第一帧
// let options = PHImageRequestOptions()
// // 获取当前版本的照片或视频
// options.version = .current
// // 尽可能快地提供结果
// options.deliveryMode = .opportunistic
// // 允许从iCloud请求
// options.isNetworkAccessAllowed = true
// // 异步请求
// options.isSynchronous = false
// 从 PHAsset 获取 AVAsset
// if let videoAsset = PhotoAndVideoMananger.mananger.getPHAsssetwithID(ids: [resourceIdent!.localIdentifier]){
// // 使用requestImageForAsset方法请求视频的第一帧图片
// PHImageManager.default().requestImage(for: videoAsset, targetSize: CGSize(width: 400, height: 400), contentMode: PHImageContentMode.aspectFit, options: options) { image, _ in
// // 处理获取到的图片
// if let thumbnailImage = image {
//
// // 图片大小
// let resources = PHAssetResource.assetResources(for: videoAsset)
// var assetSize : Int = 0
// for resource in resources {
// if let fileSize = resource.value(forKey: "fileSize") as? Int64 {
// assetSize += Int(fileSize)
// }
// }
// DispatchQueue.main.async {
// // 确保在主线程更新UI
// self.backImageView.image = thumbnailImage
// let sizeKB : Double = Double(assetSize / 1000)
// if sizeKB < 1000{
// self.saveSizeLabel.text = String(format: "%.2f KB" ,sizeKB)
// }else if sizeKB < (1000 * 1000) && sizeKB > 1000{
// self.saveSizeLabel.text = String(format: "%.2f MB" ,sizeKB/1000)
// }else{
// self.saveSizeLabel.text = String(format: "%.2f GB" ,sizeKB/(1000 * 1000))
// }
// }
// } else {
// print("无法获取图片")
// }
// }
// }
} }
} }
......
...@@ -72,69 +72,74 @@ class ImageSeletedCollectionCell:UICollectionViewCell { ...@@ -72,69 +72,74 @@ class ImageSeletedCollectionCell:UICollectionViewCell {
seletedBtn?.isSelected = model.isSeleted ?? false seletedBtn?.isSelected = model.isSeleted ?? false
} }
let placeImage = model.id?.mediaType == 1 ? "othermoren" : "videosmoren"
if let id = model.id?.localIdentifier{
if let image = model.image { backImageView?.asset.load(withLocalIdentifier: id,placeholder: UIImage.init(named: placeImage))
}else{
DispatchQueue.main.async {[weak self] in backImageView?.image = UIImage.init(named: placeImage)
guard let self else {return}
backImageView?.image = image
}
}else {
DispatchQueue.global().async {[weak self] in
guard let self else {return}
// 如果是图片
if self.photsFileType == .SimilarVideos {
// 定义请求选项来获取视频的第一帧
let options = PHImageRequestOptions()
// 获取当前版本的照片或视频
options.version = .current
// 尽可能快地提供结果
options.deliveryMode = .highQualityFormat
// 允许从iCloud请求
options.isNetworkAccessAllowed = true
// 异步请求
options.isSynchronous = false
// 从 PHAsset 获取 AVAsset
if let videoAsset = PhotoAndVideoMananger.mananger.getPHAsssetwithID(ids: [model.id!.localIdentifier]){
// 使用requestImageForAsset方法请求视频的第一帧图片
PHImageManager.default().requestImage(for: videoAsset, targetSize: CGSize(width: 400, height: 400), contentMode: PHImageContentMode.aspectFit, options: options) { image, _ in
// 处理获取到的图片
if let thumbnailImage = image {
// 使用获取到的图片,例如显示在UIImageView上
DispatchQueue.main.async { [weak self] in
guard let self else {return}
// 确保在主线程更新UI
self.model.image = thumbnailImage
self.backImageView?.image = thumbnailImage
}
} else {
print("无法获取图片")
}
}
}
}else{
if let asset = PhotoAndVideoMananger.mananger.getPHAsssetwithID(ids: [model.id!.localIdentifier]){
let image = PhotoAndVideoMananger.mananger.getImageFromAsset(asset: asset)
model.image = image
DispatchQueue.main.async {[weak self] in
guard let self else {return}
backImageView?.image = image
}
}
}
}
} }
// if let image = model.image {
//
// DispatchQueue.main.async {[weak self] in
//
// guard let self else {return}
//
// backImageView?.image = image
//
// }
//
// }else {
//
// DispatchQueue.global().async {[weak self] in
// guard let self else {return}
// // 如果是图片
// if self.photsFileType == .SimilarVideos {
// // 定义请求选项来获取视频的第一帧
// let options = PHImageRequestOptions()
// // 获取当前版本的照片或视频
// options.version = .current
// // 尽可能快地提供结果
// options.deliveryMode = .highQualityFormat
// // 允许从iCloud请求
// options.isNetworkAccessAllowed = true
// // 异步请求
// options.isSynchronous = false
// // 从 PHAsset 获取 AVAsset
// if let videoAsset = PhotoAndVideoMananger.mananger.getPHAsssetwithID(ids: [model.id!.localIdentifier]){
// // 使用requestImageForAsset方法请求视频的第一帧图片
// PHImageManager.default().requestImage(for: videoAsset, targetSize: CGSize(width: 400, height: 400), contentMode: PHImageContentMode.aspectFit, options: options) { image, _ in
// // 处理获取到的图片
// if let thumbnailImage = image {
// // 使用获取到的图片,例如显示在UIImageView上
// DispatchQueue.main.async { [weak self] in
// guard let self else {return}
// // 确保在主线程更新UI
// self.model.image = thumbnailImage
// self.backImageView?.image = thumbnailImage
// }
// } else {
// print("无法获取图片")
// }
// }
// }
// }else{
// if let asset = PhotoAndVideoMananger.mananger.getPHAsssetwithID(ids: [model.id!.localIdentifier]){
// let image = PhotoAndVideoMananger.mananger.getImageFromAsset(asset: asset)
//
// model.image = image
//
// DispatchQueue.main.async {[weak self] in
//
// guard let self else {return}
//
// backImageView?.image = image
//
// }
// }
// }
// }
// }
} }
} }
......
...@@ -24,33 +24,39 @@ class HomeLaunchView:UIView { ...@@ -24,33 +24,39 @@ class HomeLaunchView:UIView {
func configUI(){ func configUI(){
backgroundColor = UIColor.colorWithHex(hexStr: "#0082FF") // backgroundColor = UIColor.colorWithHex(hexStr: "#0082FF")
self.az_setGradientBackground(with: [UIColor.colorWithHex(hexStr: "#2AB4FF"),UIColor.colorWithHex(hexStr: "#0082FF")], locations: nil, start: CGPoint(x: 0, y: 0), end: CGPoint(x: 0, y: 1))
let logoImage = UIImageView() let logoImage = UIImageView()
logoImage.image = UIImage.init(named: "icon_phone_manager") logoImage.image = UIImage.init(named: "icon_phone_manager")
addSubview(logoImage) addSubview(logoImage)
let nameImage = UIImageView() // let nameImage = UIImageView()
nameImage.image = UIImage.init(named: "icon_phone_manager_name") // nameImage.image = UIImage.init(named: "icon_phone_manager_name")
addSubview(nameImage) // addSubview(nameImage)
addSubview(LaunchingLoop) // addSubview(LaunchingLoop)
logoImage.snp.makeConstraints { make in logoImage.snp.makeConstraints { make in
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.top.equalTo(kSafeAreaInsets.top+150) make.centerY.equalToSuperview()
// make.top.equalTo(kSafeAreaInsets.top+150)
} }
nameImage.snp.makeConstraints { make in // nameImage.snp.makeConstraints { make in
make.centerX.equalToSuperview() // make.centerX.equalToSuperview()
make.top.equalTo(logoImage.snp.bottom).offset(12) // make.top.equalTo(logoImage.snp.bottom).offset(12)
} // }
LaunchingLoop.snp.makeConstraints { make in // LaunchingLoop.snp.makeConstraints { make in
make.centerX.equalToSuperview() // make.centerX.equalToSuperview()
make.width.height.equalTo(150) // make.width.height.equalTo(150)
make.bottom.equalToSuperview().offset(-60 * RScreenH()) // make.bottom.equalToSuperview().offset(-60 * RScreenH())
} // }
} }
...@@ -68,11 +74,11 @@ class HomeLaunchView:UIView { ...@@ -68,11 +74,11 @@ class HomeLaunchView:UIView {
}) })
} }
private lazy var LaunchingLoop: LottieAnimationView = { // private lazy var LaunchingLoop: LottieAnimationView = {
let animationView = LottieAnimationView(name: "launch_loaing") // let animationView = LottieAnimationView(name: "launch_loaing")
animationView.loopMode = .loop // animationView.loopMode = .loop
animationView.play() // animationView.play()
return animationView // return animationView
}() // }()
} }
...@@ -9,6 +9,7 @@ import UIKit ...@@ -9,6 +9,7 @@ import UIKit
import SnapKit import SnapKit
import Lottie import Lottie
import StoreKit import StoreKit
import Kingfisher
class HomePayView:UIView { class HomePayView:UIView {
...@@ -99,7 +100,6 @@ class HomePayView:UIView { ...@@ -99,7 +100,6 @@ class HomePayView:UIView {
lazy var animationView:LottieAnimationView = { lazy var animationView:LottieAnimationView = {
let animationView = LottieAnimationView(name: "iapAnimation") let animationView = LottieAnimationView(name: "iapAnimation")
animationView.loopMode = .loop animationView.loopMode = .loop
return animationView return animationView
...@@ -159,10 +159,17 @@ class HomePayView:UIView { ...@@ -159,10 +159,17 @@ class HomePayView:UIView {
titleLabel2?.sizeToFit() titleLabel2?.sizeToFit()
self.addSubview(animationView) // self.addSubview(animationView)
let webpImage = UIImageView()
if let webpPath = Bundle.main.path(forResource: "pay_animation", ofType: "gif"),
let webpURL = URL(string: "file://" + webpPath) {
webpImage.kf.setImage(with: webpURL)
}
self.addSubview(webpImage)
playAnimationWithDelay() // playAnimationWithDelay()
animationView.snp.makeConstraints { make in webpImage.snp.makeConstraints { make in
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.top.equalTo(titleLabel2!.snp.bottom).offset(40) make.top.equalTo(titleLabel2!.snp.bottom).offset(40)
make.width.equalTo(285.RW()) make.width.equalTo(285.RW())
......
...@@ -29,6 +29,21 @@ class PMShowImgCell: UICollectionViewCell { ...@@ -29,6 +29,21 @@ class PMShowImgCell: UICollectionViewCell {
} }
} }
var model:ImageSeletedCollectionItem?{
didSet{
guard let model = model else{
return
}
scaleImg.localIdentifier = model.id?.localIdentifier
// if let id = model.id.localIdentifier{
// scaleImg.showImg
// }
}
}
lazy var bestResultButton:UIButton = { lazy var bestResultButton:UIButton = {
let button = UIButton(type: .custom) let button = UIButton(type: .custom)
......
...@@ -24,6 +24,19 @@ class PMShowItemCell: UICollectionViewCell { ...@@ -24,6 +24,19 @@ class PMShowItemCell: UICollectionViewCell {
} }
} }
var model:ImageSeletedCollectionItem?{
didSet{
guard let model = model else{
return
}
if let id = model.id?.localIdentifier{
iconV.asset.load(withLocalIdentifier: id)
}
}
}
private lazy var iconV: UIImageView = { private lazy var iconV: UIImageView = {
let ic = UIImageView() let ic = UIImageView()
ic.contentMode = .scaleAspectFill ic.contentMode = .scaleAspectFill
......
...@@ -407,7 +407,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa ...@@ -407,7 +407,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
if collectionView == MaxCollection { if collectionView == MaxCollection {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PMShowImgCellID, for: indexPath) as! PMShowImgCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PMShowImgCellID, for: indexPath) as! PMShowImgCell
cell.icon = self.homeDataSource![indexPath.row].image ?? UIImage() // cell.icon = self.homeDataSource![indexPath.row].image ?? UIImage()
cell.model = homeDataSource?[indexPath.row]
cell.isCurrent = selectSet.contains(indexPath.row) cell.isCurrent = selectSet.contains(indexPath.row)
if let data = self.homeDataSource { if let data = self.homeDataSource {
cell.bestResultButton.isHidden = indexPath.row != 0 || data.count <= 1 || state == .duplicates cell.bestResultButton.isHidden = indexPath.row != 0 || data.count <= 1 || state == .duplicates
...@@ -429,7 +430,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa ...@@ -429,7 +430,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
}else { }else {
if indexPath.row < self.homeDataSource?.count ?? 0 { if indexPath.row < self.homeDataSource?.count ?? 0 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PMShowItemCellID, for: indexPath) as! PMShowItemCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PMShowItemCellID, for: indexPath) as! PMShowItemCell
cell.icon = self.homeDataSource![indexPath.row].image ?? UIImage() // cell.icon = self.homeDataSource![indexPath.row].image ?? UIImage()
cell.model = homeDataSource?[indexPath.row]
cell.isCurrent = selectSet.contains(indexPath.row) //(self.currentIdx == indexPath.row) cell.isCurrent = selectSet.contains(indexPath.row) //(self.currentIdx == indexPath.row)
return cell return cell
} }
...@@ -475,7 +477,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa ...@@ -475,7 +477,8 @@ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDa
}else{ }else{
if indexPath.row < self.homeDataSource?.count ?? 0 { if indexPath.row < self.homeDataSource?.count ?? 0 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PMShowItemCellID, for: indexPath) as! PMShowItemCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PMShowItemCellID, for: indexPath) as! PMShowItemCell
cell.icon = self.homeDataSource![indexPath.row].image ?? UIImage() //cell.icon = self.homeDataSource![indexPath.row].image ?? UIImage()
cell.model = homeDataSource?[indexPath.row]
cell.isCurrent = selectSet.contains(indexPath.row) cell.isCurrent = selectSet.contains(indexPath.row)
return cell return cell
} }
......
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
#import "NSString+Ex.h" #import "NSString+Ex.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "UIView+AZGradient.h"
//
// UIView+AZGradient.h
// AZCategory
//
// Created by Alfred Zhang on 2017/6/29.
// Copyright © 2017年 Alfred Zhang. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (AZGradient)
/* The array of CGColorRef objects defining the color of each gradient
* stop. Defaults to nil. Animatable. */
@property(nullable, copy) NSArray *az_colors;
/* An optional array of NSNumber objects defining the location of each
* gradient stop as a value in the range [0,1]. The values must be
* monotonically increasing. If a nil array is given, the stops are
* assumed to spread uniformly across the [0,1] range. When rendered,
* the colors are mapped to the output colorspace before being
* interpolated. Defaults to nil. Animatable. */
@property(nullable, copy) NSArray<NSNumber *> *az_locations;
/* The start and end points of the gradient when drawn into the layer's
* coordinate space. The start point corresponds to the first gradient
* stop, the end point to the last gradient stop. Both points are
* defined in a unit coordinate space that is then mapped to the
* layer's bounds rectangle when drawn. (I.e. [0,0] is the bottom-left
* corner of the layer, [1,1] is the top-right corner.) The default values
* are [.5,0] and [.5,1] respectively. Both are animatable. */
@property CGPoint az_startPoint;
@property CGPoint az_endPoint;
+ (UIView *_Nullable)az_gradientViewWithColors:(NSArray<UIColor *> *_Nullable)colors locations:(NSArray<NSNumber *> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
- (void)az_setGradientBackgroundWithColors:(NSArray<UIColor *> *_Nullable)colors locations:(NSArray<NSNumber *> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
@end
//
// UIView+AZGradient.m
// AZCategory
//
// Created by Alfred Zhang on 2017/6/29.
// Copyright © 2017年 Alfred Zhang. All rights reserved.
//
#import "UIView+AZGradient.h"
#import <objc/runtime.h>
@implementation UIView (AZGradient)
+ (Class)layerClass {
return [CAGradientLayer class];
}
+ (UIView *)az_gradientViewWithColors:(NSArray<UIColor *> *)colors locations:(NSArray<NSNumber *> *)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint {
UIView *view = [[self alloc] init];
[view az_setGradientBackgroundWithColors:colors locations:locations startPoint:startPoint endPoint:endPoint];
return view;
}
- (void)az_setGradientBackgroundWithColors:(NSArray<UIColor *> *)colors locations:(NSArray<NSNumber *> *)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint {
NSMutableArray *colorsM = [NSMutableArray array];
for (UIColor *color in colors) {
[colorsM addObject:(__bridge id)color.CGColor];
}
self.az_colors = [colorsM copy];
self.az_locations = locations;
self.az_startPoint = startPoint;
self.az_endPoint = endPoint;
}
#pragma mark- Getter&Setter
- (NSArray *)az_colors {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setAz_colors:(NSArray *)colors {
objc_setAssociatedObject(self, @selector(az_colors), colors, OBJC_ASSOCIATION_COPY_NONATOMIC);
if ([self.layer isKindOfClass:[CAGradientLayer class]]) {
[((CAGradientLayer *)self.layer) setColors:self.az_colors];
}
}
- (NSArray<NSNumber *> *)az_locations {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setAz_locations:(NSArray<NSNumber *> *)locations {
objc_setAssociatedObject(self, @selector(az_locations), locations, OBJC_ASSOCIATION_COPY_NONATOMIC);
if ([self.layer isKindOfClass:[CAGradientLayer class]]) {
[((CAGradientLayer *)self.layer) setLocations:self.az_locations];
}
}
- (CGPoint)az_startPoint {
return [objc_getAssociatedObject(self, _cmd) CGPointValue];
}
- (void)setAz_startPoint:(CGPoint)startPoint {
objc_setAssociatedObject(self, @selector(az_startPoint), [NSValue valueWithCGPoint:startPoint], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if ([self.layer isKindOfClass:[CAGradientLayer class]]) {
[((CAGradientLayer *)self.layer) setStartPoint:self.az_startPoint];
}
}
- (CGPoint)az_endPoint {
return [objc_getAssociatedObject(self, _cmd) CGPointValue];
}
- (void)setAz_endPoint:(CGPoint)endPoint {
objc_setAssociatedObject(self, @selector(az_endPoint), [NSValue valueWithCGPoint:endPoint], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if ([self.layer isKindOfClass:[CAGradientLayer class]]) {
[((CAGradientLayer *)self.layer) setEndPoint:self.az_endPoint];
}
}
@end
@implementation UILabel (AZGradient)
+ (Class)layerClass {
return [CAGradientLayer class];
}
@end
...@@ -19,6 +19,20 @@ class PMScaleImageView: UIView , UIScrollViewDelegate { ...@@ -19,6 +19,20 @@ class PMScaleImageView: UIView , UIScrollViewDelegate {
setup() setup()
} }
var localIdentifier:String?{
didSet {
guard let localIdentifier = localIdentifier else{
return
}
showImg.asset.load(withLocalIdentifier: localIdentifier) {[weak self] image in
guard let weakSelf = self else { return }
weakSelf.icon = image
}
}
}
var icon:UIImage? { var icon:UIImage? {
didSet { didSet {
showImg.image = icon showImg.image = icon
...@@ -54,7 +68,7 @@ class PMScaleImageView: UIView , UIScrollViewDelegate { ...@@ -54,7 +68,7 @@ class PMScaleImageView: UIView , UIScrollViewDelegate {
} }
} }
private lazy var showImg: UIImageView = { lazy var showImg: UIImageView = {
let iv = UIImageView() let iv = UIImageView()
iv.contentMode = .scaleAspectFill iv.contentMode = .scaleAspectFill
scroll.addSubview(iv) scroll.addSubview(iv)
......
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