123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- //
- // AlertSheetView.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/4/17.
- // Copyright © 2019 南鑫林. All rights reserved.
- //
- import UIKit
- import FWPopupView
- class AlertSheetView: NSObject {
- /// 自定义Alert弹框样式
- ///
- /// - Parameters:
- /// - title: 标题
- /// - detailTitle: 副标题
- /// - confirmBlock: 完成回调
- /// - cancelBlock: 取消回调
- /// - Returns: FWAlertView
- class func alert(title: String = "",detailTitle:String = "",cancelTitle:String = "取消",sureTitle:String = "确定",cancelBlock: FWPopupItemClickedBlock? = nil, confirmBlock: FWPopupItemClickedBlock? = nil) {
- // 注意:此时“确定”按钮是不让按钮自己隐藏的
- let items = [FWPopupItem(title: cancelTitle, itemType: .normal, isCancel: true, canAutoHide: true, itemTitleColor: k333333Color, itemBackgroundColor: nil, itemClickedBlock: cancelBlock),
- FWPopupItem(title: sureTitle, itemType: .normal, isCancel: false, canAutoHide: true, itemTitleColor: kFFA42FColor, itemBackgroundColor: nil, itemClickedBlock: confirmBlock)]
- // 演示:修改参数
- let vProperty = FWAlertViewProperty()
- vProperty.alertViewWidth = max(UIScreen.main.bounds.width * 0.65, 275)
- vProperty.titleFontSize = 18.0
- vProperty.titleColor = UIColor.black
- vProperty.detailFontSize = 15.0
- vProperty.detailColor = k999999Color
- vProperty.buttonFontSize = 18.0
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "0"
- // 还有很多参数可设置...
- let alertView = FWAlertView.alert(title: title, detail: detailTitle, inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: nil, items: items, vProperty: vProperty)
- alertView.show()
- }
-
- /// 自定义Alert弹框样式
- ///
- /// - Parameters:
- /// - title: 标题
- /// - confirmBlock: 完成回调
- /// - cancelBlock: 取消回调
- /// - Returns: FWAlertView
- class func alert(title: String = "",cancelTitle:String = "取消",sureTitle:String = "确定",cancelBlock: FWPopupItemClickedBlock? = nil, confirmBlock: FWPopupItemClickedBlock? = nil) {
- // 注意:此时“确定”按钮是不让按钮自己隐藏的
- let items = [FWPopupItem(title: cancelTitle, itemType: .normal, isCancel: true, canAutoHide: true, itemTitleColor: k333333Color, itemBackgroundColor: nil, itemClickedBlock: cancelBlock),
- FWPopupItem(title: sureTitle, itemType: .normal, isCancel: false, canAutoHide: true, itemTitleColor: kFFA42FColor, itemBackgroundColor: nil, itemClickedBlock: confirmBlock)]
-
- // 演示:修改参数
- let vProperty = FWAlertViewProperty()
- vProperty.alertViewWidth = max(UIScreen.main.bounds.width * 0.65, 275)
- vProperty.titleFontSize = 18.0
- vProperty.titleColor = UIColor.black
- vProperty.detailFontSize = 15.0
- vProperty.detailColor = k999999Color
- vProperty.buttonFontSize = 18.0
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "0"
- // 还有很多参数可设置...
- let alertView = FWAlertView.alert(title: title, detail: nil, inputPlaceholder: nil, keyboardType: .default, isSecureTextEntry: false, customView: nil, items: items, vProperty: vProperty)
- alertView.show()
- }
-
- typealias SureClosure = (_ province :Province ,_ city : City ,_ area :Area) -> Void
-
- /// 自定义sheet省市区
- class func sheetProvinceCityAreaView(sureClosure:@escaping (Province ,City ,Area) -> Void) {
- let provinceCityAreaView = ProvinceCityAreaView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 340))
-
- let vProperty = FWPopupViewProperty()
- vProperty.popupCustomAlignment = .bottomCenter
- vProperty.popupAnimationType = .frame
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "1"
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
- vProperty.animationDuration = 0.5
- provinceCityAreaView.vProperty = vProperty
- provinceCityAreaView.show()
- provinceCityAreaView.sureClosure = {
- (province :Province , city : City , area :Area) in
- provinceCityAreaView.hide(popupDidDisappearBlock: { (popupView) in
- sureClosure(province, city,area)
- })
- }
- }
-
- /// 自定义支付View
- class func payAlertSheetView(paymentAmount:String, cancelClosure:@escaping () -> Void, sureClosure:@escaping (_ pType: PayType) -> Void) {
- let payView = CommonPayView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 300))
- payView.paymentAmount = paymentAmount
- let vProperty = FWPopupViewProperty()
- vProperty.popupCustomAlignment = .bottomCenter
- vProperty.popupAnimationType = .frame
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "0"
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
- vProperty.animationDuration = 0.3
- payView.vProperty = vProperty
- payView.show()
- payView.disTransBlock = {
- cancelClosure()
- payView.hide()
- }
- payView.confirmPayBlock = { payType in
- sureClosure(payType)
- payView.hide()
- }
- }
-
- /// 自定义评论View
- class func commentAlertSheetView(postId:Int, cancelClosure:@escaping () -> Void, sureClosure:@escaping (_ pType: PayType) -> Void) {
- let commentView = CommunityAllCommentView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 500))
- commentView.postId = postId
- let vProperty = FWPopupViewProperty()
- vProperty.popupCustomAlignment = .bottomCenter
- vProperty.popupAnimationType = .frame
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "0"
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
- vProperty.animationDuration = 0.3
- commentView.vProperty = vProperty
- commentView.show()
- commentView.disTransBlock = {
- cancelClosure()
- commentView.hide()
- }
- commentView.confirmPayBlock = { payType in
- sureClosure(payType)
- commentView.hide()
- }
- }
-
- /// 分享
- class func sheetShareView() {
- let view = ShareView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 250))
-
- let vProperty = FWPopupViewProperty()
- vProperty.popupCustomAlignment = .bottomCenter
- vProperty.popupAnimationType = .frame
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "1"
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
- vProperty.animationDuration = 0.2
- view.vProperty = vProperty
- view.show()
- }
-
-
- /// 单个选择器
- class func sheetPickViewOneComponentsView(titles:[String],title:String,height:CGFloat,sureClosure:((_ row: Int,_ value:String) -> Void)?) {
- let view = PickViewOneComponentsView(titles: titles,title: title)
- view.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: height * kScaleWidth + kSafeTabBarHeight)
- let vProperty = FWPopupViewProperty()
- vProperty.popupCustomAlignment = .bottomCenter
- vProperty.popupAnimationType = .frame
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "1"
- view.vProperty = vProperty
- view.sureClosure = { (row,value) in
- sureClosure!(row!,value!)
- view.hide()
- }
- view.show()
- }
-
-
-
- }
- // MARK: - Sheet
- extension AlertSheetView {
- class func sheetDislike(dislike:Int,y:CGFloat,sureClosure:@escaping ((CardContentUserDisLikeView) -> Void)) {
- let view = CardContentUserDisLikeView(frame: CGRect(x: 0, y: 0, width: kScreenWidth-28, height: 50))
- view.isDisLike = dislike
- let vProperty = FWPopupViewProperty()
-
- if y > kScreenHeight/2 {
- vProperty.popupCustomAlignment = .bottomCenter
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: kScreenHeight-y+29, right: 0)
- }else {
- vProperty.popupCustomAlignment = .topCenter
- vProperty.popupViewEdgeInsets = UIEdgeInsets(top: y+51, left: 0, bottom: 0, right: 0)
- }
- vProperty.popupAnimationType = .scale
- vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
- vProperty.touchWildToHide = "1"
- view.vProperty = vProperty
- view.disLikeButtonClosure = {
- view.hide()
- sureClosure(view)
- }
- view.show()
- }
- }
|