优化代码结构
This commit is contained in:
parent
9cf3feb5e8
commit
98e00590ed
@ -38,7 +38,6 @@
|
||||
1EE5C5F72B8F973A00EDFC2F /* CCSpatialShootController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5C5F62B8F973A00EDFC2F /* CCSpatialShootController.swift */; };
|
||||
1EE5C5FA2B8F97BF00EDFC2F /* SpatialVideoWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE5C5F92B8F97BF00EDFC2F /* SpatialVideoWriter.swift */; };
|
||||
1EEF683E2B8D079600B953F7 /* CCVRPreviewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EEF683D2B8D079600B953F7 /* CCVRPreviewController.swift */; };
|
||||
1EF3B31D2B945C45000BD52D /* CCSpaceAlbumFliterPopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EF3B31C2B945C45000BD52D /* CCSpaceAlbumFliterPopView.swift */; };
|
||||
1EFAF0BA2B8AF5EF002A1773 /* UIView+CCExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EFAF0B92B8AF5EF002A1773 /* UIView+CCExtension.swift */; };
|
||||
1EFAF0BD2B8B1D84002A1773 /* CCPopMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EFAF0BC2B8B1D84002A1773 /* CCPopMenuView.swift */; };
|
||||
1EFAF0C02B8B7A59002A1773 /* VRPhotoTransformController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EFAF0BF2B8B7A59002A1773 /* VRPhotoTransformController.swift */; };
|
||||
@ -128,8 +127,6 @@
|
||||
1EE5C5F62B8F973A00EDFC2F /* CCSpatialShootController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpatialShootController.swift; sourceTree = "<group>"; };
|
||||
1EE5C5F92B8F97BF00EDFC2F /* SpatialVideoWriter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpatialVideoWriter.swift; sourceTree = "<group>"; };
|
||||
1EEF683D2B8D079600B953F7 /* CCVRPreviewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCVRPreviewController.swift; sourceTree = "<group>"; };
|
||||
1EF3B31C2B945C45000BD52D /* CCSpaceAlbumFliterPopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumFliterPopView.swift; sourceTree = "<group>"; };
|
||||
1EFAF0B72B8AF1B8002A1773 /* CCSpaceAlbumPopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCSpaceAlbumPopView.swift; sourceTree = "<group>"; };
|
||||
1EFAF0B92B8AF5EF002A1773 /* UIView+CCExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+CCExtension.swift"; sourceTree = "<group>"; };
|
||||
1EFAF0BC2B8B1D84002A1773 /* CCPopMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CCPopMenuView.swift; sourceTree = "<group>"; };
|
||||
1EFAF0BF2B8B7A59002A1773 /* VRPhotoTransformController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VRPhotoTransformController.swift; sourceTree = "<group>"; };
|
||||
@ -268,7 +265,6 @@
|
||||
1EF3B31E2B945DE0000BD52D /* CCSpaceAlbumFliterPopView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1EF3B31C2B945C45000BD52D /* CCSpaceAlbumFliterPopView.swift */,
|
||||
009661F72BAD6C7100FCA65F /* CCSpaceAlbumFilterPopView2.swift */,
|
||||
);
|
||||
path = CCSpaceAlbumFliterPopView;
|
||||
@ -278,7 +274,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1EF3B31E2B945DE0000BD52D /* CCSpaceAlbumFliterPopView */,
|
||||
1EFAF0B72B8AF1B8002A1773 /* CCSpaceAlbumPopView.swift */,
|
||||
);
|
||||
path = Album;
|
||||
sourceTree = "<group>";
|
||||
@ -693,7 +688,6 @@
|
||||
AF2121002B4EA5FE00400B7F /* CCRegisterController.swift in Sources */,
|
||||
AF2120D02B4E982300400B7F /* CCUserDefault.swift in Sources */,
|
||||
AF2120EC2B4EA2FC00400B7F /* BaseController.swift in Sources */,
|
||||
1EF3B31D2B945C45000BD52D /* CCSpaceAlbumFliterPopView.swift in Sources */,
|
||||
AF2120D22B4E99E600400B7F /* CCAddImage.swift in Sources */,
|
||||
AF2120E42B4E9D5A00400B7F /* CCSMSView.swift in Sources */,
|
||||
1E1EA28E2B93393A00A5D5D2 /* UIButton+CCExtension.swift in Sources */,
|
||||
|
||||
Binary file not shown.
@ -521,8 +521,8 @@
|
||||
filePath = "SwiftProject/Project/View/Album/CCSpaceAlbumFliterPopView/CCSpaceAlbumFliterPopView.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "354"
|
||||
endingLineNumber = "354"
|
||||
startingLineNumber = "349"
|
||||
endingLineNumber = "349"
|
||||
landmarkName = "filtersButtonAction()"
|
||||
landmarkType = "7">
|
||||
<Locations>
|
||||
@ -569,8 +569,8 @@
|
||||
filePath = "SwiftProject/Project/View/Album/CCSpaceAlbumFliterPopView/CCSpaceAlbumFliterPopView.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "231"
|
||||
endingLineNumber = "231"
|
||||
startingLineNumber = "226"
|
||||
endingLineNumber = "226"
|
||||
landmarkName = "fetchPhotos()"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
|
||||
@ -11,6 +11,123 @@ import Photos
|
||||
|
||||
private let Back_Height:CGFloat = KHZSize(700)
|
||||
|
||||
enum SelectedFileType : Int {
|
||||
case all
|
||||
case image
|
||||
case video
|
||||
}
|
||||
|
||||
|
||||
|
||||
//MARK: - Cell
|
||||
class CCSpaceAlbumFliterCollectionCell: UICollectionViewCell {
|
||||
|
||||
let imageView: UIImageView = {
|
||||
let imageView = UIImageView()
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
imageView.clipsToBounds = true
|
||||
return imageView
|
||||
}()
|
||||
|
||||
let frameCountLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .white
|
||||
label.backgroundColor = UIColor(hexString: "#383739")
|
||||
label.textAlignment = .center
|
||||
label.font = UIFont.boldSystemFont(ofSize: 12)
|
||||
label.layer.cornerRadius = 8
|
||||
label.adjustsFontSizeToFitWidth = true
|
||||
label.layer.masksToBounds = true
|
||||
return label
|
||||
}()
|
||||
|
||||
let timeLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .white
|
||||
label.backgroundColor = UIColor(hexString: "#383739")
|
||||
label.textAlignment = .center
|
||||
label.font = UIFont.boldSystemFont(ofSize: 12)
|
||||
label.layer.cornerRadius = 8
|
||||
label.adjustsFontSizeToFitWidth = true
|
||||
label.layer.masksToBounds = true
|
||||
return label
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setupViews()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
setupViews()
|
||||
}
|
||||
|
||||
private func setupViews() {
|
||||
addSubview(imageView)
|
||||
addSubview(frameCountLabel)
|
||||
addSubview(timeLabel);
|
||||
|
||||
imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
frameCountLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
timeLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
imageView.topAnchor.constraint(equalTo: topAnchor),
|
||||
imageView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
imageView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
imageView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
|
||||
frameCountLabel.topAnchor.constraint(equalTo: topAnchor, constant: 8),
|
||||
frameCountLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 8),
|
||||
frameCountLabel.widthAnchor.constraint(equalToConstant: 40),
|
||||
frameCountLabel.heightAnchor.constraint(equalToConstant: 20),
|
||||
|
||||
timeLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8),
|
||||
timeLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8),
|
||||
timeLabel.widthAnchor.constraint(equalToConstant: 40),
|
||||
timeLabel.heightAnchor.constraint(equalToConstant: 20)
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//MARK: - Model
|
||||
enum AssetType : Int {
|
||||
case image
|
||||
case video
|
||||
case all
|
||||
}
|
||||
class CCSpaceAlbumFliterModel: NSObject {
|
||||
|
||||
/// 1 image 2 video 3 gif
|
||||
var assetType:AssetType?
|
||||
var itemAsset :PHAsset?
|
||||
var astLocalIdentifier :String?
|
||||
var image: UIImage?//照片或者视频第一帧
|
||||
/** 是否被用户勾选 */
|
||||
var isSelected :Bool?
|
||||
/** 当前元素 被选中之后的标号 */
|
||||
var currentItemSelectedFlage: String?
|
||||
var videoTimeLength:Int?
|
||||
|
||||
static func initWithAssetType(assetType:AssetType,asset:PHAsset,image:UIImage,localIdentifier:String) -> CCSpaceAlbumFliterModel {
|
||||
let model = CCSpaceAlbumFliterModel()
|
||||
model.assetType = assetType
|
||||
model.itemAsset = asset
|
||||
model.astLocalIdentifier = localIdentifier
|
||||
model.image = image
|
||||
|
||||
return model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CCSpaceAlbumFilterPopView2: UIView {
|
||||
var selectedImageHandler: ((Data,PHAsset) -> Void)?
|
||||
var selectedVideoHandler: ((URL,PHAsset) -> Void)?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user