|
@@ -24,14 +24,14 @@ public class PQRemindView: UIView {
|
|
|
|
|
|
public var remindBlock: ((_ sender: UIButton, _ remindData: PQBaseModel?) -> Void)?
|
|
|
|
|
|
- lazy var contentView: UIView = {
|
|
|
+ lazy public var contentView: UIView = {
|
|
|
let contentView = UIView()
|
|
|
contentView.backgroundColor = UIColor.white
|
|
|
contentView.addCorner(corner: 4)
|
|
|
return contentView
|
|
|
}()
|
|
|
|
|
|
- lazy var titleLab: UILabel = {
|
|
|
+ lazy public var titleLab: UILabel = {
|
|
|
let titleLab = UILabel()
|
|
|
titleLab.font = UIFont.systemFont(ofSize: 18, weight: .medium)
|
|
|
titleLab.textAlignment = .center
|
|
@@ -40,7 +40,7 @@ public class PQRemindView: UIView {
|
|
|
return titleLab
|
|
|
}()
|
|
|
|
|
|
- lazy var contentLab: UILabel = {
|
|
|
+ lazy public var contentLab: UILabel = {
|
|
|
// let contentLab = TYAttributedLabel.init()
|
|
|
// contentLab.textAlignment = CTTextAlignment.center
|
|
|
// contentLab.verticalAlignment = .center
|
|
@@ -56,7 +56,7 @@ public class PQRemindView: UIView {
|
|
|
return contentLab
|
|
|
}()
|
|
|
|
|
|
- lazy var cancelBtn: UIButton = {
|
|
|
+ lazy public var cancelBtn: UIButton = {
|
|
|
let cancelBtn = UIButton(type: .custom)
|
|
|
cancelBtn.setTitle("取消", for: .normal)
|
|
|
cancelBtn.setTitleColor(UIColor.black, for: .normal)
|
|
@@ -66,7 +66,7 @@ public class PQRemindView: UIView {
|
|
|
return cancelBtn
|
|
|
}()
|
|
|
|
|
|
- lazy var confirmBtn: UIButton = {
|
|
|
+ lazy public var confirmBtn: UIButton = {
|
|
|
let confirmBtn = UIButton(type: .custom)
|
|
|
confirmBtn.setTitle("确定", for: .normal)
|
|
|
confirmBtn.setTitleColor(UIColor.black, for: .normal)
|
|
@@ -76,13 +76,13 @@ public class PQRemindView: UIView {
|
|
|
return confirmBtn
|
|
|
}()
|
|
|
|
|
|
- lazy var verticalLine: UIView = {
|
|
|
+ lazy public var verticalLine: UIView = {
|
|
|
let verticalLine = UIView()
|
|
|
verticalLine.backgroundColor = UIColor.hexColor(hexadecimal: "#E5E5E5")
|
|
|
return verticalLine
|
|
|
}()
|
|
|
|
|
|
- lazy var horizonLine: UIView = {
|
|
|
+ lazy public var horizonLine: UIView = {
|
|
|
let horizonLine = UIView()
|
|
|
horizonLine.backgroundColor = UIColor.hexColor(hexadecimal: "#E5E5E5")
|
|
|
return horizonLine
|
|
@@ -122,7 +122,7 @@ public class PQRemindView: UIView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func addLayout() {
|
|
|
+ public func addLayout() {
|
|
|
var summH: CGFloat = 0
|
|
|
var titleH: CGFloat = 0
|
|
|
if (remindData?.summary?.count ?? 0) > 0 {
|
|
@@ -372,3 +372,144 @@ extension PQEmptyRemindView {
|
|
|
|
|
|
func removeShimmeringView() {}
|
|
|
}
|
|
|
+
|
|
|
+// MARK: - 上传提示框
|
|
|
+
|
|
|
+/// 上传提示框
|
|
|
+public class PQUploadRemindView: PQRemindView {
|
|
|
+ public var canMoreOpration: Bool = false // 是否还有更多操作
|
|
|
+ public var confirmTitle: String = "我知道了"
|
|
|
+ public var cancelTitle: String = "取消"
|
|
|
+ public var cacelColor: UIColor = UIColor.hexColor(hexadecimal: "#666666")
|
|
|
+ public var attributedTitle: NSAttributedString?
|
|
|
+
|
|
|
+ override public func addData() {
|
|
|
+ titleLab.textAlignment = .center
|
|
|
+ if attributedTitle != nil {
|
|
|
+ titleLab.attributedText = attributedTitle
|
|
|
+ } else {
|
|
|
+ titleLab.text = remindData?.title
|
|
|
+ }
|
|
|
+ if remindData?.attributedTitle != nil {
|
|
|
+ contentLab.attributedText = remindData?.attributedTitle
|
|
|
+ } else {
|
|
|
+ contentLab.text = remindData?.summary
|
|
|
+ }
|
|
|
+ cancelBtn.setTitleColor(cacelColor, for: .normal)
|
|
|
+ confirmBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#EE0051"), for: .normal)
|
|
|
+ confirmBtn.setTitle(confirmTitle, for: .normal)
|
|
|
+ cancelBtn.setTitle(cancelTitle, for: .normal)
|
|
|
+ let ges = UITapGestureRecognizer(target: self, action: #selector(removeView))
|
|
|
+ addGestureRecognizer(ges)
|
|
|
+ }
|
|
|
+
|
|
|
+ override public func addLayout() {
|
|
|
+ let titleH: CGFloat = ((remindData?.title != nil && (remindData?.title?.count ?? 0) > 0) || attributedTitle != nil) ? cDefaultMargin * 2 : 0
|
|
|
+
|
|
|
+ let summH: CGFloat = sizeTextFits(attributedText: remindData?.attributedTitle != nil ? remindData?.attributedTitle : NSMutableAttributedString(string: remindData?.summary ?? ""), text: nil, numberOfLines: 0, font: UIFont.systemFont(ofSize: 14), maxSize: CGSize(width: cScreenWidth - cDefaultMargin * 12, height: CGFloat.greatestFiniteMagnitude)).height + cDefaultMargin
|
|
|
+
|
|
|
+ let contentH: CGFloat = (titleH == 0 ? 0 : cDefaultMargin * 3) + cDefaultMargin * 2 + summH + cDefaultMargin + cDefaultMargin * 5
|
|
|
+
|
|
|
+ contentView.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(self).offset(cDefaultMargin * 3)
|
|
|
+ make.right.equalTo(self).offset(-cDefaultMargin * 3)
|
|
|
+ make.height.equalTo(contentH)
|
|
|
+ make.center.equalTo(self)
|
|
|
+ }
|
|
|
+ titleLab.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(contentView).offset(cDefaultMargin * 2)
|
|
|
+ make.right.equalTo(contentView).offset(-cDefaultMargin * 2)
|
|
|
+ make.height.equalTo(titleH)
|
|
|
+ make.top.equalTo(contentView).offset(titleH == 0 ? 0 : cDefaultMargin * 2)
|
|
|
+ }
|
|
|
+ contentLab.snp.makeConstraints { make in
|
|
|
+ make.top.equalTo(titleLab.snp_bottom).offset(cDefaultMargin)
|
|
|
+ make.left.right.equalTo(titleLab)
|
|
|
+ make.height.equalTo(summH)
|
|
|
+ }
|
|
|
+ if canMoreOpration {
|
|
|
+ let btnW: CGFloat = (cScreenWidth - 1 - cDefaultMargin * 8) / 2
|
|
|
+ verticalLine.snp.makeConstraints { make in
|
|
|
+ make.top.equalTo(contentLab.snp_bottom).offset(cDefaultMargin)
|
|
|
+ make.height.equalTo(1)
|
|
|
+ make.left.width.equalToSuperview()
|
|
|
+ }
|
|
|
+ cancelBtn.snp.makeConstraints { make in
|
|
|
+ make.left.equalToSuperview()
|
|
|
+ make.top.equalTo(verticalLine.snp_bottom)
|
|
|
+ make.width.equalTo(btnW)
|
|
|
+ make.bottom.equalTo(contentView)
|
|
|
+ }
|
|
|
+ horizonLine.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(cancelBtn.snp_right)
|
|
|
+ make.height.top.equalTo(cancelBtn)
|
|
|
+ make.width.equalTo(1)
|
|
|
+ }
|
|
|
+ confirmBtn.snp.makeConstraints { make in
|
|
|
+ make.right.equalToSuperview()
|
|
|
+ make.height.width.bottom.equalTo(cancelBtn)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ verticalLine.snp.makeConstraints { make in
|
|
|
+ make.top.equalTo(contentLab.snp_bottom).offset(cDefaultMargin)
|
|
|
+ make.height.equalTo(1)
|
|
|
+ make.left.width.equalToSuperview()
|
|
|
+ }
|
|
|
+ confirmBtn.snp.makeConstraints { make in
|
|
|
+ make.right.left.equalTo(titleLab)
|
|
|
+ make.top.equalTo(verticalLine.snp_bottom)
|
|
|
+ make.bottom.equalTo(contentView)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func removeView() {
|
|
|
+ removeFromSuperview()
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc override func btnClck(sender: UIButton) {
|
|
|
+ removeFromSuperview()
|
|
|
+ if remindBlock != nil {
|
|
|
+ remindBlock!(sender, remindData!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 快速生成
|
|
|
+ /// - Parameters:
|
|
|
+ /// - title: <#title description#>
|
|
|
+ /// - summary: <#summary description#>
|
|
|
+ /// - confirmTitle: <#confirmTitle description#>
|
|
|
+ /// - remindHandle: <#remindHandle description#>
|
|
|
+ /// - Returns: <#description#>
|
|
|
+ class public func showUploadRemindView(title: String?, attributedTitle: NSAttributedString? = nil, summary: String, canMoreOpration: Bool = false, confirmTitle: String?, cancelTitle: String? = nil, cancelColor: UIColor? = nil, remindHandle: @escaping (_ sender: UIButton, _ baseModel: PQBaseModel?) -> Void) {
|
|
|
+ if UIApplication.shared.keyWindow?.viewWithTag(cUploadViewRemindTag) != nil {
|
|
|
+ UIApplication.shared.keyWindow?.viewWithTag(cUploadViewRemindTag)?.removeFromSuperview()
|
|
|
+ }
|
|
|
+ let remindData = PQBaseModel()
|
|
|
+ let paragraphStyle = NSMutableParagraphStyle()
|
|
|
+ paragraphStyle.lineSpacing = 3.0
|
|
|
+ paragraphStyle.alignment = .center
|
|
|
+ remindData.title = title
|
|
|
+ remindData.attributedTitle = NSMutableAttributedString(string: summary, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.hexColor(hexadecimal: "#666666"), NSAttributedString.Key.paragraphStyle: paragraphStyle])
|
|
|
+ let remindView = PQUploadRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
|
+ remindView.canMoreOpration = canMoreOpration
|
|
|
+ if confirmTitle != nil {
|
|
|
+ remindView.confirmTitle = confirmTitle!
|
|
|
+ }
|
|
|
+ if cancelTitle != nil {
|
|
|
+ remindView.cancelTitle = cancelTitle!
|
|
|
+ }
|
|
|
+ if cancelColor != nil {
|
|
|
+ remindView.cacelColor = cancelColor!
|
|
|
+ }
|
|
|
+ if attributedTitle != nil {
|
|
|
+ remindView.attributedTitle = attributedTitle
|
|
|
+ }
|
|
|
+ remindView.remindBlock = { sender, baseModel in
|
|
|
+ remindHandle(sender, baseModel)
|
|
|
+ }
|
|
|
+ remindView.tag = cUploadViewRemindTag
|
|
|
+ UIApplication.shared.keyWindow?.addSubview(remindView)
|
|
|
+ remindView.remindData = remindData
|
|
|
+ }
|
|
|
+}
|