Commit 1a939e25 authored by shenyong's avatar shenyong

垃圾桶页面

parent 401a24cd
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -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 SwiftyGif
class HomePayView:UIView { class HomePayView:UIView {
...@@ -16,10 +17,10 @@ class HomePayView:UIView { ...@@ -16,10 +17,10 @@ class HomePayView:UIView {
private var closeBtn:UIButton? private var closeBtn:UIButton?
private var titleLabel1:UILabel? private var titleLabel1:UILabel?
private var titleLabel2:UILabel? private var titleLabel2:UILabel?
private var photoImage:UIImageView! // private var photoImage:UIImageView!
private var icloudImage:UIImageView! // private var icloudImage:UIImageView!
private var photoLabel:UILabel? // private var photoLabel:UILabel?
private var icloudLabel:UILabel? // private var icloudLabel:UILabel?
// private var animationLabel:UILabel? // private var animationLabel:UILabel?
private var contentView2:UIView? private var contentView2:UIView?
private var contentView2Title:UILabel? private var contentView2Title:UILabel?
...@@ -41,7 +42,7 @@ class HomePayView:UIView { ...@@ -41,7 +42,7 @@ class HomePayView:UIView {
private var trailTitle:UILabel! private var trailTitle:UILabel!
private var tipsView:UIView! private var tipsView:UIView!
private var memSize:UILabel! private var memSize:UILabel!
var sizeLabel:UILabel! // var sizeLabel:UILabel!
var type = 0 { var type = 0 {
didSet { didSet {
...@@ -98,16 +99,16 @@ class HomePayView:UIView { ...@@ -98,16 +99,16 @@ class HomePayView:UIView {
}() }()
lazy var animationView:LottieAnimationView = { // lazy var animationView:LottieAnimationView = {
//
let animationView = LottieAnimationView(name: "onboardingStorageLight") // let animationView = LottieAnimationView(name: "onboardingStorageLight")
//
animationView.animationSpeed = -1.0 // animationView.animationSpeed = -1.0
animationView.layer.cornerRadius = 8 // animationView.layer.cornerRadius = 8
animationView.contentMode = .scaleAspectFill // animationView.contentMode = .scaleAspectFill
animationView.clipsToBounds = true // animationView.clipsToBounds = true
return animationView // return animationView
}() // }()
var callBack:callBack<Any> = {text in} var callBack:callBack<Any> = {text in}
...@@ -162,89 +163,92 @@ class HomePayView:UIView { ...@@ -162,89 +163,92 @@ class HomePayView:UIView {
titleLabel2?.sizeToFit() titleLabel2?.sizeToFit()
photoImage = UIImageView(image: UIImage(named: "img_photos_start"))
self.addSubview(photoImage)
photoImage.snp.makeConstraints { make in
make.top.equalTo(titleLabel2!.snp.bottom).offset(38.RH())
make.left.equalTo(48.RW())
make.size.equalTo(64.RW())
}
icloudImage = UIImageView(image: UIImage(named: "img_file_guide"))
self.addSubview(icloudImage)
icloudImage.snp.makeConstraints { make in
make.left.equalTo(photoImage.snp.right).offset(24.RW())
make.centerY.equalTo(photoImage)
make.size.equalTo(64.RW())
}
photoLabel = UILabel()
photoLabel?.text = "403"
photoLabel?.backgroundColor = UIColor.colorWithHex(hexStr: "#EB4545")
photoLabel?.font = UIFont.scaledSystemFont(ofSize: 10, weight: .bold)
photoLabel?.textAlignment = .center
photoLabel?.textColor = .white
photoLabel?.layer.cornerRadius = 12.RW()
photoLabel?.layer.masksToBounds = true
self.addSubview(photoLabel!)
photoLabel?.snp.makeConstraints { make in
make.top.equalTo(photoImage.snp.top).offset(-12)
make.right.equalTo(photoImage.snp.right).offset(12)
make.size.equalTo(24.RW())
}
photoLabel?.sizeToFit()
icloudLabel = UILabel()
icloudLabel?.text = "217"
icloudLabel?.textAlignment = .center
icloudLabel?.font = UIFont.scaledSystemFont(ofSize: 10, weight: .bold)
icloudLabel?.backgroundColor = UIColor.colorWithHex(hexStr: "#EB4545")
icloudLabel?.textColor = .white
icloudLabel?.layer.cornerRadius = 12.RW()
icloudLabel?.layer.masksToBounds = true
self.addSubview(icloudLabel!)
icloudLabel?.snp.makeConstraints { make in
make.top.equalTo(icloudImage.snp.top).offset(-12)
make.right.equalTo(icloudImage.snp.right).offset(12)
make.size.equalTo(24.RW())
}
icloudLabel?.sizeToFit()
self.addSubview(animationView)
playAnimationWithDelay() // photoImage = UIImageView(image: UIImage(named: "img_photos_start"))
animationView.snp.makeConstraints { make in // self.addSubview(photoImage)
make.top.equalTo(icloudImage!.snp.bottom).offset(24) //
make.centerX.equalToSuperview() // photoImage.snp.makeConstraints { make in
make.width.equalTo(280) // make.top.equalTo(titleLabel2!.snp.bottom).offset(38.RH())
make.height.equalTo(12.RW()) // make.left.equalTo(48.RW())
} // make.size.equalTo(64.RW())
// }
let analysis = UILabel() //
analysis.text = "Analysis completed" // icloudImage = UIImageView(image: UIImage(named: "img_file_guide"))
analysis.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3") // self.addSubview(icloudImage)
analysis.font = UIFont.scaledSystemFont(ofSize: 14, weight: .bold) //
addSubview(analysis) // icloudImage.snp.makeConstraints { make in
analysis.snp.makeConstraints { make in // make.left.equalTo(photoImage.snp.right).offset(24.RW())
make.left.equalTo(animationView.snp.left) // make.centerY.equalTo(photoImage)
make.top.equalTo(animationView.snp.bottom).offset(8) // make.size.equalTo(64.RW())
} // }
//
memSize = UILabel() // photoLabel = UILabel()
memSize.text = "100%" // photoLabel?.text = "403"
memSize.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3") // photoLabel?.backgroundColor = UIColor.colorWithHex(hexStr: "#EB4545")
memSize.font = UIFont.scaledSystemFont(ofSize: 14, weight: .bold) // photoLabel?.font = UIFont.scaledSystemFont(ofSize: 10, weight: .bold)
addSubview(memSize) // photoLabel?.textAlignment = .center
memSize.snp.makeConstraints { make in // photoLabel?.textColor = .white
make.right.equalTo(animationView.snp.right) // photoLabel?.layer.cornerRadius = 12.RW()
make.top.equalTo(animationView.snp.bottom).offset(8) // photoLabel?.layer.masksToBounds = true
} // self.addSubview(photoLabel!)
//
// photoLabel?.snp.makeConstraints { make in
// make.top.equalTo(photoImage.snp.top).offset(-12)
// make.right.equalTo(photoImage.snp.right).offset(12)
// make.size.equalTo(24.RW())
// }
//
// photoLabel?.sizeToFit()
//
// icloudLabel = UILabel()
// icloudLabel?.text = "217"
// icloudLabel?.textAlignment = .center
// icloudLabel?.font = UIFont.scaledSystemFont(ofSize: 10, weight: .bold)
// icloudLabel?.backgroundColor = UIColor.colorWithHex(hexStr: "#EB4545")
// icloudLabel?.textColor = .white
// icloudLabel?.layer.cornerRadius = 12.RW()
// icloudLabel?.layer.masksToBounds = true
// self.addSubview(icloudLabel!)
//
// icloudLabel?.snp.makeConstraints { make in
// make.top.equalTo(icloudImage.snp.top).offset(-12)
// make.right.equalTo(icloudImage.snp.right).offset(12)
// make.size.equalTo(24.RW())
// }
//
// icloudLabel?.sizeToFit()
//
// self.addSubview(animationView)
//
// playAnimationWithDelay()
// animationView.snp.makeConstraints { make in
// make.top.equalTo(icloudImage!.snp.bottom).offset(24)
// make.centerX.equalToSuperview()
// make.width.equalTo(280)
// make.height.equalTo(12.RW())
// }
//
// let analysis = UILabel()
// analysis.text = "Analysis completed"
// analysis.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3")
// analysis.font = UIFont.scaledSystemFont(ofSize: 14, weight: .bold)
// addSubview(analysis)
// analysis.snp.makeConstraints { make in
// make.left.equalTo(animationView.snp.left)
// make.top.equalTo(animationView.snp.bottom).offset(8)
// }
//
// memSize = UILabel()
// memSize.text = "100%"
// memSize.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3")
// memSize.font = UIFont.scaledSystemFont(ofSize: 14, weight: .bold)
// addSubview(memSize)
// memSize.snp.makeConstraints { make in
// make.right.equalTo(animationView.snp.right)
// make.top.equalTo(animationView.snp.bottom).offset(8)
// }
appleLabel = UILabel() appleLabel = UILabel()
...@@ -328,7 +332,7 @@ class HomePayView:UIView { ...@@ -328,7 +332,7 @@ class HomePayView:UIView {
privavye_Label.snp.makeConstraints { make in privavye_Label.snp.makeConstraints { make in
make.left.right.equalTo(self.contentView2!) make.left.right.equalTo(self.contentView2!)
make.top.equalTo(ppBtn.snp.bottom).offset(15) make.top.equalTo(ppBtn.snp.bottom).offset(15.RH())
make.bottom.equalToSuperview().offset(-10) make.bottom.equalToSuperview().offset(-10)
} }
self.layoutIfNeeded() self.layoutIfNeeded()
...@@ -336,20 +340,65 @@ class HomePayView:UIView { ...@@ -336,20 +340,65 @@ class HomePayView:UIView {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
self.callBack(CommonPush.change) self.callBack(CommonPush.change)
} }
}
func playAnimationWithDelay() {
// 播放动画
animationView.play(fromProgress: 0.4, toProgress: 1, loopMode: .playOnce) {[weak self] finished in // if let url = Bundle.main.url(forResource: "iap", withExtension: "gif"),
if finished { // let data = try? Data(contentsOf: url) {
// 动画播放完成后,延迟 2 秒再重新播放 // let animatedImage = FLAnimatedImage(animatedGIFData: data)
DispatchQueue.main.asyncAfter(deadline: .now() + 2) { // let imageView = FLAnimatedImageView()
self?.playAnimationWithDelay() // imageView.animatedImage = animatedImage
} // imageView.startAnimating()
// addSubview(imageView)
//
// imageView.snp.makeConstraints { make in
// make.centerX.equalToSuperview()
// make.top.equalTo(titleLabel2!.snp.bottom).offset(40)
// make.width.equalTo(285.RW())
// make.height.equalTo(142.RW())
// }
// }
let gifImageView = UIImageView()
gifImageView.contentMode = .scaleAspectFit
addSubview(gifImageView)
gifImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(titleLabel2!.snp.bottom).offset(40)
make.width.equalTo(285.RW())
make.height.equalTo(142.RW())
} }
// 从 Bundle 加载 GIF 文件
guard let gifImage = try? UIImage(gifName: "iap.gif") else {
print("Failed to load GIF")
return
} }
gifImageView.setGifImage(gifImage, loopCount: -1)
gifImageView.startAnimatingGif()
// gifImageView.startAnimatingGif()
// // 设置 GIF 到 ImageView 并开始播放
// do {
// try gifImageView.setGifImage(gifImage, loopCount: 0) // 0 表示无限循环
// } catch {
// print("Error setting GIF: \(error)")
// }
} }
// func playAnimationWithDelay() {
// // 播放动画
// animationView.play(fromProgress: 0.4, toProgress: 1, loopMode: .playOnce) {[weak self] finished in
// if finished {
// // 动画播放完成后,延迟 2 秒再重新播放
// DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
// self?.playAnimationWithDelay()
// }
// }
// }
// }
lazy var privavye_Label: UILabel = { lazy var privavye_Label: UILabel = {
let priva = UILabel() let priva = UILabel()
priva.font = UIFont.scaledSystemFont(ofSize: 14, weight: .regular) priva.font = UIFont.scaledSystemFont(ofSize: 14, weight: .regular)
...@@ -499,48 +548,48 @@ class HomePayView:UIView { ...@@ -499,48 +548,48 @@ class HomePayView:UIView {
} }
tipsView.snp.makeConstraints { make in tipsView.snp.makeConstraints { make in
make.top.equalTo(animationView.snp.bottom).offset(92.RH()) make.top.equalTo(titleLabel2!.snp.bottom).offset(230.RH())
make.left.right.equalToSuperview().inset(12) make.left.right.equalToSuperview().inset(12)
make.height.equalTo(110.RH()) make.height.equalTo(110.RH())
} }
let freespace = UILabel() // let freespace = UILabel()
freespace.font = UIFont.scaledSystemFont(ofSize: 12, weight: .bold) // freespace.font = UIFont.scaledSystemFont(ofSize: 12, weight: .bold)
freespace.text = "FREE SPACE" // freespace.text = "FREE SPACE"
freespace.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3") // freespace.textColor = UIColor.colorWithHex(hexStr: "#B3B3B3")
addSubview(freespace) // addSubview(freespace)
//
sizeLabel = UILabel() // sizeLabel = UILabel()
sizeLabel.text = "54.2 GB" // sizeLabel.text = "54.2 GB"
sizeLabel.textColor = UIColor.colorWithHex(hexStr: black3Color) // sizeLabel.textColor = UIColor.colorWithHex(hexStr: black3Color)
sizeLabel.font = UIFont.scaledSystemFont(ofSize: 12, weight: .bold) // sizeLabel.font = UIFont.scaledSystemFont(ofSize: 12, weight: .bold)
addSubview(sizeLabel) // addSubview(sizeLabel)
//
freespace.snp.makeConstraints { make in // freespace.snp.makeConstraints { make in
make.left.equalTo(icloudImage!.snp.right).offset(24.RW()) // make.left.equalTo(icloudImage!.snp.right).offset(24.RW())
make.top.equalTo(titleLabel2!.snp.bottom).offset(42) // make.top.equalTo(titleLabel2!.snp.bottom).offset(42)
make.height.equalTo(17.RW()) // make.height.equalTo(17.RW())
} // }
//
sizeLabel.snp.makeConstraints { make in // sizeLabel.snp.makeConstraints { make in
make.top.equalTo(freespace.snp.bottom).offset(0) // make.top.equalTo(freespace.snp.bottom).offset(0)
make.left.equalTo(icloudImage!.snp.right).offset(24) // make.left.equalTo(icloudImage!.snp.right).offset(24)
make.height.equalTo(39.RW()) // make.height.equalTo(39.RW())
} // }
//
let fullText = FileTool().formatBytes(FileTool().getStorageInfo(for: .free) ?? 0 ) // let fullText = FileTool().formatBytes(FileTool().getStorageInfo(for: .free) ?? 0 )
// 创建一个可变的富文本字符串 // // 创建一个可变的富文本字符串
let attributedString = NSMutableAttributedString(string: fullText) // let attributedString = NSMutableAttributedString(string: fullText)
// 设置前半部分(动态数值)的范围 // // 设置前半部分(动态数值)的范围
let regularFont = UIFont.scaledSystemFont(ofSize: 28, weight: .bold) // 设置常规字体大小 // let regularFont = UIFont.scaledSystemFont(ofSize: 28, weight: .bold) // 设置常规字体大小
attributedString.addAttribute(.font, value: regularFont, range: NSRange.init(location: 0,length:fullText.count-2)) // attributedString.addAttribute(.font, value: regularFont, range: NSRange.init(location: 0,length:fullText.count-2))
//
// 设置“GB”部分的范围并将字体大小设置为12 // // 设置“GB”部分的范围并将字体大小设置为12
let smallFont = UIFont.scaledSystemFont(ofSize: 12, weight: .bold) // 设置字体大小为12 // let smallFont = UIFont.scaledSystemFont(ofSize: 12, weight: .bold) // 设置字体大小为12
attributedString.addAttribute(.font, value: smallFont, range:NSRange.init(location: fullText.count-2, length: 2)) // attributedString.addAttribute(.font, value: smallFont, range:NSRange.init(location: fullText.count-2, length: 2))
//
// 将富文本赋值给UILabel // // 将富文本赋值给UILabel
sizeLabel.attributedText = attributedString // sizeLabel.attributedText = attributedString
payDueView.snp.makeConstraints { make in payDueView.snp.makeConstraints { make in
......
...@@ -36,7 +36,7 @@ class HomePayViewController:UIViewController { ...@@ -36,7 +36,7 @@ class HomePayViewController:UIViewController {
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated) super.viewDidAppear(animated)
homePayView?.playAnimationWithDelay() // homePayView?.playAnimationWithDelay()
} }
override func viewDidDisappear(_ animated: Bool) { override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated) super.viewDidDisappear(animated)
......
...@@ -34,6 +34,23 @@ class PMShowImgVideoController: BaseViewController { ...@@ -34,6 +34,23 @@ class PMShowImgVideoController: BaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
configUI()
}
func configUI(){
// 垃圾桶临时入口
let trashBtn = UIButton()
trashBtn.setTitle("trash", for: .normal)
trashBtn.setTitleColor(.black, for: .normal)
trashBtn.addTarget(self, action: #selector(pushToTrash), for: .touchUpInside)
titleView.addSubview(trashBtn)
trashBtn.snp.makeConstraints { make in
make.right.equalTo(-16)
make.centerY.equalTo(titleView.titleLabel)
}
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -84,6 +101,14 @@ class PMShowImgVideoController: BaseViewController { ...@@ -84,6 +101,14 @@ class PMShowImgVideoController: BaseViewController {
view.addSubview(col) view.addSubview(col)
return col return col
}() }()
@objc func pushToTrash(){
let vc = TrashViewController()
self.present(vc, animated: true)
}
} }
extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{ extension PMShowImgVideoController : UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{
......
//
// TrashViewController.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import UIKit
class TrashViewController: UIViewController {
var source:[TrashTypeEnum] = [.video,.other,.shot,.chat]
var contentH:CGFloat = 0
var contentScrollView:UIScrollView!
var delBtn:UIButton!
var currentType:TrashTypeEnum = .other
let pageCount = 4 // 总页数
var currentPage = 1
override func viewDidLoad() {
super.viewDidLoad()
configUI()
}
func configUI(){
view.backgroundColor = .white
contentScrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: ScreenW, height: contentH))
contentScrollView.contentSize = CGSize(width: ScreenW*4, height: view.height)
contentScrollView.isPagingEnabled = true
contentScrollView.showsHorizontalScrollIndicator = false
contentScrollView.showsVerticalScrollIndicator = false
contentScrollView.bounces = false
contentScrollView.delegate = self
contentScrollView.backgroundColor = UIColor.white
view.addSubview(contentScrollView)
delBtn = UIButton()
delBtn.setTitle("Delete", for: .normal)
delBtn.setTitleColor(.white, for: .normal)
delBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
delBtn.backgroundColor = UIColor.colorWithHex(hexStr: "#0082FF")
delBtn.layer.cornerRadius = 10
view.addSubview(delBtn)
delBtn.snp.makeConstraints { make in
make.bottom.equalTo(-17)
make.left.right.equalToSuperview().inset(55)
make.height.equalTo(40)
}
let closeBtn = UIButton()
closeBtn.setImage(UIImage.init(named: "icon_close_bottom"), for: .normal)
view.addSubview(closeBtn)
closeBtn.snp.makeConstraints { make in
make.left.equalTo(16)
make.top.equalTo(12)
make.size.equalTo(18)
}
contentScrollView.addSubview(videoView)
contentScrollView.addSubview(otherView)
contentScrollView.addSubview(shotView)
contentScrollView.addSubview(chatView)
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
let viewWidth = self.view.bounds.width
let viewHeight = self.view.bounds.height
contentH = viewHeight - 108
contentScrollView.frame = CGRect(x: 0, y: 34, width: viewWidth, height: contentH)
contentScrollView.contentSize = CGSize(width: viewWidth*4, height: contentH)
videoView.frame = CGRect(x: 0, y: 0, width: viewWidth, height: contentH)
otherView.frame = CGRect(x: viewWidth, y: 0, width: viewWidth, height: contentH)
shotView.frame = CGRect(x: viewWidth*2, y: 0, width: viewWidth, height: contentH)
chatView.frame = CGRect(x: viewWidth*3, y: 0, width: viewWidth, height: contentH)
}
lazy var videoView:TrashContenView = {
let videoView = TrashContenView()
videoView.trashType = .video
return videoView
}()
lazy var otherView:TrashContenView = {
let otherView = TrashContenView()
otherView.trashType = .other
return otherView
}()
lazy var shotView:TrashContenView = {
let shotView = TrashContenView()
shotView.trashType = .shot
return shotView
}()
lazy var chatView:TrashContenView = {
let chatView = TrashContenView()
chatView.trashType = .chat
return chatView
}()
lazy var collectionView:UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: view.width, height: view.height)
layout.scrollDirection = .horizontal
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: view.width, height: view.height), collectionViewLayout:layout)
collectionView.isPagingEnabled = true
collectionView.delegate = self
collectionView.backgroundColor = .white
collectionView.dataSource = self
collectionView.register(UINib(nibName: "TrashContenViewCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenViewCell0")
collectionView.register(UINib(nibName: "TrashContenViewCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenViewCell1")
collectionView.register(UINib(nibName: "TrashContenViewCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenViewCell2")
collectionView.register(UINib(nibName: "TrashContenViewCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenViewCell3")
return collectionView
}()
}
extension TrashViewController:UICollectionViewDelegate,UICollectionViewDataSource{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return source.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TrashContenViewCell\(indexPath.row)", for: indexPath) as! TrashContenViewCell
cell.trashType = source[indexPath.row]
return cell
}
}
extension TrashViewController:UIScrollViewDelegate{
func scrollViewDidScroll(_ scrollView: UIScrollView){
let offset = scrollView.contentOffset.x
print("滑动距离",offset)
let model = TrashPageScrollModel.init(offset: offset,page: currentPage)
NotificationCenter.default.post(name: .trashPageScroll, object: model)
}
// 当用户手指离开屏幕且滚动减速停止时调用
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let currentPage = Int(scrollView.contentOffset.x / scrollView.bounds.width)
print("当前页: \(currentPage + 1)/\(pageCount)")
self.currentPage = currentPage + 1
}
// 当使用 setContentOffset 或 scrollToRect 等方法触发的滚动动画结束时调用
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
let currentPage = Int(scrollView.contentOffset.x / scrollView.bounds.width)
print("当前页: \(currentPage + 1)/\(pageCount)")
self.currentPage = currentPage + 1
}
}
//
// TrashUIModel.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import Foundation
enum TrashTypeEnum{
case video,other,shot,chat
}
struct TrashPageScrollModel{
var offset:CGFloat = 0
var page:Int = 1
}
//
// TrashContenAssetCell.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import UIKit
class TrashContenAssetCell: UICollectionViewCell {
@IBOutlet weak var assetImage: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
}
override func layoutSubviews() {
super.layoutSubviews()
assetImage.cornerCut(radius: 8, corner: .allCorners)
}
@IBAction func removeClick(_ sender: Any) {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="TrashContenAssetCell" customModule="PhoneManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="138" height="145"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="138" height="145"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="eLJ-qj-i27">
<rect key="frame" x="0.0" y="0.0" width="138" height="145"/>
<color key="backgroundColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="u7L-fz-1My">
<rect key="frame" x="110" y="0.0" width="28" height="34"/>
<constraints>
<constraint firstAttribute="width" constant="28" id="8iF-C1-mzq"/>
<constraint firstAttribute="height" constant="34" id="Yde-4P-yCb"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="icon_trash_remove"/>
<connections>
<action selector="removeClick:" destination="gTV-IL-0wX" eventType="touchUpInside" id="Kdg-c7-RsH"/>
</connections>
</button>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="eLJ-qj-i27" secondAttribute="trailing" id="0rT-cN-YvO"/>
<constraint firstItem="u7L-fz-1My" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Ma5-yx-gre"/>
<constraint firstItem="eLJ-qj-i27" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Qwo-N1-6WM"/>
<constraint firstAttribute="trailing" secondItem="u7L-fz-1My" secondAttribute="trailing" id="Toq-Ra-cSL"/>
<constraint firstAttribute="bottom" secondItem="eLJ-qj-i27" secondAttribute="bottom" id="Yz5-xE-glP"/>
<constraint firstItem="eLJ-qj-i27" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="mnv-e0-PKX"/>
</constraints>
<size key="customSize" width="138" height="145"/>
<connections>
<outlet property="assetImage" destination="eLJ-qj-i27" id="KYz-cL-qDY"/>
</connections>
<point key="canvasLocation" x="155.72519083969465" y="53.169014084507047"/>
</collectionViewCell>
</objects>
<resources>
<image name="icon_trash_remove" width="16" height="16"/>
</resources>
</document>
//
// TrashContenTitleCell.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import UIKit
class TrashContenTitleCell: UICollectionViewCell {
@IBOutlet weak var title: UILabel!
@IBOutlet weak var contentL: UILabel!
var lineOne: UIView!
var lineTwo: UIView!
var lineThree: UIView!
var lineFour: UIView!
var scrollLine:UIView!
let lineW:CGFloat = (ScreenW - 62) / 4.0
let selectColor:UIColor = UIColor.colorWithHex(hexStr: "#0082FF")
let normalColor:UIColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
var trashType:TrashTypeEnum = .video{
didSet{
switch trashType {
case .video:
scrollLine.frame = lineOne.frame
case .other:
scrollLine.frame = lineTwo.frame
case .shot:
scrollLine.frame = lineThree.frame
case .chat:
scrollLine.frame = lineFour.frame
}
}
}
override func awakeFromNib() {
super.awakeFromNib()
lineOne = UIView()
lineOne.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
addSubview(lineOne)
lineTwo = UIView()
lineTwo.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
addSubview(lineTwo)
lineThree = UIView()
lineThree.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
addSubview(lineThree)
lineFour = UIView()
lineFour.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
addSubview(lineFour)
lineOne.frame = CGRect(x: 16, y: 62, width: lineW, height: 6)
lineTwo.frame = CGRect(x: 10+lineOne.rightX, y: 62, width: lineW, height: 6)
lineThree.frame = CGRect(x: 10+lineTwo.rightX, y: 62, width: lineW, height: 6)
lineFour.frame = CGRect(x: 10+lineThree.rightX, y: 62, width: lineW, height: 6)
scrollLine = UIView()
scrollLine.backgroundColor = UIColor.colorWithHex(hexStr: "#0082FF")
scrollLine.frame = lineOne.frame
addSubview(scrollLine)
scrollLine.cornerCut(radius: 2, corner: .allCorners)
NotificationCenter.default.addObserver(forName: .trashPageScroll, object: nil, queue: nil) {[weak self] notif in
guard let weakSelf = self else { return }
guard let offset = notif.object as? CGFloat else{
return
}
switch weakSelf.trashType {
case .video:
if offset > 0{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
}else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineOne.frame
}
}
case .other:
if offset > ScreenW{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
}
else if offset == ScreenW{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
}
else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineOne.frame
}
}
case .shot:
if offset > ScreenW * 2{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineFour.frame
}
}
else if offset == ScreenW * 2{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
}
else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
}
case .chat:
if offset < ScreenW * 3{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
}else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineFour.frame
}
}
}
}
}
override func layoutSubviews() {
super.layoutSubviews()
}
// func reset(){
// lineOne.backgroundColor = trashType.normalColor
// lineTwo.backgroundColor = trashType.normalColor
// lineThree.backgroundColor = trashType.normalColor
// lineFour.backgroundColor = trashType.normalColor
// }
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="TrashContenTitleCell" customModule="PhoneManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="367" height="96"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="367" height="96"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2ql-I6-tLt">
<rect key="frame" x="0.0" y="0.0" width="367" height="84"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Trash Can · Video" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Ks-xQ-36T">
<rect key="frame" x="16" y="0.0" width="162" height="24"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="20"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1 video · 156.9MB" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ded-ac-qdM">
<rect key="frame" x="16" y="28" width="133.66666666666666" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="vHf-wv-0RL"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="8Ks-xQ-36T" firstAttribute="leading" secondItem="2ql-I6-tLt" secondAttribute="leading" constant="16" id="D5d-JF-WWs"/>
<constraint firstItem="8Ks-xQ-36T" firstAttribute="top" secondItem="2ql-I6-tLt" secondAttribute="top" id="Ost-JT-11u"/>
<constraint firstItem="ded-ac-qdM" firstAttribute="top" secondItem="8Ks-xQ-36T" secondAttribute="bottom" constant="4" id="RUR-iU-J2f"/>
<constraint firstItem="ded-ac-qdM" firstAttribute="leading" secondItem="2ql-I6-tLt" secondAttribute="leading" constant="16" id="rpq-9I-gZF"/>
</constraints>
</view>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.96470588235294119" blue="0.9882352941176471" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="2ql-I6-tLt" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="VTc-X8-1c5"/>
<constraint firstAttribute="trailing" secondItem="2ql-I6-tLt" secondAttribute="trailing" id="fR2-bt-dJM"/>
<constraint firstAttribute="bottom" secondItem="2ql-I6-tLt" secondAttribute="bottom" constant="12" id="huu-EZ-MHP"/>
<constraint firstItem="2ql-I6-tLt" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="lgE-St-BlS"/>
</constraints>
<size key="customSize" width="367" height="96"/>
<connections>
<outlet property="contentL" destination="ded-ac-qdM" id="il0-p1-cJv"/>
<outlet property="title" destination="8Ks-xQ-36T" id="Zql-BY-4sx"/>
</connections>
<point key="canvasLocation" x="330.53435114503816" y="35.91549295774648"/>
</collectionViewCell>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// TrashContenView.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import UIKit
class TrashContenView: UIView {
var collectionView: UICollectionView!
var typeLabel:UILabel!
var sizeLabel:UILabel!
var lineOne: UIView!
var lineTwo: UIView!
var lineThree: UIView!
var lineFour: UIView!
var scrollLine:UIView!
let lineW:CGFloat = (ScreenW - 62) / 4.0
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
configUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func configUI(){
let layout = UICollectionViewFlowLayout()
layout.minimumInteritemSpacing = 12
layout.minimumLineSpacing = 12
layout.sectionInset = UIEdgeInsets(top: 20, left: 16, bottom: 0, right: 16)
layout.itemSize = CGSize(width: (ScreenW-56)/3, height: (ScreenW-56)/3)
collectionView = UICollectionView.init(frame: CGRect.zero,collectionViewLayout: layout)
collectionView.delegate = self
collectionView.backgroundColor = UIColor.colorWithHex(hexStr: "#F2F6FC")
collectionView.dataSource = self
collectionView.register(UINib(nibName: "TrashContenAssetCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenAssetCell")
// collectionView.register(UINib(nibName: "TrashContenTitleCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenTitleCell")
addSubview(collectionView)
let topView = UIView()
topView.backgroundColor = .white
addSubview(topView)
topView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(82)
}
typeLabel = UILabel()
typeLabel.text = "Trash Can · Video"
typeLabel.textColor = .black
typeLabel.font = UIFont.systemFont(ofSize: 20, weight: .medium)
topView.addSubview(typeLabel)
sizeLabel = UILabel()
sizeLabel.text = "1 video · 156.9MB"
sizeLabel.textColor = UIColor.colorWithHex(hexStr: "#666666")
sizeLabel.font = UIFont.systemFont(ofSize: 16, weight: .medium)
topView.addSubview(sizeLabel)
typeLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.top.equalTo(0)
}
sizeLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.top.equalTo(30)
}
collectionView.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview()
make.top.equalTo(sizeLabel.snp.bottom).offset(32)
}
lineOne = UIView()
lineOne.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
topView.addSubview(lineOne)
lineTwo = UIView()
lineTwo.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
topView.addSubview(lineTwo)
lineThree = UIView()
lineThree.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
topView.addSubview(lineThree)
lineFour = UIView()
lineFour.backgroundColor = UIColor.colorWithHex(hexStr: "#E5E5E5")
topView.addSubview(lineFour)
lineOne.frame = CGRect(x: 16, y: 62, width: lineW, height: 6)
lineTwo.frame = CGRect(x: 10+lineOne.rightX, y: 62, width: lineW, height: 6)
lineThree.frame = CGRect(x: 10+lineTwo.rightX, y: 62, width: lineW, height: 6)
lineFour.frame = CGRect(x: 10+lineThree.rightX, y: 62, width: lineW, height: 6)
scrollLine = UIView()
scrollLine.backgroundColor = UIColor.colorWithHex(hexStr: "#0082FF")
scrollLine.frame = lineOne.frame
topView.addSubview(scrollLine)
NotificationCenter.default.addObserver(forName: .trashPageScroll, object: nil, queue: nil) {[weak self] notif in
guard let weakSelf = self else { return }
guard let model = notif.object as? TrashPageScrollModel else{
return
}
let offset = model.offset
let page = model.page
switch weakSelf.trashType {
case .video:
if page == 1{
if offset > 0{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
}else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineOne.frame
}
}
}else{
weakSelf.scrollLine.frame = weakSelf.lineOne.frame
}
case .other:
if page == 2{
if offset > ScreenW{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
}
else if offset == ScreenW{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
}
else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineOne.frame
}
}
}else{
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
case .shot:
if page == 3{
if offset > ScreenW * 2{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineFour.frame
}
}
else if offset == ScreenW * 2{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
}
else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineTwo.frame
}
}
}else{
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
case .chat:
if page == 4{
if offset < ScreenW * 3{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineThree.frame
}
}else{
UIView.animate(withDuration: 0.2) {
weakSelf.scrollLine.frame = weakSelf.lineFour.frame
}
}
}else{
weakSelf.scrollLine.frame = weakSelf.lineFour.frame
}
}
}
}
override func layoutSubviews() {
super.layoutSubviews()
scrollLine.cornerCut(radius: 2, corner: .allCorners)
lineOne.cornerCut(radius: 2, corner: .allCorners)
lineTwo.cornerCut(radius: 2, corner: .allCorners)
lineThree.cornerCut(radius: 2, corner: .allCorners)
lineFour.cornerCut(radius: 2, corner: .allCorners)
// collectionView.frame = self.bounds
}
var trashType:TrashTypeEnum = .video{
didSet{
switch trashType {
case .video:
scrollLine.frame = lineOne.frame
case .other:
scrollLine.frame = lineTwo.frame
case .shot:
scrollLine.frame = lineThree.frame
case .chat:
scrollLine.frame = lineFour.frame
}
collectionView.reloadData()
}
}
}
extension TrashContenView:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{
func numberOfSections(in collectionView: UICollectionView) -> Int{
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 20 //section == 0 ? 1 : 20
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// if indexPath.section == 0{
// let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TrashContenTitleCell", for: indexPath) as! TrashContenTitleCell
// cell.trashType = trashType
// return cell
// }
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TrashContenAssetCell", for: indexPath) as! TrashContenAssetCell
return cell
}
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
// return indexPath.section == 0 ? CGSize(width: ScreenW, height: 92) : CGSize(width: (ScreenW-56)/3, height: (ScreenW-56)/3)
// }
//
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets{
// return section == 0 ? UIEdgeInsets() : UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
// }
}
//
// TrashContenViewCell.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import UIKit
class TrashContenViewCell: UICollectionViewCell {
@IBOutlet weak var collectionView: UICollectionView!
var trashType:TrashTypeEnum = .video{
didSet{
collectionView.reloadData()
}
}
override func awakeFromNib() {
super.awakeFromNib()
configUI()
}
func configUI(){
let layout = UICollectionViewFlowLayout()
layout.minimumInteritemSpacing = 12
layout.minimumLineSpacing = 12
collectionView.setCollectionViewLayout(layout, animated: false)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.register(UINib(nibName: "TrashContenAssetCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenAssetCell")
collectionView.register(UINib(nibName: "TrashContenTitleCell", bundle: nil), forCellWithReuseIdentifier: "TrashContenTitleCell")
}
}
extension TrashContenViewCell:UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{
func numberOfSections(in collectionView: UICollectionView) -> Int{
return 2
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return section == 0 ? 1 : 20
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.section == 0{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TrashContenTitleCell", for: indexPath) as! TrashContenTitleCell
cell.trashType = trashType
return cell
}
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TrashContenAssetCell", for: indexPath) as! TrashContenAssetCell
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
return indexPath.section == 0 ? CGSize(width: ScreenW, height: 92) : CGSize(width: (ScreenW-56)/3, height: (ScreenW-56)/3)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets{
return section == 0 ? UIEdgeInsets() : UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="TrashContenViewCell" customModule="PhoneManager" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="361" height="651"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="361" height="651"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="Odc-yC-eFI">
<rect key="frame" x="0.0" y="34" width="361" height="543"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="wcT-3C-X99">
<size key="itemSize" width="128" height="128"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
</collectionView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vwh-eI-xUZ">
<rect key="frame" x="12" y="12" width="18" height="22"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="icon_close_bottom"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tAl-Ag-gWh">
<rect key="frame" x="55" y="594" width="251" height="40"/>
<color key="backgroundColor" red="0.0" green="0.50980392156862742" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Vfn-jJ-kAL"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Delete"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="Radius">
<real key="value" value="10"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</button>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Odc-yC-eFI" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="34" id="0pH-QH-0Nh"/>
<constraint firstAttribute="trailing" secondItem="Odc-yC-eFI" secondAttribute="trailing" id="6da-yv-Mra"/>
<constraint firstAttribute="bottom" secondItem="Odc-yC-eFI" secondAttribute="bottom" constant="74" id="DXX-tt-ruW"/>
<constraint firstItem="tAl-Ag-gWh" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="55" id="LPh-dc-mJz"/>
<constraint firstAttribute="trailing" secondItem="tAl-Ag-gWh" secondAttribute="trailing" constant="55" id="Lf5-pG-yLg"/>
<constraint firstItem="Odc-yC-eFI" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="OS7-L9-lZo"/>
<constraint firstItem="Vwh-eI-xUZ" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="12" id="i0S-Ce-fxf"/>
<constraint firstItem="tAl-Ag-gWh" firstAttribute="top" secondItem="Odc-yC-eFI" secondAttribute="bottom" constant="17" id="sgV-i8-XdP"/>
<constraint firstItem="Vwh-eI-xUZ" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" constant="12" id="ulu-1z-3ov"/>
</constraints>
<size key="customSize" width="361" height="651"/>
<connections>
<outlet property="collectionView" destination="Odc-yC-eFI" id="blD-2P-agx"/>
</connections>
<point key="canvasLocation" x="329.00763358778624" y="232.04225352112678"/>
</collectionViewCell>
</objects>
<resources>
<image name="icon_close_bottom" width="18" height="18"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
...@@ -181,6 +181,16 @@ extension UIView { ...@@ -181,6 +181,16 @@ extension UIView {
// 将渐变图层添加到视图的最底层 // 将渐变图层添加到视图的最底层
self.layer.insertSublayer(gradientLayer, at: 0) self.layer.insertSublayer(gradientLayer, at: 0)
} }
/// 视图最右边的x坐标(origin.x + width)
var rightX: CGFloat {
return frame.maxX
}
/// 视图最底部的y坐标(origin.y + height)
var bottomY: CGFloat {
return frame.maxY
}
} }
......
//
// EXNotification.swift
// PhoneManager
//
// Created by edy on 2025/5/11.
//
import Foundation
extension NSNotification.Name {
static let trashPageScroll: NSNotification.Name = NSNotification.Name(rawValue: "trashPageScroll")
}
...@@ -13,6 +13,7 @@ target 'PhoneManager' do ...@@ -13,6 +13,7 @@ target 'PhoneManager' do
pod 'OpenCV' pod 'OpenCV'
pod 'SVProgressHUD' pod 'SVProgressHUD'
pod 'Google-Mobile-Ads-SDK' pod 'Google-Mobile-Ads-SDK'
pod 'SwiftyGif'
post_install do |installer| post_install do |installer|
installer.pods_project.targets.each do |target| installer.pods_project.targets.each do |target|
......
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