Commit e3c81dec authored by CZ1004's avatar CZ1004

【新增】垃圾桶功能

parent 07f47302
...@@ -51,6 +51,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -51,6 +51,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true return true
} }
func applicationWillTerminate(_ application: UIApplication) {
// 保存单利中所有垃圾桶的数据
saveDataToTrashDB()
}
func saveDataToTrashDB(){
let data = Singleton.shared.trashData
var count = 0
for (key,value) in data {
for item in value {
let success = TrashDatabase.shared.insert(localIdentifier: item.localIdentifier, assetSize: item.assetSize, createDate: item.createDate, mediaType: key.dbType)
if success {
count = count + 1
}
}
}
Singleton.shared.trashData = [:]
Print("保留单利数据到数据库--\(count)条")
}
func applicationDidBecomeActive(_ application: UIApplication) { func applicationDidBecomeActive(_ application: UIApplication) {
NotificationCenter.default.post(name: Notification.Name("applicationDidBecomeActive"), object: nil) NotificationCenter.default.post(name: Notification.Name("applicationDidBecomeActive"), object: nil)
......
{
"images" : [
{
"filename" : "Frame.png",
"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" : [
{
"filename" : "Group_1171275102.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group_1171275102@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group_1171275102@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -308,29 +308,15 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti ...@@ -308,29 +308,15 @@ extension HomePhotosDetailViewController:WaterfallMutiSectionDelegate,UICollecti
cell.cellCallBack = {[weak self] ident,order in cell.cellCallBack = {[weak self] ident,order in
guard let self else {return} guard let self else {return}
DispatchQueue.main.async { DispatchQueue.main.async {
// 点击之后跳转详情页面 // 点击之后跳转详情页面
let vc = PMShowImgVideoController() if self.mediaType == .screenshots {
vc.state = .similarPhotos let vc = PhotoRemoveViewController(data: self.resourceData,currentIndex: indexPath.row,mediaType: .shot)
vc.currentIdx = 0 self.navigationController?.pushViewController(vc, animated: true)
vc.oldPageIndexPath = indexPath }
let dataSource = ImageSeletedCollectionItem() if self.mediaType == .Other {
dataSource.isSeleted = cell.choose let vc = PhotoRemoveViewController(data: self.resourceData,currentIndex: indexPath.row,mediaType: .other)
dataSource.id = ident self.navigationController?.pushViewController(vc, animated: true)
// 获取image
dataSource.image = PhotoAndVideoMananger.mananger.getImageFromAssetID(id: ident.localIdentifier)
vc.homeDataSource = [dataSource]
vc.backOrgPageCallBack = {[weak self]index,data in
guard let self else {return}
if let data = data{
if let item = data.first{
cell.choose = item.isSeleted ?? false
}
}
} }
self.navigationController?.pushViewController(vc, animated: true)
} }
} }
cell.clickCallBack = {[weak self] click,order in cell.clickCallBack = {[weak self] click,order in
......
...@@ -21,13 +21,13 @@ class PhotoSlideViewController: BaseViewController { ...@@ -21,13 +21,13 @@ class PhotoSlideViewController: BaseViewController {
private lazy var topView: AnchorRotatableView = { private lazy var topView: AnchorRotatableView = {
let view = AnchorRotatableView() let view = AnchorRotatableView()
view.configure(anchorPoint: CGPoint(x: 0.5, y: 0.5))
return view return view
}() }()
private lazy var bottomView: AnchorRotatableView = { private lazy var bottomView: AnchorRotatableView = {
let view = AnchorRotatableView() let view = AnchorRotatableView()
view.configure(anchorPoint: CGPoint(x: 0.5, y: 0.5))
return view return view
}() }()
...@@ -119,7 +119,8 @@ class PhotoSlideViewController: BaseViewController { ...@@ -119,7 +119,8 @@ class PhotoSlideViewController: BaseViewController {
updateCardTransform(translation: translation) updateCardTransform(translation: translation)
updateButtons(progress: progress,translation: translation) updateButtons(progress: progress,translation: translation)
case .ended, .cancelled: case .ended, .cancelled:
endDragAnimation(velocity: velocity) break
// endDragAnimation(velocity: velocity)
default: break default: break
} }
} }
......
...@@ -40,10 +40,3 @@ class AnchorRotatableView: UIView { ...@@ -40,10 +40,3 @@ class AnchorRotatableView: UIView {
} }
extension AnchorRotatableView {
func configure(anchorPoint: CGPoint) {
layer.anchorPoint = anchorPoint
}
}
//
// PhotoRemoveNavView.swift
// PhoneManager
//
// Created by edy on 2025/5/13.
//
import UIKit
class PhotoRemoveNavView: UIView {
public var backButton:UIButton!
public var titleLbel : UILabel!
public var resetButton :UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
backgroundColor = .white
backButton = UIButton()
backButton.setImage(UIImage(named: "nav_back"), for: .normal)
backButton.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
self.addSubview(backButton)
backButton.snp.makeConstraints { make in
make.centerY.equalTo(navCenterY)
make.left.equalToSuperview().offset(marginLR)
make.width.height.equalTo(iconWH)
}
titleLbel = UILabel()
titleLbel.textColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
titleLbel.font = UIFont.systemFont(ofSize: 12, weight: .medium)
self.addSubview(titleLbel)
titleLbel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalToSuperview().offset(6 + statusBarHeight)
make.height.equalTo(22)
}
resetButton = UIButton()
resetButton.setImage(UIImage(named: "nav_back"), for: .normal)
resetButton.addTarget(self, action: #selector(resetButtonAction), for: .touchUpInside)
resetButton.isHidden = true
self.addSubview(resetButton)
resetButton.snp.makeConstraints { make in
make.centerY.equalTo(navCenterY)
make.right.equalToSuperview().offset(-marginLR)
make.width.height.equalTo(iconWH)
}
}
@objc private func backBtnClick() {
self.responderViewController()?.navigationController?.popViewController(animated: true)
}
@objc private func resetButtonAction() {
}
}
//
// AnchorRotatableView.swift
// AIClean
//
// Created by 赵前 on 2025/5/10.
//
import Foundation
import UIKit
class PhotosRemoveBaseView: UIView {
var currentIndex : Int?
var initialCenter: CGPoint = .zero
private let imageView = UIImageView()
private let leftButton = UIButton()
private let rightButton = UIButton()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
// 配置图片视图
imageView.contentMode = .scaleAspectFill
imageView.layer.cornerRadius = 20
imageView.clipsToBounds = true
addSubview(imageView)
// 配置按钮
let buttonSize: CGFloat = 300
leftButton.frame = CGRect(x: 0, y: 0, width: buttonSize, height: buttonSize)
leftButton.setImage(UIImage(named:"Frame 2"), for: .normal) // 替换你的图标
leftButton.tintColor = .white
leftButton.alpha = 0
addSubview(leftButton)
rightButton.frame = CGRect(x: 0, y: 0, width: buttonSize, height: buttonSize)
rightButton.setImage(UIImage(named:"Group_1171275102"), for: .normal) // 替换你的图标
rightButton.tintColor = .white
rightButton.alpha = 0
addSubview(rightButton)
leftButton.center = cWindow!.center
rightButton.center = cWindow!.center
}
func configure(with image: UIImage) {
imageView.image = image
imageView.frame = bounds
}
func showLeftButton() {
UIView.animate(withDuration: 0.2) {
self.leftButton.alpha = 1
self.rightButton.alpha = 0
}
}
func showRightButton() {
UIView.animate(withDuration: 0.2) {
self.rightButton.alpha = 1
self.leftButton.alpha = 0
}
}
func hideButtons() {
UIView.animate(withDuration: 0.2) {
self.leftButton.alpha = 0
self.rightButton.alpha = 0
self.leftButton.center = cWindow!.center
self.rightButton.center = cWindow!.center
}
}
}
//
// TrashSubView.swift
// PhoneManager
//
// Created by edy on 2025/5/13.
//
import UIKit
class TrashSubView: UIView {
lazy var resourceCountlabel : UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 24, weight: .semibold)
label.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
return label
}()
lazy var tipLabel : UILabel = {
let label = UILabel()
label.text = "The photo in the trash can"
label.font = UIFont.systemFont(ofSize: 12, weight: .semibold)
label.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
label.numberOfLines = 0
return label
}()
lazy var emptyButton: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "ic_delete_duplicates"), for: .normal)
button.backgroundColor = UIColor(red: 0, green: 0.51, blue: 1, alpha: 1)
button.setTitle("Empty the garbage", for: .normal)
button.setTitleColor(.white, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .semibold)
button.layer.cornerRadius = 19
button.clipsToBounds = true
return button
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.addSubview(self.resourceCountlabel)
self.addSubview(self.tipLabel)
self.addSubview(self.emptyButton)
self.resourceCountlabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.centerY.equalToSuperview()
make.height.equalTo(22)
make.width.equalTo(30)
}
self.tipLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(17)
make.bottom.equalToSuperview().offset(-17)
make.left.equalTo(self.resourceCountlabel.snp.right).offset(11)
make.width.equalTo(100)
}
self.emptyButton.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-9)
make.height.equalTo(38)
make.centerY.equalToSuperview()
make.width.equalTo(145)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
...@@ -19,6 +19,8 @@ class Singleton { ...@@ -19,6 +19,8 @@ class Singleton {
var maxDeleteCount : Int = 25 var maxDeleteCount : Int = 25
var trashData : [TrashTypeEnum : [AssetModel]] = [:]
var photoPermission : PrivacyType? var photoPermission : PrivacyType?
......
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