123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- //
- // MCNavBarDelegate.swift
- // HCQuanfangtong
- //
- // Created by Apple on 2022/2/10.
- // Copyright © 2022 Jyp. All rights reserved.
- //
- import Foundation
- import RxSwift
- import RxCocoa
- import UIKit
- protocol MCNavBarDelegate: UIView{
-
- /// 样式
- var navStyle: MCNavBarStyle {get}
-
- /// 透明样式 != nil 包含透明样式
- var navTransparentStyle: MCNavBarTransparentColorStyle? { get set }
-
- /// 透明样式绑定的scrollView
- var navTransparentBinderedScrollView: UIScrollView? { get set }
-
- /// 高度
- var navBarHeightSubject: BehaviorSubject<CGFloat> { get }
-
- /// 返回按钮方法
- var navBarBackBlock: (()->Void)? {get set}
-
- /// 是否显示返回按钮
- var showNavBackBtn: Bool {get set}
-
- /// bar 高度
- func navBarHeight() -> CGFloat
-
- /// 设置标题
- /// - Parameter title: 标题文本,seachBar value or segment Index
- func setNavTitle(_ title: String?)
- func setNavSubTitle(_ title: String?)
-
-
- /// 设置右边按钮的标题 图片
- /// - Parameters:
- /// - title: <#title description#>
- /// - image: <#image description#>
- /// - index: <#index description#>
- func setNavRightBtnTitle(_ title: String?, image: String?, at index: Int)
- func setNavLeftBtnTitle(_ title: String?, image: String?, at index: Int)
-
- /// 新增按钮
- /// - Parameters:
- /// - title: <#title description#>
- /// - image: <#image description#>
- /// - tap: <#tap description#>
- /// - semantic
- /// - index: <#index description#>
- func insertNavRightBtn(_ title: String?, image: String?, tap: (()->Void)?, semantic: UISemanticContentAttribute?, at index: Int)
- func insertNavLeftBtn(_ title: String?, image: String?, tap: (()->Void)?, semantic: UISemanticContentAttribute?, at index: Int)
-
-
- /// 设置隐藏
- /// - Parameters:
- /// - hidden: <#hidden description#>
- /// - index: <#index description#>
- func setNavRightBtnHidden(_ hidden: Bool, at index: Int)
- func setNavLeftBtnHidden(_ hidden: Bool, at index: Int)
-
-
- /// 删除按钮
- /// - Parameter index: <#index description#>
- func deleteNavRightBtn(at index: Int)
-
- /// 删除左边按钮 不可以删除返回按钮,可以操作隐藏
- /// - Parameter index: <#index description#>
- func deleteNavLeftBtn(at index: Int)
-
- /// 获取右侧按钮的位置
- /// - Parameter index: <#index description#>
- func getNavRightBtnFrame(at index: Int) -> CGRect?
-
- /// 获取左侧按钮的位置
- /// - Parameter index: <#index description#>
- func getNavLeftBtnFrame(at index: Int) -> CGRect?
-
- /// 设置右边按钮 透明导航 图片
- /// - Parameters:
- /// - img: <#img description#>
- /// - index: <#index description#>
- func setNavRightBtnTransparentImage(_ img: String, at index: Int)
-
- /// 设置左边按钮 透明导航 图片
- /// - Parameters:
- /// - img: <#img description#>
- /// - index: <#index description#>
- func setNavLeftBtnTransparentImage(_ img: String, at index: Int)
-
-
- }
- class MCNavBarStyle: NSObject{
-
- var styleForBackgroundColor: UIColor = kThemeBlackColor
-
- var styleForTitleFont: UIFont = UIFont.pingFangSC(withWeight: FontWeightStyle.medium, size: 19)
- var styleForTitleColor: UIColor = kThemeWhiteColor
-
- var styleForSubTitleFont: UIFont = UIFont.pingFangSC(withWeight: FontWeightStyle.medium, size: 13)
- var styleForSubTitleColor: UIColor = UIColor.init(red: 1, green: 1, blue: 1, alpha: 0.6)
-
- var styleForBtnTitleColor: UIColor = kThemeWhiteColor
- var styleForBtnTitleFont: UIFont = UIFont.pingFangSC(withWeight: FontWeightStyle.medium, size: 16)
-
- /// 内容边距
- var styleForContentEdge: UIEdgeInsets = UIEdgeInsets.init(top: 0, left: 10, bottom: 0, right: 10)
-
- /// 按钮最小点击区域宽度
- var styleForTapMinWidth: CGFloat = 30
-
- /// 文字和图片的距离
- var styleForBtnTitleAndImageDistance: CGFloat = 2
-
- var styleForBtnEdgeInset: UIEdgeInsets = UIEdgeInsets.init(top: 0, left: 2, bottom: 0, right: 2)
-
- /// 元素间距
- var styleForElementSpace: CGFloat = 5
-
- /// 标题和子标题的间距
- var styleForTitleAndSubTitleDistance: CGFloat = 5
-
- /// 返回图片
- var styleForBackImage: UIImage = UIImage.init(named: "白色返回")!
-
- /// 返回按钮的内边距
- var styleForBackEdgeInset: UIEdgeInsets = UIEdgeInsets.init(top: 0, left: 16, bottom: 0, right: 2)
-
- var styleForBackMinWidth: CGFloat = 60
-
-
- /// 中间区域是否居中,默认居中
- var styleForContentViewIsMiddle: Bool = true
-
- /// -1 代表不限制宽度
- var styleForContentViewWidth: CGFloat = -1
-
- /// 当出现需要放大显示时,采用此放大比例
- var styleForScaling: CGFloat = 1.2
-
- /// 放大之前的字体颜色
- var styleForScalingBeforeTitleColor: UIColor = UIColor.init(red: 1, green: 1, blue: 1, alpha: 0.6)
-
- /// <#Description#>
- var styleForSearchHeight: CGFloat = 30
-
- /// input样式的背景颜色
- var styleForSearchBackgroundColor: UIColor = kThemeWhiteColor
-
- /// input样式的背景颜色搜索图片样式
- var styleForSearchSearchImage: UIImage = UIImage.init(named: "new_search_gray")!
-
- /// input样式placeholderColor
- var styleForSearchPlaceholderColor: UIColor = kThemeOfTextPlaceholderColor
-
- /// input样式输入框的文本大小
- var styleForSearchTextFont: UIFont = UIFont.pingFangSC(withWeight: FontWeightStyle.regular, size: 14)
-
- static var whiteStyle: MCNavBarStyle = {
- let style = MCNavBarStyle()
- style.styleForBackgroundColor = kThemeWhiteColor
- style.styleForTitleColor = kThemeOfTextBlackColor
- style.styleForScalingBeforeTitleColor = kThemeOfTextLightColor
- style.styleForBtnTitleColor = kThemeOfTextBlackColor
- style.styleForBackImage = UIImage.init(named: "icon_back_white_nav_bar")!
- // style.styleForContentEdge = UIEdgeInsets.init(top: 0, left: 16, bottom: 0, right: 16)
- return style
- }()
- }
- /// 透明颜色样式
- class MCNavBarTransparentColorStyle: NSObject{
-
- static var blackStyle: MCNavBarTransparentColorStyle = {
- let style = MCNavBarTransparentColorStyle.init()
- style.styleForBackgroundColor = UIColor.clear
- style.styleForTitleColor = kThemeOfTextBlackColor
- style.styleForSubTitleColor = kThemeOfTextBlackColor
- style.styleForBtnTitleColor = kThemeOfTextBlackColor
- style.styleForBackImage = UIImage.init(named: "渠道选择返回箭头")!
- return style
- }()
-
- /// 滑动距离 当达到此值时切换为正常的navBar
- var styleForScrollDistanceChange: CGFloat = 100
-
- var styleForBackgroundColor: UIColor = UIColor.clear
- var styleForTitleColor: UIColor = kThemeWhiteColor
- var styleForSubTitleColor: UIColor = UIColor.init(red: 1, green: 1, blue: 1, alpha: 0.6)
- var styleForBtnTitleColor: UIColor = kThemeWhiteColor
- var styleForBackImage: UIImage = UIImage.init(named: "箭头返回")!
-
- }
- /// 任何按钮都可以关联弹窗的代理,以操作弹窗显示,消失,以及获取选定的字符串和位置
- protocol MCPopBeAssociatedDelegate : NSObjectProtocol{
-
- /// 是否显示
- var isShow: Bool! {get}
-
- /// 信号 : show or hidden
- var binderIsShow: PublishSubject<Bool>! {get}
-
- /// 信号 : 单选
- var binderValue: PublishSubject<MCPopSelectedModel?>? {get}
-
- /// 信号 : 单选 多选
- var binderValues: PublishSubject<[MCPopSelectedModel]?>? {get}
-
- /// 发送信号 binderValues 会自动发送信号
- /// - Parameter str: <#str description#>
- func sendSingle(with str: String)
-
- /// 设置数据源
- /// - Parameter sources: <#sources description#>
- func setDataSource<T>(with sources: T) -> Bool
-
- /// 获取数据源
- /// - Returns: <#description#>
- func getDataSource() -> Any?
-
- /// 显示
- @discardableResult
- func show() -> Self
-
- /// 隐藏
- func hidden()
-
- }
- /// 弹窗选定的值
- @objcMembers class MCPopSelectedModel: NSObject{
-
- /// 字符串
- var name: String?
-
- /// 在数据源的位置,有可能为空
- var index: NSNumber?
-
- /// 有可能为空
- var id: String?
-
- /// 初始化
- /// - Parameters:
- /// - name: <#name description#>
- /// - index: <#index description#>
- init(name: String?, index: NSNumber? = nil, id: String? = nil){
- self.name = name
- self.index = index
- self.id = id
- super.init()
- }
-
- override var description: String{
- "name = \(String(describing: self.name)), index = \(String(describing: self.index)), id = \(String(describing: self.id))"
- }
-
- }
- @objcMembers public class MCPopSourceModel: NSObject{
-
- /// 名字
- var name: String?
-
- /// id值
- var id: String?
-
- /// 子数据源
- var subItems: [MCPopSourceModel]?
-
- convenience init(name: String?, id: String?){
- self.init(name: name, id: id, subItems: nil)
- }
-
- init(name: String?, id: String?, subItems: [MCPopSourceModel]?){
- self.name = name
- self.id = id
- self.subItems = subItems
- super.init()
- }
-
- }
|