|  | @@ -11,12 +11,23 @@ import BFUIKit
 | 
											
												
													
														|  |  import BFMediaKit
 |  |  import BFMediaKit
 | 
											
												
													
														|  |  import BFCommonKit
 |  |  import BFCommonKit
 | 
											
												
													
														|  |  import BFNetRequestKit
 |  |  import BFNetRequestKit
 | 
											
												
													
														|  | 
 |  | +import Alamofire
 | 
											
												
													
														|  | 
 |  | +import MJRefresh
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  enum BFChooseMusicViewClickType {
 |  |  enum BFChooseMusicViewClickType {
 | 
											
												
													
														|  |      case sure, cancle, search
 |  |      case sure, cancle, search
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +struct MusicCategoryModel {
 | 
											
												
													
														|  | 
 |  | +    var id : Int64
 | 
											
												
													
														|  | 
 |  | +    var name: String?
 | 
											
												
													
														|  | 
 |  | +    var page = 1
 | 
											
												
													
														|  | 
 |  | +    mutating func changePage() {
 | 
											
												
													
														|  | 
 |  | +        page += 1
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  class BFChooseMusicView: UIView {
 |  |  class BFChooseMusicView: UIView {
 | 
											
												
													
														|  |      
 |  |      
 | 
											
										
											
												
													
														|  | @@ -30,11 +41,11 @@ class BFChooseMusicView: UIView {
 | 
											
												
													
														|  |          willSet{
 |  |          willSet{
 | 
											
												
													
														|  |              if searchModel != nil {
 |  |              if searchModel != nil {
 | 
											
												
													
														|  |                  if let catogory = categories.first(where: { mod in
 |  |                  if let catogory = categories.first(where: { mod in
 | 
											
												
													
														|  | -                    mod.tagName == "热门"
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    mod.name == "热门"
 | 
											
												
													
														|  |                  }){
 |  |                  }){
 | 
											
												
													
														|  | -                    if let tid = catogory.tagId, let _ = musicDic[tid] {
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    if let _ = musicDic[catogory.id] {
 | 
											
												
													
														|  |                          // 找到热门的数组
 |  |                          // 找到热门的数组
 | 
											
												
													
														|  | -                        musicDic[tid]?.removeFirst()
 |  | 
 | 
											
												
													
														|  | 
 |  | +                        musicDic[catogory.id]?.removeFirst()
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -42,14 +53,14 @@ class BFChooseMusicView: UIView {
 | 
											
												
													
														|  |          didSet {
 |  |          didSet {
 | 
											
												
													
														|  |              if let searchModel = searchModel {
 |  |              if let searchModel = searchModel {
 | 
											
												
													
														|  |                  if let catogory = categories.first(where: { mod in
 |  |                  if let catogory = categories.first(where: { mod in
 | 
											
												
													
														|  | -                    mod.tagName == "热门"
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    mod.name == "热门"
 | 
											
												
													
														|  |                  }){
 |  |                  }){
 | 
											
												
													
														|  | -                    if let tid = catogory.tagId, let list = musicDic[tid] {
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    if let list = musicDic[catogory.id] {
 | 
											
												
													
														|  |                          var arr = [PQVoiceModel]()
 |  |                          var arr = [PQVoiceModel]()
 | 
											
												
													
														|  |                          arr.append(searchModel)
 |  |                          arr.append(searchModel)
 | 
											
												
													
														|  |                          if list.first?.musicId != searchModel.musicId {
 |  |                          if list.first?.musicId != searchModel.musicId {
 | 
											
												
													
														|  |                              arr.append(contentsOf: list)
 |  |                              arr.append(contentsOf: list)
 | 
											
												
													
														|  | -                            musicDic[tid] = arr
 |  | 
 | 
											
												
													
														|  | 
 |  | +                            musicDic[catogory.id] = arr
 | 
											
												
													
														|  |                              searchModel.isSelected = true
 |  |                              searchModel.isSelected = true
 | 
											
												
													
														|  |                              chosedMusic?.isSelected = false
 |  |                              chosedMusic?.isSelected = false
 | 
											
												
													
														|  |                              chosedMusic = searchModel
 |  |                              chosedMusic = searchModel
 | 
											
										
											
												
													
														|  | @@ -64,8 +75,9 @@ class BFChooseMusicView: UIView {
 | 
											
												
													
														|  |      // 选择的音乐类别
 |  |      // 选择的音乐类别
 | 
											
												
													
														|  |      var categorySelectIndex : Int = 1
 |  |      var categorySelectIndex : Int = 1
 | 
											
												
													
														|  |      
 |  |      
 | 
											
												
													
														|  | 
 |  | +    var currPage : Int64 = 1
 | 
											
												
													
														|  |      // 音乐类别
 |  |      // 音乐类别
 | 
											
												
													
														|  | -    var categories = [PQStuckPointMusicTagsModel]()
 |  | 
 | 
											
												
													
														|  | 
 |  | +    var categories = [MusicCategoryModel]()
 | 
											
												
													
														|  |      
 |  |      
 | 
											
												
													
														|  |      var musicVolume = 0.0 {
 |  |      var musicVolume = 0.0 {
 | 
											
												
													
														|  |          didSet{
 |  |          didSet{
 | 
											
										
											
												
													
														|  | @@ -136,8 +148,15 @@ class BFChooseMusicView: UIView {
 | 
											
												
													
														|  |          tb.dataSource = self
 |  |          tb.dataSource = self
 | 
											
												
													
														|  |          tb.separatorColor = UIColor.hexColor(hexadecimal: "#272727")
 |  |          tb.separatorColor = UIColor.hexColor(hexadecimal: "#272727")
 | 
											
												
													
														|  |          tb.register(BFMuicInfoCell.self, forCellReuseIdentifier: "BFMuicInfoCell")
 |  |          tb.register(BFMuicInfoCell.self, forCellReuseIdentifier: "BFMuicInfoCell")
 | 
											
												
													
														|  | -        tb.tableFooterView = UIView()
 |  | 
 | 
											
												
													
														|  |          tb.backgroundColor = .clear
 |  |          tb.backgroundColor = .clear
 | 
											
												
													
														|  | 
 |  | +        tb.mj_footer = MJRefreshAutoFooter.init(refreshingBlock: {[weak self] in
 | 
											
												
													
														|  | 
 |  | +            guard let wself = self else { return }
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  | 
 |  | +            let cate = wself.categories[wself.categorySelectIndex]
 | 
											
												
													
														|  | 
 |  | +            if (wself.musicDic[cate.id]?.count ?? 0) > 0 {
 | 
											
												
													
														|  | 
 |  | +                wself.getMusicsForCategory()
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        })
 | 
											
												
													
														|  |          return tb
 |  |          return tb
 | 
											
												
													
														|  |      }()
 |  |      }()
 | 
											
												
													
														|  |      
 |  |      
 | 
											
										
											
												
													
														|  | @@ -238,79 +257,95 @@ class BFChooseMusicView: UIView {
 | 
											
												
													
														|  |      required init?(coder: NSCoder) {
 |  |      required init?(coder: NSCoder) {
 | 
											
												
													
														|  |          fatalError("init(coder:) has not been implemented")
 |  |          fatalError("init(coder:) has not been implemented")
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    //MARK: - 请求数据
 | 
											
												
													
														|  |      func prepareData() {
 |  |      func prepareData() {
 | 
											
												
													
														|  | -        BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + stuckPointMusicCategoryUrl, parames: ["parentTagId": 0], commonParams: commonParams(), isJsonEncodingNormal: true, timeoutInterval: 15) {[weak self] response, _, error, _ in
 |  | 
 | 
											
												
													
														|  | 
 |  | +        let categoryListUrl = "produce-center/bgm/app/getAllBgmCates"
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  | 
 |  | +        BFNetRequestAdaptor.postRequestData(url: onlinePQTvApi + categoryListUrl, parames: [:], commonParams: ["baseInfo":commonParams()], encoding: JSONEncoding.default, isJsonEncodingNormal: false, timeoutInterval: 15) {[weak self] response, _, error, _ in
 | 
											
												
													
														|  |              guard let wself = self else { return }
 |  |              guard let wself = self else { return }
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | -            var tagsList = Array<PQStuckPointMusicTagsModel>.init()
 |  | 
 | 
											
												
													
														|  | 
 |  | +            var tagsList = [MusicCategoryModel]()
 | 
											
												
													
														|  |              if response is NSNull || response == nil {
 |  |              if response is NSNull || response == nil {
 | 
											
												
													
														|  |                  cShowHUB(superView: nil, msg: "音乐分类获取失败")
 |  |                  cShowHUB(superView: nil, msg: "音乐分类获取失败")
 | 
											
												
													
														|  |                  return
 |  |                  return
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              let tagsTempArr = response as? [[String: Any]]
 |  |              let tagsTempArr = response as? [[String: Any]]
 | 
											
												
													
														|  | -            if tagsTempArr != nil, (tagsTempArr?.count ?? 0) > 0 {  
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if tagsTempArr != nil, (tagsTempArr?.count ?? 0) > 0 {
 | 
											
												
													
														|  |                  for dict in tagsTempArr! {
 |  |                  for dict in tagsTempArr! {
 | 
											
												
													
														|  | -                    let tempMusic = PQStuckPointMusicTagsModel(jsonDict: dict)
 |  | 
 | 
											
												
													
														|  | -                    tempMusic.parentTagId = 0
 |  | 
 | 
											
												
													
														|  | -                    tagsList.append(tempMusic)
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    let cid = (dict["cateId"] as? Int64 ?? 0)
 | 
											
												
													
														|  | 
 |  | +                    if cid > 0 {
 | 
											
												
													
														|  | 
 |  | +                        let tempMusic = MusicCategoryModel(id: cid, name: dict["cateName"] as? String)
 | 
											
												
													
														|  | 
 |  | +                        tagsList.append(tempMusic)
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -            tagsList.first?.isSelected = true
 |  | 
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | -            let tempMusic = PQStuckPointMusicTagsModel()
 |  | 
 | 
											
												
													
														|  | -            tempMusic.tagId = -1
 |  | 
 | 
											
												
													
														|  | 
 |  | +            let tempMusic = MusicCategoryModel(id: -1, name: "")
 | 
											
												
													
														|  |              tagsList.insert(tempMusic, at: 0)
 |  |              tagsList.insert(tempMusic, at: 0)
 | 
											
												
													
														|  |              wself.categories.append(contentsOf: tagsList)
 |  |              wself.categories.append(contentsOf: tagsList)
 | 
											
												
													
														|  |              wself.categoryView.reloadData()
 |  |              wself.categoryView.reloadData()
 | 
											
												
													
														|  |              if wself.categories.count > 1 {
 |  |              if wself.categories.count > 1 {
 | 
											
												
													
														|  |                  wself.categorySelectIndex = 1
 |  |                  wself.categorySelectIndex = 1
 | 
											
												
													
														|  | -                if let firstTagid = wself.categories[1].tagId{
 |  | 
 | 
											
												
													
														|  | -                    wself.getMusicsForCategory(tagId:firstTagid, pageNum: 1)
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | 
 |  | +                wself.getMusicsForCategory()
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      
 |  |      
 | 
											
												
													
														|  | -    func getMusicsForCategory(tagId:Int64, pageNum:Int64) {
 |  | 
 | 
											
												
													
														|  | -        BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + stuckPointMusicPageUrl, parames: ["tagId": tagId, "parentTagId": 0, "pageNum": pageNum, "pageSize": 20], commonParams: commonParams()) {[weak self] response, _, error, _ in
 |  | 
 | 
											
												
													
														|  | 
 |  | +    func getMusicsForCategory() {
 | 
											
												
													
														|  | 
 |  | +        let musicListUrl = "produce-center/bgm/pageCateBgm"
 | 
											
												
													
														|  | 
 |  | +        var cate = categories[categorySelectIndex]
 | 
											
												
													
														|  | 
 |  | +        BFNetRequestAdaptor.postRequestData(url: onlinePQTvApi + musicListUrl, parames: ["cateId": cate.id, "pageNum": cate.page, "pageSize": 20], commonParams: commonParams(), encoding: JSONEncoding.default) {[weak self] response, _, error, _ in
 | 
											
												
													
														|  |              guard let wself = self else { return }
 |  |              guard let wself = self else { return }
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | -            var musicPageList = [PQVoiceModel]()
 |  | 
 | 
											
												
													
														|  | 
 |  | +            wself.musicTb.mj_footer?.endRefreshing()
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  |              if response is NSNull || response == nil {
 |  |              if response is NSNull || response == nil {
 | 
											
												
													
														|  |                  cShowHUB(superView: nil, msg: "该分类下无音乐")
 |  |                  cShowHUB(superView: nil, msg: "该分类下无音乐")
 | 
											
												
													
														|  |                  return
 |  |                  return
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | -            if wself.musicDic[tagId] == nil {
 |  | 
 | 
											
												
													
														|  | -                wself.musicDic[tagId] = [PQVoiceModel]()
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if wself.musicDic[cate.id] == nil {
 | 
											
												
													
														|  | 
 |  | +                wself.musicDic[cate.id] = [PQVoiceModel]()
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | -            let oldDataMusic : [PQVoiceModel] = wself.musicDic[tagId]!
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            var musicPageList = [PQVoiceModel]()
 | 
											
												
													
														|  | 
 |  | +            let oldDataMusic : [PQVoiceModel] = wself.musicDic[cate.id]!
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | -            if let tempArr = response as? [[String: Any]], tempArr.count > 0 {
 |  | 
 | 
											
												
													
														|  | -                for (_, dict) in tempArr.enumerated() {
 |  | 
 | 
											
												
													
														|  | -                    let tempMusic = PQVoiceModel(jsonDict: dict)
 |  | 
 | 
											
												
													
														|  | -                    tempMusic.cacheTagID = tagId
 |  | 
 | 
											
												
													
														|  | -                    if tempMusic.endTime <= tempMusic.startTime {
 |  | 
 | 
											
												
													
														|  | -                        tempMusic.endTime = tempMusic.startTime + 40
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if let dict = response as? [String: Any] {
 | 
											
												
													
														|  | 
 |  | +                if let tempArr = dict["objs"] as? [[String: Any]] , tempArr.count > 0 {
 | 
											
												
													
														|  | 
 |  | +                    for (_, dic) in tempArr.enumerated() {
 | 
											
												
													
														|  | 
 |  | +                        let tempMusic = PQVoiceModel(jsonDict: dic)
 | 
											
												
													
														|  | 
 |  | +                        tempMusic.cacheTagID = cate.id
 | 
											
												
													
														|  | 
 |  | +                        if tempMusic.endTime <= tempMusic.startTime {
 | 
											
												
													
														|  | 
 |  | +                            tempMusic.endTime = tempMusic.startTime + 40
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  | 
 |  | +                        
 | 
											
												
													
														|  | 
 |  | +                        let haveIndex = oldDataMusic.firstIndex(where: { (music) -> Bool in
 | 
											
												
													
														|  | 
 |  | +                            music.musicId == tempMusic.musicId
 | 
											
												
													
														|  | 
 |  | +                        })
 | 
											
												
													
														|  | 
 |  | +                        if haveIndex == nil {
 | 
											
												
													
														|  | 
 |  | +                            musicPageList.append(tempMusic)
 | 
											
												
													
														|  | 
 |  | +                        }
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                    let haveIndex = oldDataMusic.firstIndex(where: { (music) -> Bool in
 |  | 
 | 
											
												
													
														|  | -                        music.musicId == tempMusic.musicId
 |  | 
 | 
											
												
													
														|  | -                    })
 |  | 
 | 
											
												
													
														|  | -                    if haveIndex == nil {
 |  | 
 | 
											
												
													
														|  | -                        musicPageList.append(tempMusic)
 |  | 
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                
 | 
											
												
													
														|  | 
 |  | +                if musicPageList.count > 0 {
 | 
											
												
													
														|  | 
 |  | +                    if let ind = wself.categories.firstIndex(where: {$0.id == cate.id}) {
 | 
											
												
													
														|  | 
 |  | +                        wself.categories[ind].changePage()
 | 
											
												
													
														|  | 
 |  | +                        
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  | 
 |  | +                    wself.musicDic[cate.id]!.append(contentsOf: musicPageList)
 | 
											
												
													
														|  | 
 |  | +                    if cate.id == wself.categories[wself.categorySelectIndex].id{
 | 
											
												
													
														|  | 
 |  | +                        wself.musicTb.reloadData()
 | 
											
												
													
														|  |                      }
 |  |                      }
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            
 |  | 
 | 
											
												
													
														|  | -            if musicPageList.count > 0 {
 |  | 
 | 
											
												
													
														|  | -                wself.musicDic[tagId]!.append(contentsOf: musicPageList)
 |  | 
 | 
											
												
													
														|  | -                if tagId == wself.categories[wself.categorySelectIndex].tagId{
 |  | 
 | 
											
												
													
														|  | -                    wself.musicTb.reloadData()
 |  | 
 | 
											
												
													
														|  | 
 |  | +                if (dict["totalSize"] as? Int64 ?? 0) <= (dict["offset"] as? Int64 ?? -1) {
 | 
											
												
													
														|  | 
 |  | +                    // 不再需要数据拉新
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      
 |  |      
 | 
											
										
											
												
													
														|  | @@ -384,7 +419,8 @@ extension BFChooseMusicView:UITableViewDelegate, UITableViewDataSource {
 | 
											
												
													
														|  |                  wself.cutActionCallback?(data)
 |  |                  wself.cutActionCallback?(data)
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        if let tagid = categories[categorySelectIndex].tagId, let arr = musicDic[tagid] {
 |  | 
 | 
											
												
													
														|  | 
 |  | +        let tagid = categories[categorySelectIndex].id
 | 
											
												
													
														|  | 
 |  | +        if let arr = musicDic[tagid] {
 | 
											
												
													
														|  |              cell.data = arr[indexPath.row]
 |  |              cell.data = arr[indexPath.row]
 | 
											
												
													
														|  |              if cell.data?.isSelected ?? false {
 |  |              if cell.data?.isSelected ?? false {
 | 
											
												
													
														|  |                  chosedIndexPath = indexPath
 |  |                  chosedIndexPath = indexPath
 | 
											
										
											
												
													
														|  | @@ -404,7 +440,7 @@ extension BFChooseMusicView:UITableViewDelegate, UITableViewDataSource {
 | 
											
												
													
														|  |      
 |  |      
 | 
											
												
													
														|  |      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
 |  |      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
 | 
											
												
													
														|  |          if categories.count > 1 {
 |  |          if categories.count > 1 {
 | 
											
												
													
														|  | -            return musicDic[categories[categorySelectIndex].tagId ?? 0]?.count ?? 0
 |  | 
 | 
											
												
													
														|  | 
 |  | +            return musicDic[categories[categorySelectIndex].id]?.count ?? 0
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return 0
 |  |          return 0
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
										
											
												
													
														|  | @@ -492,7 +528,7 @@ extension BFChooseMusicView : UICollectionViewDelegate, UICollectionViewDataSour
 | 
											
												
													
														|  |              oldCell?.isChoosed = false
 |  |              oldCell?.isChoosed = false
 | 
											
												
													
														|  |              newCell?.isChoosed = true
 |  |              newCell?.isChoosed = true
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  | -            getMusicsForCategory(tagId: categories[categorySelectIndex].tagId ?? 0, pageNum: 1)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            getMusicsForCategory()
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |          }else {
 |  |          }else {
 | 
											
												
													
														|  |              cancelChooseMusic()
 |  |              cancelChooseMusic()
 | 
											
										
											
												
													
														|  | @@ -508,7 +544,7 @@ extension BFChooseMusicView: BFFlowLayoutDelegate{
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          var itemWidth = 30.0
 |  |          var itemWidth = 30.0
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  | -        if let title = categories[indexPath.row].tagName, title.count > 0{
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if let title = categories[indexPath.row].name, title.count > 0{
 | 
											
												
													
														|  |              let ww = title.textAutoWidth(height: 20, font: UIFont.systemFont(ofSize: 15, weight: .regular))
 |  |              let ww = title.textAutoWidth(height: 20, font: UIFont.systemFont(ofSize: 15, weight: .regular))
 | 
											
												
													
														|  |              itemWidth = max(30.0, ww)
 |  |              itemWidth = max(30.0, ww)
 | 
											
												
													
														|  |          }
 |  |          }
 |