Commit 873ecde3 authored by CZ1004's avatar CZ1004

【优化】部分逻辑新增和bug修复

parent 78b769f8
//
// HomeDetailDeleteView.swift
// PhoneManager
//
// Created by edy on 2025/5/19.
//
import UIKit
class HomeDetailDeleteView: UIView {
var deleteCallBack:(()->Void) = {}
lazy var deleteButton : UIButton = {
let view = UIButton()
view.setTitle("Delete", for: UIControl.State.normal)
view.setTitleColor(.white, for: .normal)
view.clipsToBounds = true
view.layer.cornerRadius = 23
view.backgroundColor = UIColor(red: 0.7, green: 0.7, blue: 0.7, alpha: 1)
view.addTarget(self, action: #selector(deleteButtonAction), for: .touchUpInside)
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .white
self.addSubview(self.deleteButton)
self.deleteButton.snp.makeConstraints { make in
make.top.equalToSuperview().offset(16)
make.left.equalToSuperview().offset(15)
make.right.equalToSuperview().offset(-15)
make.height.equalTo(46)
}
}
@objc func deleteButtonAction(){
self.deleteCallBack()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
......@@ -44,6 +44,7 @@ class HomeInfoView :UIView {
lazy var headerView:HomeInfoTitleView = {
let sview:HomeInfoTitleView = HomeInfoTitleView(frame: CGRect(x: 0, y: 0, width: width, height: 84))
sview.titleLabel.text = self.titleText
sview.type = self.type
sview.filterButton.isHidden = self.type != .similar && self.type != .SimilarVideos
return sview
}()
......@@ -354,9 +355,19 @@ extension HomeInfoView:UITableViewDataSource,UITableViewDelegate {
guard let indexPath = tableView.indexPathsForVisibleRows?.first else { return }
let nextRow = self.isDragEnd == true ? indexPath.row + 1 : indexPath.row + 2
// let nextRow = self.isDragEnd == true ? indexPath.row + 1 : indexPath.row + 2
let nextRow = indexPath.row + 2
let nextSection = indexPath.section
// 获取最后一个cell 看看是不是存在
guard let lastIndexPath = tableView.indexPathsForVisibleRows?.last else {return}
let lastNextRow = lastIndexPath.row + 1
guard lastNextRow < tableView.numberOfRows(inSection: nextSection) else {
// 滚动到最底部
tableView.scrollToRow(at: lastIndexPath, at: .bottom, animated: true)
return
}
// 检查下一行是否存在
guard nextRow < tableView.numberOfRows(inSection: nextSection) else { return }
......@@ -498,6 +509,8 @@ class HomeInfoTitleView:UIView {
var sortViewSubmitCallBack : (ResourceFilterBoxModel)->Void = {model in}
var type : PhotsFileType?
lazy var titleLabel:UILabel = {
let sview:UILabel = UILabel()
......@@ -575,7 +588,12 @@ class HomeInfoTitleView:UIView {
let allNumberStr = "\(allNumber)"
let seletedCountStr = "\(seletedCount)"
let fullText = allNumberStr + " photos · \(seletedCountStr) selected"
var fullText = "0 photos · 0 selected"
if self.type == .SimilarVideos {
fullText = allNumberStr + " videos · \(seletedCountStr) selected"
}else {
fullText = allNumberStr + " photos · \(seletedCountStr) selected"
}
let attributedString2 = NSMutableAttributedString(string: fullText, attributes: [
......
......@@ -56,6 +56,7 @@ class PhotosRemoveBaseView: UIView {
self.imageView.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer()
tap.addTarget(self, action: #selector(showDeatail))
imageView.backgroundColor = .white
self.imageView.addGestureRecognizer(tap)
}
......
......@@ -9,6 +9,8 @@ import UIKit
class TrashSubView: UIView {
var type : TrashTypeEnum?
var clearTashDataCallBack : ()->Void = {}
var presentTashDetailViewClickCallBack : ()->Void = {}
......@@ -32,7 +34,7 @@ class TrashSubView: UIView {
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.setTitle("Empty Trash", for: .normal)
button.setTitleColor(.white, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 12, weight: .semibold)
button.layer.cornerRadius = 19
......@@ -43,6 +45,8 @@ class TrashSubView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.addTopShadow()
// 给当前视图添加手势
addTapGestureToSelf()
......
......@@ -146,14 +146,14 @@ extension YearMonthPickerView: UIPickerViewDataSource, UIPickerViewDelegate {
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return component == 0 ? months[row] : "\(years.reversed()[row])"
return component == 0 ? months[row] : "\(years[row])"
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if component == 0 {
selectedMonth = row
} else {
selectedYear = years.reversed()[row]
selectedYear = years[row]
}
}
......
......@@ -12,13 +12,13 @@ class TrashViewController: BaseViewController {
var dissmisCallBack:()->Void = {}
var source:[TrashTypeEnum] = [.video,.other,.shot,.chat]
var source:[TrashTypeEnum] = [.video,.other,.shot]
var contentH:CGFloat = 0
var contentScrollView:UIScrollView!
var delBtn:UIButton!
var currentType:TrashTypeEnum = .other
let pageCount = 4 // 总页数
let pageCount = 3 // 总页数
var currentPage = 1 {
didSet{
self.setDelButtonUI()
......@@ -61,7 +61,7 @@ class TrashViewController: BaseViewController {
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.contentSize = CGSize(width: ScreenW * CGFloat(self.source.count), height: view.height)
contentScrollView.isPagingEnabled = true
contentScrollView.showsHorizontalScrollIndicator = false
contentScrollView.showsVerticalScrollIndicator = false
......@@ -98,13 +98,11 @@ class TrashViewController: BaseViewController {
contentScrollView.addSubview(videoView)
contentScrollView.addSubview(otherView)
contentScrollView.addSubview(shotView)
contentScrollView.addSubview(chatView)
videoView.deleteButton = delBtn
otherView.deleteButton = delBtn
shotView.deleteButton = delBtn
chatView.deleteButton = delBtn
}
override func viewWillLayoutSubviews() {
......@@ -114,11 +112,10 @@ class TrashViewController: BaseViewController {
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)
contentScrollView.contentSize = CGSize(width: viewWidth * CGFloat(self.source.count), 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 = {
......@@ -139,54 +136,8 @@ class TrashViewController: BaseViewController {
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){
......@@ -233,9 +184,6 @@ extension TrashViewController:UIScrollViewDelegate{
if self.currentPage == 3 {
return (TrashTypeEnum.shot,self.shotView)
}
if self.currentPage == 4 {
return (TrashTypeEnum.chat,self.chatView)
}
return (TrashTypeEnum.video,self.videoView)
}
......
......@@ -11,7 +11,6 @@ enum TrashTypeEnum : String, CaseIterable{
case video = "Video"
case other = "Other"
case shot = "Screenshot"
case chat = "Chat"
var dbType:Int{
switch self {
......@@ -21,8 +20,6 @@ enum TrashTypeEnum : String, CaseIterable{
return 1
case .shot:
return 2
case .chat:
return 3
}
}
}
......
......@@ -39,8 +39,6 @@ class TrashContenTitleCell: UICollectionViewCell {
scrollLine.frame = lineTwo.frame
case .shot:
scrollLine.frame = lineThree.frame
case .chat:
scrollLine.frame = lineFour.frame
}
}
}
......@@ -131,16 +129,6 @@ class TrashContenTitleCell: UICollectionViewCell {
}
}
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
}
}
}
}
}
......
......@@ -29,7 +29,7 @@ class TrashContenView: UIView {
var deleteButton : UIButton?
var scrollLine:UIView!
let lineW:CGFloat = (ScreenW - 62) / 4.0
let lineW:CGFloat = (ScreenW - 62) / 3.0
var dataSource:[AssetModel] = [] {
didSet{
......@@ -48,11 +48,6 @@ class TrashContenView: UIView {
}
func getData(){
// dataSource = TrashDatabase.shared.queryByMediaType(trashType.dbType).compactMap({ (localIdentifier: String, assetSize: Double, createDate: Date, mediaType: Int) in
// return AssetModel.init(localIdentifier: localIdentifier, assetSize: assetSize, createDate: createDate)
// })
collectionView.reloadData()
}
......@@ -81,7 +76,6 @@ class TrashContenView: UIView {
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)
......@@ -134,14 +128,9 @@ class TrashContenView: 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()
......@@ -218,23 +207,6 @@ class TrashContenView: UIView {
}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
}
}
}
}
......@@ -245,8 +217,6 @@ class TrashContenView: UIView {
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{
......@@ -258,8 +228,6 @@ class TrashContenView: UIView {
scrollLine.frame = lineTwo.frame
case .shot:
scrollLine.frame = lineThree.frame
case .chat:
scrollLine.frame = lineFour.frame
}
getData()
}
......
......@@ -103,8 +103,6 @@ class TrashDefaultView: UIView {
case .other,.shot:
jumpToPhotosDetailPage(type: type)
break
case .chat:
break
}
}
}
......@@ -113,14 +111,6 @@ class TrashDefaultView: UIView {
self.responderViewController()?.dismiss(animated: true, completion: {
NotificationCenter.default.post(name: TrashDefaultView.jumpToPhotosDetailPageName, object: nil,userInfo: ["type":self.mediaType?.rawValue ?? ""])
})
// PhotoDataManager.manager.loadFromFileSystem { model in
// let data = type == .other ? model.otherModelArray[4] : model.otherModelArray[2]
// let vc:HomePhotosDetailViewController = HomePhotosDetailViewController(model: data)
// vc.mediaType = type == .other ? .Other : PhotsFileType.screenshots
// vc.dealData()
// self.responderViewController()?.navigationController?.pushViewController(vc, animated: true)
// }
}
func jumpToVideoDetailPage(type: TrashTypeEnum){
self.responderViewController()?.dismiss(animated: true, completion: {
......
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