|
@@ -0,0 +1,153 @@
|
|
|
+//
|
|
|
+// SheetSureView.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by 南鑫林 on 2019/7/21.
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+import UIKit
|
|
|
+import FWPopupView
|
|
|
+import RxSwift
|
|
|
+
|
|
|
+class SheetSureView: FWPopupView {
|
|
|
+
|
|
|
+ let disposeBag = DisposeBag()
|
|
|
+
|
|
|
+ var titleStr : String = ""
|
|
|
+ var sureStr : String = ""
|
|
|
+ var cancleStr : String = ""
|
|
|
+
|
|
|
+ override init(frame: CGRect) {
|
|
|
+ super.init(frame: frame)
|
|
|
+ }
|
|
|
+
|
|
|
+ init(titleStr:String,sureStr:String,cancleStr:String = "取消") {
|
|
|
+ self.init()
|
|
|
+ self.titleStr = titleStr
|
|
|
+ self.sureStr = sureStr
|
|
|
+ self.cancleStr = cancleStr
|
|
|
+ frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: 150+kSafeTabBarHeight)
|
|
|
+ // fillCode
|
|
|
+ self.configRectCorner(corner: [.topLeft,.topRight], radii: CGSize(width: 8, height: 8))
|
|
|
+ setupViews()
|
|
|
+ setLayouts()
|
|
|
+ setupData()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ required init?(coder aDecoder: NSCoder) {
|
|
|
+ fatalError("init(coder:) has not been implemented")
|
|
|
+ }
|
|
|
+
|
|
|
+ func setupViews() {
|
|
|
+ addSubview(titleLabel)
|
|
|
+ addSubview(lineLabel)
|
|
|
+ addSubview(sureButton)
|
|
|
+ addSubview(specLabel)
|
|
|
+ addSubview(cancelButton)
|
|
|
+ }
|
|
|
+
|
|
|
+ func setLayouts() {
|
|
|
+ titleLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(14)
|
|
|
+ make.left.equalTo(28)
|
|
|
+ make.right.equalTo(-28)
|
|
|
+ make.height.equalTo(20)
|
|
|
+ }
|
|
|
+ lineLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(14)
|
|
|
+ make.right.left.equalToSuperview()
|
|
|
+ make.height.equalTo(1)
|
|
|
+ }
|
|
|
+ sureButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(lineLabel.snp_bottom)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(48)
|
|
|
+ }
|
|
|
+ specLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(sureButton.snp_bottom)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(5)
|
|
|
+ }
|
|
|
+ cancelButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(specLabel.snp_bottom)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(48)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ lazy var titleLabel: UILabel = {
|
|
|
+ let titleLabel = UILabel()
|
|
|
+ titleLabel.text = titleStr
|
|
|
+ titleLabel.textColor = k999999Color
|
|
|
+ titleLabel.font = kRegularFont14
|
|
|
+ titleLabel.textAlignment = .center
|
|
|
+ return titleLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var lineLabel: UILabel = {
|
|
|
+ let lineLabel = UILabel()
|
|
|
+ lineLabel.backgroundColor = keeeeeeColor
|
|
|
+ return lineLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var sureButton: UIButton = {
|
|
|
+ let sureButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ sureButton.setTitle(sureStr, for: UIControl.State.normal)
|
|
|
+ sureButton.setTitleColor(k333333Color, for: UIControl.State.normal)
|
|
|
+ sureButton.titleLabel?.font = kRegularFont16
|
|
|
+ return sureButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var specLabel: UILabel = {
|
|
|
+ let specLabel = UILabel()
|
|
|
+ specLabel.backgroundColor = kf2f2f2Color
|
|
|
+ return specLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var cancelButton: UIButton = {
|
|
|
+ let cancelButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ cancelButton.setTitle(cancleStr, for: UIControl.State.normal)
|
|
|
+ cancelButton.setTitleColor(k333333Color, for: UIControl.State.normal)
|
|
|
+ cancelButton.titleLabel?.font = kRegularFont16
|
|
|
+
|
|
|
+ return cancelButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ typealias SureButtonClosure = () -> Void
|
|
|
+ var sureButtonClosure: SureButtonClosure?
|
|
|
+
|
|
|
+ func setupData() {
|
|
|
+ cancelButton.rx.tap.subscribe(onNext: {[weak self] (data) in
|
|
|
+ self?.hide()
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+
|
|
|
+ sureButton.rx.tap.subscribe(onNext: {
|
|
|
+ [weak self] (data) in
|
|
|
+ self?.hide()
|
|
|
+ if let sureButtonClosure = self?.sureButtonClosure {
|
|
|
+ sureButtonClosure()
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ class func sheetSureView(titleStr:String,sureStr:String,cancleStr:String = "取消", sureClosure:@escaping (() -> Void)) {
|
|
|
+ let view = SheetSureView(titleStr: titleStr, sureStr: sureStr,cancleStr: cancleStr)
|
|
|
+ let vProperty = FWPopupViewProperty()
|
|
|
+ vProperty.popupCustomAlignment = .bottomCenter
|
|
|
+ vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
+ vProperty.popupAnimationType = .frame
|
|
|
+ vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
|
|
|
+ vProperty.touchWildToHide = "0"
|
|
|
+ view.vProperty = vProperty
|
|
|
+ view.sureButtonClosure = {
|
|
|
+ view.hide()
|
|
|
+ sureClosure()
|
|
|
+ }
|
|
|
+ view.show()
|
|
|
+ }
|
|
|
+
|
|
|
+}
|