Commit 24796ab2a73dfdfbfa02d6701d100c2b9add3b24
1 parent
8ba7d542
首页支持 短剧 , 课程 区块
Showing
9 changed files
with
511 additions
and
153 deletions
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNSlideBaseNavigationController.swift
| ... | ... | @@ -10,6 +10,18 @@ import Foundation |
| 10 | 10 | class CNSlideBaseNavigationController: UINavigationController |
| 11 | 11 | ,UIViewControllerTransitioningDelegate { |
| 12 | 12 | var dismissClosure: (()->())? |
| 13 | + var cellType:CNLiveHomePageCellType = .course | |
| 14 | + | |
| 15 | + init(rootViewController: UIViewController,cellType:CNLiveHomePageCellType) { | |
| 16 | + super.init(rootViewController: rootViewController) | |
| 17 | + self.cellType = cellType | |
| 18 | + | |
| 19 | + } | |
| 20 | + | |
| 21 | + required init?(coder aDecoder: NSCoder) { | |
| 22 | + fatalError("init(coder:) has not been implemented") | |
| 23 | + } | |
| 24 | + | |
| 13 | 25 | override func viewDidLoad() { |
| 14 | 26 | super.viewDidLoad() |
| 15 | 27 | modalPresentationStyle = .custom |
| ... | ... | @@ -17,11 +29,11 @@ class CNSlideBaseNavigationController: UINavigationController |
| 17 | 29 | } |
| 18 | 30 | |
| 19 | 31 | func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { |
| 20 | - return CNUpSlideAnimationTransition(animationType: .present) | |
| 32 | + return CNUpSlideAnimationTransition(animationType: .present, cellType: self.cellType) | |
| 21 | 33 | } |
| 22 | 34 | |
| 23 | 35 | func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { |
| 24 | - return CNUpSlideAnimationTransition(animationType: .dismiss) | |
| 36 | + return CNUpSlideAnimationTransition(animationType: .dismiss, cellType: self.cellType) | |
| 25 | 37 | } |
| 26 | 38 | |
| 27 | 39 | func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { | ... | ... |
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideDetailViewController.swift
| ... | ... | @@ -3,11 +3,24 @@ |
| 3 | 3 | // metaCode |
| 4 | 4 | // |
| 5 | 5 | // Created by zx on 2023/10/16. |
| 6 | -// 下滑页原生页--大图点击详情页 | |
| 6 | +// 下滑页原生页--课程 大图点击详情页 | |
| 7 | +// 首页原生页--短剧 大图详情页 | |
| 7 | 8 | |
| 8 | 9 | import Foundation |
| 10 | +import MJRefresh | |
| 11 | +import EmptyDataSet_Swift | |
| 9 | 12 | |
| 10 | -class CNUpSlideDetailViewController: CNLiveBaseViewController { | |
| 13 | +///首页课程或短剧类型 | |
| 14 | +enum CNLiveHomePageCellType { | |
| 15 | + ///课程控制器->课程 | |
| 16 | + case course | |
| 17 | + ///短剧控制器->短剧 | |
| 18 | + case playlet | |
| 19 | + ///短剧控制器->课程 | |
| 20 | + case playletToCourse | |
| 21 | +} | |
| 22 | + | |
| 23 | +class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSource, UITableViewDelegate,EmptyDataSetSource, EmptyDataSetDelegate { | |
| 11 | 24 | |
| 12 | 25 | //slideModel |
| 13 | 26 | var _slideModel : CNLiveDownSlideModel? |
| ... | ... | @@ -20,6 +33,8 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController { |
| 20 | 33 | } |
| 21 | 34 | } |
| 22 | 35 | |
| 36 | + var cellType: CNLiveHomePageCellType = .course | |
| 37 | + | |
| 23 | 38 | var dismissClosure: (()->())? |
| 24 | 39 | //the point when start to interactive |
| 25 | 40 | var interactiveStartingPoint: CGPoint? = nil |
| ... | ... | @@ -54,7 +69,9 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController { |
| 54 | 69 | return btn |
| 55 | 70 | }() |
| 56 | 71 | |
| 57 | - init(cell: CNDownSlideSingleCourseCell,slideModel:CNLiveDownSlideModel) { | |
| 72 | + init(cell: CNDownSlideSingleCourseCell,slideModel:CNLiveDownSlideModel,cellType:CNLiveHomePageCellType) { | |
| 73 | + self.cellType = cellType | |
| 74 | + self.pageNum = 1 | |
| 58 | 75 | self.cell = cell |
| 59 | 76 | super.init(nibName: nil, bundle: nil) |
| 60 | 77 | self.slideModel = slideModel |
| ... | ... | @@ -75,12 +92,20 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController { |
| 75 | 92 | super.viewDidLoad() |
| 76 | 93 | setupUI() |
| 77 | 94 | getImageFromCell() |
| 95 | + if self.cellType == .playlet{ | |
| 96 | + self.getBlockContents(page: 1) | |
| 97 | + } | |
| 78 | 98 | } |
| 79 | 99 | |
| 80 | 100 | private func setupUI() { |
| 81 | 101 | self.view.layer.masksToBounds = true |
| 82 | - view.addSubview(scrollView) | |
| 83 | - scrollView.slideModel = _slideModel | |
| 102 | + if self.cellType == .playlet{ | |
| 103 | + self.view.addSubview(self.tableView) | |
| 104 | + self.tableView.frame = CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight) | |
| 105 | + }else{ | |
| 106 | + view.addSubview(scrollView) | |
| 107 | + scrollView.slideModel = _slideModel | |
| 108 | + } | |
| 84 | 109 | view.addSubview(closeBtn) |
| 85 | 110 | view.addGestureRecognizer(dismissPanGesture) |
| 86 | 111 | |
| ... | ... | @@ -128,7 +153,6 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController { |
| 128 | 153 | dismiss(animated: true, completion: nil) |
| 129 | 154 | let nav = self.navigationController as! CNSlideBaseNavigationController |
| 130 | 155 | nav.dismissClosure?() |
| 131 | -// dismissClosure?() | |
| 132 | 156 | stopDismissPanGesture(gesture) |
| 133 | 157 | return |
| 134 | 158 | } |
| ... | ... | @@ -160,17 +184,132 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController { |
| 160 | 184 | gesture.view?.transform = CGAffineTransform.identity |
| 161 | 185 | } |
| 162 | 186 | } |
| 187 | + | |
| 188 | + // MARK: - 短剧cell列表详情页 | |
| 189 | + let kCNLiveAlbumImageCellIdentifier = "kCNLiveAlbumImageCellIdentifier" | |
| 190 | + let kCNLiveAlbumCellIdentifier = "kCNLiveAlbumCellIdentifier" | |
| 191 | + | |
| 192 | + var pageNum: NSInteger | |
| 193 | + var network_type: CNLiveMineResponseType! | |
| 194 | + // MARK: - 懒加载 | |
| 195 | + ///数据源 | |
| 196 | + lazy var dataArray: NSMutableArray = { | |
| 197 | + var dataArray = NSMutableArray() | |
| 198 | + return dataArray | |
| 199 | + }() | |
| 200 | + lazy var tableView : UITableView = { | |
| 201 | + let tableView = UITableView(frame: .zero, style: .plain) | |
| 202 | + tableView.dataSource = self | |
| 203 | + tableView.delegate = self | |
| 204 | + tableView.emptyDataSetSource = self | |
| 205 | + tableView.emptyDataSetDelegate = self | |
| 206 | + tableView.separatorStyle = .none | |
| 207 | + tableView.tableFooterView = UIView.init() | |
| 208 | + tableView.register(CNLiveAlbumCell.self, forCellReuseIdentifier: kCNLiveAlbumCellIdentifier) | |
| 209 | + tableView.register(CNLiveAlbumImageCell.self, forCellReuseIdentifier: kCNLiveAlbumImageCellIdentifier) | |
| 210 | + return tableView | |
| 211 | + }() | |
| 212 | + | |
| 213 | + | |
| 214 | + func numberOfSections(in tableView: UITableView) -> Int { | |
| 215 | + 2 | |
| 216 | + } | |
| 217 | + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| 218 | + if section == 0{ | |
| 219 | + return 1 | |
| 220 | + }else{ | |
| 221 | + return self.dataArray.count | |
| 222 | + } | |
| 223 | + } | |
| 224 | + | |
| 225 | + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| 226 | + | |
| 227 | + if indexPath.section == 0{ | |
| 228 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveAlbumImageCellIdentifier) as? CNLiveAlbumImageCell | |
| 229 | + else { | |
| 230 | + let cell = CNLiveAlbumImageCell() | |
| 231 | + return cell | |
| 232 | + } | |
| 233 | + cell.iconImgView.image = self.cell.bgImageView.image | |
| 234 | + return cell | |
| 235 | + }else{ | |
| 236 | + let albumModel = self.dataArray[indexPath.row] as! CNLiveAlbumModel | |
| 237 | + | |
| 238 | + guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveAlbumCellIdentifier) as? CNLiveAlbumCell | |
| 239 | + else { | |
| 240 | + let cell = CNLiveAlbumCell() | |
| 241 | + return cell | |
| 242 | + } | |
| 243 | + cell.albumModel = albumModel | |
| 244 | + return cell | |
| 245 | + } | |
| 246 | + } | |
| 247 | + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
| 248 | + if indexPath.section == 0{ | |
| 249 | + return KSreenWidth | |
| 250 | + }else{ | |
| 251 | + return 75 | |
| 252 | + } | |
| 253 | + } | |
| 254 | + | |
| 255 | + // MARK: - 获取全部专辑列表 | |
| 256 | + func getBlockContents(page:NSInteger){ | |
| 257 | + showLoading(message: "") | |
| 258 | + CNLiveHomePageViewModel.getBlockContents(blockId: self.slideModel!.blockId ?? "", page: page) {[weak self] result, status in | |
| 259 | + hiddenLoading() | |
| 260 | + if status == .success{ | |
| 261 | + if self!.pageNum > 1 { | |
| 262 | + self!.dataArray.addObjects(from: result as! [CNLiveAlbumModel]) | |
| 263 | + } | |
| 264 | + if self!.pageNum == 1 { | |
| 265 | + self!.dataArray.removeAllObjects() | |
| 266 | + self!.dataArray.addObjects(from: result as! [CNLiveAlbumModel]) | |
| 267 | + if self!.dataArray.count > 0 && self!.tableView.mj_header == nil && self!.tableView.mj_footer == nil { | |
| 268 | + self!.addRefreshView() | |
| 269 | + self!.pageNum = self!.pageNum + 1 | |
| 270 | + self!.getBlockContents(page: self!.pageNum) | |
| 271 | + } | |
| 272 | + } | |
| 273 | + | |
| 274 | + self!.tableView.mj_header?.endRefreshing() | |
| 275 | + self!.tableView.mj_footer?.endRefreshing() | |
| 276 | + self!.tableView.reloadData() | |
| 277 | + if (result as! Array<Any>).count == 0 { | |
| 278 | + self!.tableView.mj_footer?.endRefreshingWithNoMoreData() | |
| 279 | + self!.tableView.reloadData() | |
| 280 | + } | |
| 281 | + | |
| 282 | + }else if (status == .noNetwork) { | |
| 283 | + self!.network_type = .noNetwork | |
| 284 | + self!.tableView.reloadEmptyDataSet() | |
| 285 | + } else { | |
| 286 | + self!.network_type = .failed | |
| 287 | + self!.tableView.reloadEmptyDataSet() | |
| 288 | + } | |
| 289 | + } | |
| 290 | + } | |
| 291 | + func addRefreshView() { | |
| 292 | + tableView.mj_header = MJRefreshNormalHeader.init(refreshingBlock: {[weak self] in | |
| 293 | + self!.pageNum = 1 | |
| 294 | + self!.getBlockContents(page: 1) | |
| 295 | + }) | |
| 296 | + | |
| 297 | + tableView.mj_footer = MJRefreshAutoNormalFooter.init(refreshingBlock: {[weak self] in | |
| 298 | + self!.pageNum = self!.pageNum + 1 | |
| 299 | + self!.getBlockContents(page: self!.pageNum) | |
| 300 | + }) | |
| 301 | + } | |
| 163 | 302 | |
| 164 | 303 | } |
| 165 | 304 | |
| 166 | 305 | extension CNUpSlideDetailViewController: UIViewControllerTransitioningDelegate { |
| 167 | 306 | |
| 168 | 307 | func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { |
| 169 | - return CNUpSlideAnimationTransition(animationType: .present) | |
| 308 | + return CNUpSlideAnimationTransition(animationType: .present, cellType: self.cellType) | |
| 170 | 309 | } |
| 171 | 310 | |
| 172 | 311 | func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { |
| 173 | - return CNUpSlideAnimationTransition(animationType: .dismiss) | |
| 312 | + return CNUpSlideAnimationTransition(animationType: .dismiss, cellType: self.cellType) | |
| 174 | 313 | } |
| 175 | 314 | |
| 176 | 315 | func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { |
| ... | ... | @@ -193,3 +332,48 @@ extension CNUpSlideDetailViewController: UIGestureRecognizerDelegate { |
| 193 | 332 | return true |
| 194 | 333 | } |
| 195 | 334 | } |
| 335 | + | |
| 336 | +extension CNUpSlideDetailViewController { | |
| 337 | + | |
| 338 | + func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { | |
| 339 | + if network_type == .failed || network_type == .unkonw { | |
| 340 | + return UIImage(named: "mine_list_source_unusual_failed") | |
| 341 | + } | |
| 342 | + if dataArray.count == 0 { | |
| 343 | + return UIImage(named: "mine_list_source_unusual_empty") | |
| 344 | + } | |
| 345 | + if network_type == .noNetwork { | |
| 346 | + return UIImage(named: "mine_list_source_unusual_noNet") | |
| 347 | + } | |
| 348 | + return UIImage(named: "mine_list_source_unusual_empty") | |
| 349 | + } | |
| 350 | + | |
| 351 | + func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? { | |
| 352 | + var defult_string = "" | |
| 353 | + if network_type == .failed || network_type == .unkonw { | |
| 354 | + defult_string = "接口请求错误,刷新试试~" | |
| 355 | + } | |
| 356 | + if network_type == .noNetwork { | |
| 357 | + defult_string = "网络开小差了,刷新试试~" | |
| 358 | + } | |
| 359 | + if dataArray.count == 0 { | |
| 360 | + defult_string = "暂时没有数据~" | |
| 361 | + } | |
| 362 | + return NSAttributedString(string: defult_string, attributes: [.font: Font_17,.foregroundColor: HexColor("#666666")!]) | |
| 363 | + } | |
| 364 | + | |
| 365 | + func buttonTitle(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> NSAttributedString? { | |
| 366 | + if network_type == .failed || network_type == .noNetwork { | |
| 367 | + let attributes = [NSAttributedString.Key.font:Font_16_Fit, | |
| 368 | + NSAttributedString.Key.foregroundColor: HexColor("#609BFF")] | |
| 369 | + return NSAttributedString(string: "刷一刷", attributes: attributes as [NSAttributedString.Key : Any]) | |
| 370 | + } | |
| 371 | + return nil | |
| 372 | + } | |
| 373 | + | |
| 374 | + func emptyDataSet(_ scrollView: UIScrollView, didTapView view: UIView) { | |
| 375 | + if network_type == .failed || network_type == .noNetwork { | |
| 376 | + getBlockContents(page: 1) | |
| 377 | + } | |
| 378 | + } | |
| 379 | +} | ... | ... |
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideViewController.swift
| ... | ... | @@ -160,6 +160,19 @@ class CNUpSlideViewController: CNLiveBaseViewController,UITableViewDelegate,UITa |
| 160 | 160 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 161 | 161 | |
| 162 | 162 | let slideModel = self.dataArray[indexPath.row] as! CNLiveDownSlideModel |
| 163 | + var cellType:CNLiveHomePageCellType = .course | |
| 164 | + ///model | |
| 165 | + ///(1) 1,2时跳转:sharelUrl后面拼接 ?contentId=contentId&videoId=pid | |
| 166 | + ///(2) 3,4时跳转:thirdUrl | |
| 167 | + ///(3)“album”,“album_video”,“album_ugc” -> http://wjjh5.cnlive.com/cnYmAlbumVideoList.html?aid=contentId&title=titlle | |
| 168 | + if slideModel.contents.first?.model ?? "0" == "1" || slideModel.contents.first?.model ?? "0" == "2" || slideModel.contents.first?.model ?? "0" == "3" || slideModel.contents.first?.model ?? "0" == "4"{ | |
| 169 | + cellType = .course | |
| 170 | + }else if slideModel.contents.first?.model ?? "0" == "album_ugc"{ | |
| 171 | + cellType = .playlet | |
| 172 | + }else{ | |
| 173 | + //新类型 | |
| 174 | + } | |
| 175 | + | |
| 163 | 176 | //type=4一排两个 推荐课程&推荐活动; 74今日推荐; 12列表全部课程; 75单课程大图 |
| 164 | 177 | if slideModel.type == SlideModelTypeRecommend4{ |
| 165 | 178 | |
| ... | ... | @@ -168,7 +181,7 @@ class CNUpSlideViewController: CNLiveBaseViewController,UITableViewDelegate,UITa |
| 168 | 181 | }else if slideModel.type == SlideModelTypeAllCourse12{ |
| 169 | 182 | guard let cell = tableView.cellForRow(at: indexPath) as? CNDownSlideSingleCourseCell else { return } |
| 170 | 183 | selectedCell = cell |
| 171 | - let detailVC = CNSlideBaseNavigationController(rootViewController: CNUpSlideDetailViewController(cell: cell,slideModel: slideModel)) | |
| 184 | + let detailVC = CNSlideBaseNavigationController(rootViewController: CNUpSlideDetailViewController(cell: cell,slideModel: slideModel, cellType: cellType), cellType: cellType) | |
| 172 | 185 | detailVC.dismissClosure = { [weak self] in |
| 173 | 186 | guard let StrongSelf = self else { return } |
| 174 | 187 | StrongSelf.updateStatusBarAndTabbarFrame(visible: true) |
| ... | ... | @@ -180,7 +193,7 @@ class CNUpSlideViewController: CNLiveBaseViewController,UITableViewDelegate,UITa |
| 180 | 193 | guard let cell = tableView.cellForRow(at: indexPath) as? CNDownSlideSingleCourseCell else { return } |
| 181 | 194 | selectedCell = cell |
| 182 | 195 | |
| 183 | - let detailVC = CNSlideBaseNavigationController(rootViewController: CNUpSlideDetailViewController(cell: cell,slideModel: slideModel)) | |
| 196 | + let detailVC = CNSlideBaseNavigationController(rootViewController: CNUpSlideDetailViewController(cell: cell,slideModel: slideModel, cellType: cellType), cellType: cellType) | |
| 184 | 197 | |
| 185 | 198 | detailVC.dismissClosure = { [weak self] in |
| 186 | 199 | guard let StrongSelf = self else { return } | ... | ... |
metaCode/Classes/Main/HomePages/Controller/AuthController/CNLiveAuthViewController.swift
| ... | ... | @@ -213,6 +213,19 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa |
| 213 | 213 | }else{ |
| 214 | 214 | |
| 215 | 215 | let slideModel = self.dataArray[indexPath.row] as! CNLiveDownSlideModel |
| 216 | + var cellType:CNLiveHomePageCellType = .course | |
| 217 | + ///model | |
| 218 | + ///(1) 1,2时跳转:sharelUrl后面拼接 ?contentId=contentId&videoId=pid | |
| 219 | + ///(2) 3,4时跳转:thirdUrl | |
| 220 | + ///(3)“album”,“album_video”,“album_ugc” -> http://wjjh5.cnlive.com/cnYmAlbumVideoList.html?aid=contentId&title=titlle | |
| 221 | + if slideModel.contents.first?.model ?? "0" == "1" || slideModel.contents.first?.model ?? "0" == "2" || slideModel.contents.first?.model ?? "0" == "3" || slideModel.contents.first?.model ?? "0" == "4"{ | |
| 222 | + cellType = .playletToCourse | |
| 223 | + }else if slideModel.contents.first?.model ?? "0" == "album_ugc"{ | |
| 224 | + cellType = .playlet | |
| 225 | + }else{ | |
| 226 | + //新类型 | |
| 227 | + } | |
| 228 | + | |
| 216 | 229 | //type=4一排两个 推荐课程&推荐活动; 74今日推荐; 12列表全部课程; 75单课程大图 |
| 217 | 230 | if slideModel.type == SlideModelTypeRecommend4{ |
| 218 | 231 | |
| ... | ... | @@ -221,7 +234,8 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa |
| 221 | 234 | }else if slideModel.type == SlideModelTypeAllCourse12{ |
| 222 | 235 | guard let cell = tableView.cellForRow(at: indexPath) as? CNDownSlideSingleCourseCell else { return } |
| 223 | 236 | selectedCell = cell |
| 224 | - let detailVC = CNHomePageBaseNavigationController(rootViewController: CNHomepageDetailViewController(cell: cell,slideModel: slideModel)) | |
| 237 | + | |
| 238 | + let detailVC = CNSlideBaseNavigationController(rootViewController: CNUpSlideDetailViewController(cell: cell,slideModel: slideModel, cellType: cellType), cellType: cellType) | |
| 225 | 239 | detailVC.dismissClosure = { [weak self] in |
| 226 | 240 | guard let StrongSelf = self else { return } |
| 227 | 241 | StrongSelf.updateStatusBarAndTabbarFrame(visible: true) |
| ... | ... | @@ -232,8 +246,7 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa |
| 232 | 246 | }else if slideModel.type == SlideModelTypeOneCourse75{ |
| 233 | 247 | guard let cell = tableView.cellForRow(at: indexPath) as? CNDownSlideSingleCourseCell else { return } |
| 234 | 248 | selectedCell = cell |
| 235 | - | |
| 236 | - let detailVC = CNHomePageBaseNavigationController(rootViewController:CNHomepageDetailViewController(cell: cell,slideModel: slideModel)) | |
| 249 | + let detailVC = CNSlideBaseNavigationController(rootViewController: CNUpSlideDetailViewController(cell: cell,slideModel: slideModel, cellType: cellType), cellType: cellType) | |
| 237 | 250 | |
| 238 | 251 | detailVC.dismissClosure = { [weak self] in |
| 239 | 252 | guard let StrongSelf = self else { return } |
| ... | ... | @@ -318,7 +331,6 @@ class CNLiveAuthViewController:CNLiveBaseViewController,UITableViewDelegate,UITa |
| 318 | 331 | // showLoading(message: "") |
| 319 | 332 | CNLiveDownSlideViewModel.requestGetPage(pageId: pageID as NSString) { result, status in |
| 320 | 333 | hiddenLoading() |
| 321 | - | |
| 322 | 334 | if status == .success{ |
| 323 | 335 | self.dataArray.removeAllObjects() |
| 324 | 336 | let array = result as! [Any] | ... | ... |
metaCode/Classes/Main/HomePages/Controller/AuthController/push相关/CNHomepageDetailViewController.swift
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | // metaCode |
| 4 | 4 | // |
| 5 | 5 | // Created by zx on 2024/1/5. |
| 6 | -// 首页短剧--大图点击详情页 | |
| 6 | +// 首页--短剧大图点击详情页 | |
| 7 | 7 | |
| 8 | 8 | import Foundation |
| 9 | 9 | import MJRefresh |
| ... | ... | @@ -11,30 +11,6 @@ import EmptyDataSet_Swift |
| 11 | 11 | |
| 12 | 12 | class CNHomepageDetailViewController: CNLiveBaseViewController ,UITableViewDataSource, UITableViewDelegate,EmptyDataSetSource, EmptyDataSetDelegate{ |
| 13 | 13 | |
| 14 | - let kCNLiveAlbumImageCellIdentifier = "kCNLiveAlbumImageCellIdentifier" | |
| 15 | - let kCNLiveAlbumCellIdentifier = "kCNLiveAlbumCellIdentifier" | |
| 16 | - | |
| 17 | - var pageNum: NSInteger | |
| 18 | - var network_type: CNLiveMineResponseType! | |
| 19 | - // MARK: - 懒加载 | |
| 20 | - ///数据源 | |
| 21 | - lazy var dataArray: NSMutableArray = { | |
| 22 | - var dataArray = NSMutableArray() | |
| 23 | - return dataArray | |
| 24 | - }() | |
| 25 | - lazy var tableView : UITableView = { | |
| 26 | - let tableView = UITableView(frame: .zero, style: .plain) | |
| 27 | - tableView.dataSource = self | |
| 28 | - tableView.delegate = self | |
| 29 | - tableView.emptyDataSetSource = self | |
| 30 | - tableView.emptyDataSetDelegate = self | |
| 31 | - tableView.separatorStyle = .none | |
| 32 | - tableView.tableFooterView = UIView.init() | |
| 33 | - tableView.register(CNLiveAlbumCell.self, forCellReuseIdentifier: kCNLiveAlbumCellIdentifier) | |
| 34 | - tableView.register(CNLiveAlbumImageCell.self, forCellReuseIdentifier: kCNLiveAlbumImageCellIdentifier) | |
| 35 | - return tableView | |
| 36 | - }() | |
| 37 | - | |
| 38 | 14 | //slideModel |
| 39 | 15 | var _slideModel : CNLiveDownSlideModel? |
| 40 | 16 | var slideModel : CNLiveDownSlideModel? { |
| ... | ... | @@ -49,11 +25,9 @@ class CNHomepageDetailViewController: CNLiveBaseViewController ,UITableViewData |
| 49 | 25 | var dismissClosure: (()->())? |
| 50 | 26 | //the point when start to interactive |
| 51 | 27 | var interactiveStartingPoint: CGPoint? = nil |
| 52 | - | |
| 53 | 28 | var draggingDownToDismiss = false |
| 54 | - | |
| 55 | 29 | let cell: CNDownSlideSingleCourseCell! |
| 56 | - | |
| 30 | + | |
| 57 | 31 | private lazy var dismissPanGesture: UIPanGestureRecognizer = { |
| 58 | 32 | let ges = UIPanGestureRecognizer() |
| 59 | 33 | ges.maximumNumberOfTouches = 1 |
| ... | ... | @@ -79,7 +53,6 @@ class CNHomepageDetailViewController: CNLiveBaseViewController ,UITableViewData |
| 79 | 53 | btn.addTarget(self, action: #selector(closeAction), for: .touchUpInside) |
| 80 | 54 | return btn |
| 81 | 55 | }() |
| 82 | - | |
| 83 | 56 | init(cell: CNDownSlideSingleCourseCell,slideModel:CNLiveDownSlideModel) { |
| 84 | 57 | self.pageNum = 1 |
| 85 | 58 | self.cell = cell |
| ... | ... | @@ -98,7 +71,6 @@ class CNHomepageDetailViewController: CNLiveBaseViewController ,UITableViewData |
| 98 | 71 | required init?(coder aDecoder: NSCoder) { |
| 99 | 72 | fatalError("init(coder:) has not been implemented") |
| 100 | 73 | } |
| 101 | - | |
| 102 | 74 | override func viewDidLoad() { |
| 103 | 75 | super.viewDidLoad() |
| 104 | 76 | setupUI() |
| ... | ... | @@ -125,12 +97,98 @@ class CNHomepageDetailViewController: CNLiveBaseViewController ,UITableViewData |
| 125 | 97 | private func getImageFromCell() { |
| 126 | 98 | scrollView.imageView.image = cell.bgImageView.image |
| 127 | 99 | } |
| 128 | - | |
| 129 | 100 | @objc private func closeAction() { |
| 130 | 101 | dismiss(animated: true, completion: nil) |
| 131 | 102 | let nav = self.navigationController as! CNHomePageBaseNavigationController |
| 132 | 103 | nav.dismissClosure?() |
| 133 | 104 | } |
| 105 | + @objc private func handleDismissPan(gesture: UIPanGestureRecognizer) { | |
| 106 | + if !draggingDownToDismiss { | |
| 107 | + return | |
| 108 | + } | |
| 109 | + | |
| 110 | + let startingPoint: CGPoint | |
| 111 | + | |
| 112 | + if let p = interactiveStartingPoint { | |
| 113 | + startingPoint = p | |
| 114 | + } else { | |
| 115 | + startingPoint = gesture.location(in: nil) | |
| 116 | + interactiveStartingPoint = startingPoint | |
| 117 | + } | |
| 118 | + | |
| 119 | + let currentLocation = gesture.location(in: nil) | |
| 120 | + | |
| 121 | + var progress = (currentLocation.y - startingPoint.y) / 100 | |
| 122 | + | |
| 123 | + //prevent viewController bigger when scrolling up | |
| 124 | + if currentLocation.y <= startingPoint.y { | |
| 125 | + progress = 0 | |
| 126 | + } | |
| 127 | + | |
| 128 | + if progress >= 1.0 { | |
| 129 | + dismiss(animated: true, completion: nil) | |
| 130 | + let nav = self.navigationController as! CNHomePageBaseNavigationController | |
| 131 | + nav.dismissClosure?() | |
| 132 | +// dismissClosure?() | |
| 133 | + stopDismissPanGesture(gesture) | |
| 134 | + return | |
| 135 | + } | |
| 136 | + | |
| 137 | + let targetShrinkScale: CGFloat = 0.86 | |
| 138 | + let currentScale: CGFloat = 1 - (1 - targetShrinkScale) * progress | |
| 139 | + | |
| 140 | + switch gesture.state { | |
| 141 | + case .began,.changed: | |
| 142 | + scrollView.isScrollEnabled = false | |
| 143 | + gesture.view?.transform = CGAffineTransform(scaleX: currentScale, y: currentScale) | |
| 144 | + gesture.view?.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius * (progress) | |
| 145 | + scrollView.showsVerticalScrollIndicator = false | |
| 146 | + case .cancelled,.ended: | |
| 147 | + scrollView.isScrollEnabled = true | |
| 148 | + stopDismissPanGesture(gesture) | |
| 149 | + default: | |
| 150 | + break | |
| 151 | + } | |
| 152 | + } | |
| 153 | + | |
| 154 | + //当下拉Offset超过100或取消下拉手势时,执行此方法 | |
| 155 | + private func stopDismissPanGesture(_ gesture: UIPanGestureRecognizer) { | |
| 156 | + draggingDownToDismiss = false | |
| 157 | + interactiveStartingPoint = nil | |
| 158 | + scrollView.showsVerticalScrollIndicator = true | |
| 159 | + | |
| 160 | + UIView.animate(withDuration: 0.2) { | |
| 161 | + gesture.view?.transform = CGAffineTransform.identity | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + let kCNLiveAlbumImageCellIdentifier = "kCNLiveAlbumImageCellIdentifier" | |
| 169 | + let kCNLiveAlbumCellIdentifier = "kCNLiveAlbumCellIdentifier" | |
| 170 | + | |
| 171 | + var pageNum: NSInteger | |
| 172 | + var network_type: CNLiveMineResponseType! | |
| 173 | + // MARK: - 懒加载 | |
| 174 | + ///数据源 | |
| 175 | + lazy var dataArray: NSMutableArray = { | |
| 176 | + var dataArray = NSMutableArray() | |
| 177 | + return dataArray | |
| 178 | + }() | |
| 179 | + lazy var tableView : UITableView = { | |
| 180 | + let tableView = UITableView(frame: .zero, style: .plain) | |
| 181 | + tableView.dataSource = self | |
| 182 | + tableView.delegate = self | |
| 183 | + tableView.emptyDataSetSource = self | |
| 184 | + tableView.emptyDataSetDelegate = self | |
| 185 | + tableView.separatorStyle = .none | |
| 186 | + tableView.tableFooterView = UIView.init() | |
| 187 | + tableView.register(CNLiveAlbumCell.self, forCellReuseIdentifier: kCNLiveAlbumCellIdentifier) | |
| 188 | + tableView.register(CNLiveAlbumImageCell.self, forCellReuseIdentifier: kCNLiveAlbumImageCellIdentifier) | |
| 189 | + return tableView | |
| 190 | + }() | |
| 191 | + | |
| 134 | 192 | |
| 135 | 193 | func numberOfSections(in tableView: UITableView) -> Int { |
| 136 | 194 | 2 |
| ... | ... | @@ -220,67 +278,6 @@ class CNHomepageDetailViewController: CNLiveBaseViewController ,UITableViewData |
| 220 | 278 | self!.getBlockContents(page: self!.pageNum) |
| 221 | 279 | }) |
| 222 | 280 | } |
| 223 | - | |
| 224 | - @objc private func handleDismissPan(gesture: UIPanGestureRecognizer) { | |
| 225 | - if !draggingDownToDismiss { | |
| 226 | - return | |
| 227 | - } | |
| 228 | - | |
| 229 | - let startingPoint: CGPoint | |
| 230 | - | |
| 231 | - if let p = interactiveStartingPoint { | |
| 232 | - startingPoint = p | |
| 233 | - } else { | |
| 234 | - startingPoint = gesture.location(in: nil) | |
| 235 | - interactiveStartingPoint = startingPoint | |
| 236 | - } | |
| 237 | - | |
| 238 | - let currentLocation = gesture.location(in: nil) | |
| 239 | - | |
| 240 | - var progress = (currentLocation.y - startingPoint.y) / 100 | |
| 241 | - | |
| 242 | - //prevent viewController bigger when scrolling up | |
| 243 | - if currentLocation.y <= startingPoint.y { | |
| 244 | - progress = 0 | |
| 245 | - } | |
| 246 | - | |
| 247 | - if progress >= 1.0 { | |
| 248 | - dismiss(animated: true, completion: nil) | |
| 249 | - let nav = self.navigationController as! CNHomePageBaseNavigationController | |
| 250 | - nav.dismissClosure?() | |
| 251 | -// dismissClosure?() | |
| 252 | - stopDismissPanGesture(gesture) | |
| 253 | - return | |
| 254 | - } | |
| 255 | - | |
| 256 | - let targetShrinkScale: CGFloat = 0.86 | |
| 257 | - let currentScale: CGFloat = 1 - (1 - targetShrinkScale) * progress | |
| 258 | - | |
| 259 | - switch gesture.state { | |
| 260 | - case .began,.changed: | |
| 261 | - scrollView.isScrollEnabled = false | |
| 262 | - gesture.view?.transform = CGAffineTransform(scaleX: currentScale, y: currentScale) | |
| 263 | - gesture.view?.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius * (progress) | |
| 264 | - scrollView.showsVerticalScrollIndicator = false | |
| 265 | - case .cancelled,.ended: | |
| 266 | - scrollView.isScrollEnabled = true | |
| 267 | - stopDismissPanGesture(gesture) | |
| 268 | - default: | |
| 269 | - break | |
| 270 | - } | |
| 271 | - } | |
| 272 | - | |
| 273 | - //当下拉Offset超过100或取消下拉手势时,执行此方法 | |
| 274 | - private func stopDismissPanGesture(_ gesture: UIPanGestureRecognizer) { | |
| 275 | - draggingDownToDismiss = false | |
| 276 | - interactiveStartingPoint = nil | |
| 277 | - scrollView.showsVerticalScrollIndicator = true | |
| 278 | - | |
| 279 | - UIView.animate(withDuration: 0.2) { | |
| 280 | - gesture.view?.transform = CGAffineTransform.identity | |
| 281 | - } | |
| 282 | - } | |
| 283 | - | |
| 284 | 281 | } |
| 285 | 282 | |
| 286 | 283 | extension CNHomepageDetailViewController: UIViewControllerTransitioningDelegate { | ... | ... |
metaCode/Classes/Main/HomePages/Controller/AuthController/push相关/CNHomepageDuanJuDetailViewController.swift
| ... | ... | @@ -130,7 +130,7 @@ class CNHomepageDuanJuDetailViewController: CNLiveBaseViewController ,UITableVi |
| 130 | 130 | let cell = CNLiveAlbumCell() |
| 131 | 131 | return cell |
| 132 | 132 | } |
| 133 | - cell.albumMsgModel = albumModel | |
| 133 | + cell.setupNewUIMsgModel(model: albumModel,isDetail: true) | |
| 134 | 134 | return cell |
| 135 | 135 | } |
| 136 | 136 | } | ... | ... |
metaCode/Classes/Main/HomePages/View/HomePage/CNLiveHomePageDuanJuCell.swift
| ... | ... | @@ -105,8 +105,7 @@ class CNLiveHomePageDuanJuCell:UITableViewCell,UITableViewDelegate,UITableViewDa |
| 105 | 105 | let cell = CNLiveAlbumCell() |
| 106 | 106 | return cell |
| 107 | 107 | } |
| 108 | - cell.albumMsgModel = model | |
| 109 | - | |
| 108 | + cell.setupNewUIMsgModel(model: model,isDetail: false) | |
| 110 | 109 | return cell |
| 111 | 110 | } |
| 112 | 111 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ... | ... |
metaCode/Classes/Main/HomePages/View/HomepageDetail/CNLiveAlbumCell.swift
| ... | ... | @@ -18,8 +18,6 @@ class CNLiveAlbumCell:UITableViewCell{ |
| 18 | 18 | } |
| 19 | 19 | set{ |
| 20 | 20 | _albumMsgModel = newValue! |
| 21 | - | |
| 22 | - self.setupNewUIMsgModel(model: _albumMsgModel!) | |
| 23 | 21 | } |
| 24 | 22 | } |
| 25 | 23 | |
| ... | ... | @@ -31,8 +29,6 @@ class CNLiveAlbumCell:UITableViewCell{ |
| 31 | 29 | } |
| 32 | 30 | set{ |
| 33 | 31 | _albumModel = newValue! |
| 34 | - | |
| 35 | - self.setupNewUI(model: _albumModel!) | |
| 36 | 32 | } |
| 37 | 33 | } |
| 38 | 34 | //MARK: - 懒加载 |
| ... | ... | @@ -86,18 +82,25 @@ class CNLiveAlbumCell:UITableViewCell{ |
| 86 | 82 | fatalError("init(coder:) has not been implemented") |
| 87 | 83 | } |
| 88 | 84 | func setupNewUI(model:CNLiveAlbumModel){ |
| 85 | + self.albumModel = model | |
| 89 | 86 | self.titleLabl.text = model.title |
| 90 | 87 | self.subTitleLabel.text = model.subTitle |
| 91 | 88 | self.iconImgView.kf.setImage(with: URL(string: model.poster)) |
| 92 | 89 | self.titleLabl.width = KSreenWidth-(self.iconImgView.right+15)-80 |
| 93 | 90 | self.playBtn.left = KSreenWidth-80 |
| 94 | 91 | } |
| 95 | - func setupNewUIMsgModel(model:CNLiveAlbumMsgModel){ | |
| 92 | + func setupNewUIMsgModel(model:CNLiveAlbumMsgModel,isDetail:Bool){ | |
| 93 | + self.albumMsgModel = model | |
| 94 | + //在追短剧model | |
| 96 | 95 | self.titleLabl.text = model.albumName |
| 97 | 96 | self.subTitleLabel.text = model.subTitle |
| 98 | 97 | self.iconImgView.kf.setImage(with: URL(string: model.albumImg)) |
| 99 | 98 | self.titleLabl.width = KSreenWidth-(self.iconImgView.right+15)-80-30 |
| 100 | - self.playBtn.left = KSreenWidth-80-30 | |
| 99 | + if isDetail{ | |
| 100 | + self.playBtn.left = KSreenWidth-80 | |
| 101 | + }else{ | |
| 102 | + self.playBtn.left = KSreenWidth-80-30 | |
| 103 | + } | |
| 101 | 104 | } |
| 102 | 105 | @objc func playBtnAction(){ |
| 103 | 106 | showLoading(message: "") | ... | ... |
metaCode/Classes/Main/Util/CNUpSlideAnimationTransition.swift
| ... | ... | @@ -17,8 +17,9 @@ enum AnimationType { |
| 17 | 17 | |
| 18 | 18 | class CNUpSlideAnimationTransition: NSObject { |
| 19 | 19 | let animationType: AnimationType! |
| 20 | - | |
| 21 | - init(animationType: AnimationType) { | |
| 20 | + var cellType:CNLiveHomePageCellType = .course | |
| 21 | + init(animationType: AnimationType,cellType:CNLiveHomePageCellType) { | |
| 22 | + self.cellType = cellType | |
| 22 | 23 | self.animationType = animationType |
| 23 | 24 | super.init() |
| 24 | 25 | } |
| ... | ... | @@ -39,48 +40,185 @@ extension CNUpSlideAnimationTransition: UIViewControllerAnimatedTransitioning { |
| 39 | 40 | |
| 40 | 41 | func animationForPresent(using transitionContext: UIViewControllerContextTransitioning) { |
| 41 | 42 | let containerView = transitionContext.containerView |
| 42 | - //1.Get fromVC and toVC | |
| 43 | - guard let fromVC = transitionContext.viewController(forKey: .from) as? CNUpSlideViewController else { return } | |
| 44 | - guard let toNaviVC = transitionContext.viewController(forKey: .to) as? CNSlideBaseNavigationController else { return } | |
| 45 | - guard let selectedCell = fromVC.selectedCell else { return } | |
| 46 | - let toVC = toNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 47 | - let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: fromVC.view) | |
| 48 | - //2.Set presentation original size. | |
| 49 | - toVC.view.frame = frame | |
| 50 | - toVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 51 | - toVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 52 | - | |
| 53 | - containerView.addSubview(toNaviVC.view) | |
| 54 | 43 | |
| 55 | - //3.Change original size to final size with animation. | |
| 56 | - UIView.animate(withDuration: transitonDuration, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: { | |
| 57 | - toVC.view.frame = UIScreen.main.bounds | |
| 58 | - toVC.scrollView.imageView.frame.size.width = KSreenWidth | |
| 59 | - toVC.scrollView.imageView.frame.size.height = KSreenWidth*DownSlideSingleCourseImgH/DownSlideSingleCourseW | |
| 60 | - toVC.closeBtn.alpha = 1 | |
| 44 | + if self.cellType == .playlet{ | |
| 45 | + //1.Get fromVC and toVC | |
| 46 | + guard let fromVCtemp = transitionContext.viewController(forKey: .from) as? CNLiveBaseTabBarViewController else { return } | |
| 47 | + let fromNavi = fromVCtemp.viewControllers![0] as! CNLiveBaseNavigationController | |
| 48 | + let fromVC = fromNavi.viewControllers.first as! CNLiveAuthViewController | |
| 49 | + guard let toNaviVC = transitionContext.viewController(forKey: .to) as? CNSlideBaseNavigationController else { return } | |
| 50 | + if toNaviVC.topViewController is CNUpSlideDetailViewController{ | |
| 51 | + guard let selectedCell = fromVC.selectedCell else { return } | |
| 52 | + let toVC = toNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 53 | + let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: fromVC.view) | |
| 54 | + //2.Set presentation original size. | |
| 55 | + toVC.view.frame = frame | |
| 56 | + toVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 57 | + toVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 58 | + | |
| 59 | + containerView.addSubview(toNaviVC.view) | |
| 60 | + | |
| 61 | + //3.Change original size to final size with animation. | |
| 62 | + UIView.animate(withDuration: transitonDuration, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: { | |
| 63 | + toVC.view.frame = UIScreen.main.bounds | |
| 64 | + toVC.scrollView.imageView.frame.size.width = KSreenWidth | |
| 65 | + toVC.scrollView.imageView.frame.size.height = KSreenWidth*DownSlideSingleCourseImgH/DownSlideSingleCourseW | |
| 66 | + toVC.closeBtn.alpha = 1 | |
| 67 | + | |
| 68 | + }) { (completed) in | |
| 69 | + transitionContext.completeTransition(completed) | |
| 70 | + } | |
| 71 | + }else if toNaviVC.topViewController is CNHomepageDuanJuDetailViewController{ | |
| 72 | + guard let selectedCell = fromVC.selectedDuanjuCell else { return } | |
| 73 | + let toVC = toNaviVC.topViewController as! CNHomepageDuanJuDetailViewController | |
| 74 | + let frame = selectedCell.convert(selectedCell.totalView.frame, to: fromVC.view) | |
| 75 | + //2.Set presentation original size. | |
| 76 | + toVC.view.frame = frame | |
| 77 | + containerView.addSubview(toNaviVC.view) | |
| 78 | + | |
| 79 | + //3.Change original size to final size with animation. | |
| 80 | + UIView.animate(withDuration: transitonDuration, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: { | |
| 81 | + toVC.view.frame = UIScreen.main.bounds | |
| 82 | + toVC.closeBtn.alpha = 1 | |
| 83 | + | |
| 84 | + }) { (completed) in | |
| 85 | + transitionContext.completeTransition(completed) | |
| 86 | + } | |
| 87 | + }else{ | |
| 88 | + return | |
| 89 | + } | |
| 90 | + }else if self.cellType == .course{ | |
| 91 | + //1.Get fromVC and toVC | |
| 92 | + guard let fromVC = transitionContext.viewController(forKey: .from) as? CNUpSlideViewController else { return } | |
| 93 | + guard let toNaviVC = transitionContext.viewController(forKey: .to) as? CNSlideBaseNavigationController else { return } | |
| 94 | + guard let selectedCell = fromVC.selectedCell else { return } | |
| 95 | + let toVC = toNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 96 | + let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: fromVC.view) | |
| 97 | + //2.Set presentation original size. | |
| 98 | + toVC.view.frame = frame | |
| 99 | + toVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 100 | + toVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 101 | + | |
| 102 | + containerView.addSubview(toNaviVC.view) | |
| 61 | 103 | |
| 62 | - }) { (completed) in | |
| 63 | - transitionContext.completeTransition(completed) | |
| 104 | + //3.Change original size to final size with animation. | |
| 105 | + UIView.animate(withDuration: transitonDuration, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: { | |
| 106 | + toVC.view.frame = UIScreen.main.bounds | |
| 107 | + toVC.scrollView.imageView.frame.size.width = KSreenWidth | |
| 108 | + toVC.scrollView.imageView.frame.size.height = KSreenWidth*DownSlideSingleCourseImgH/DownSlideSingleCourseW | |
| 109 | + toVC.closeBtn.alpha = 1 | |
| 110 | + | |
| 111 | + }) { (completed) in | |
| 112 | + transitionContext.completeTransition(completed) | |
| 113 | + } | |
| 114 | + }else if self.cellType == .playletToCourse{ | |
| 115 | + //1.Get fromVC and toVC | |
| 116 | + guard let fromVCtemp = transitionContext.viewController(forKey: .from) as? CNLiveBaseTabBarViewController else { return } | |
| 117 | + let fromNavi = fromVCtemp.viewControllers![0] as! CNLiveBaseNavigationController | |
| 118 | + let fromVC = fromNavi.viewControllers.first as! CNLiveAuthViewController | |
| 119 | +// guard let fromVC = transitionContext.viewController(forKey: .from) as? CNUpSlideViewController else { return } | |
| 120 | + guard let toNaviVC = transitionContext.viewController(forKey: .to) as? CNSlideBaseNavigationController else { return } | |
| 121 | + guard let selectedCell = fromVC.selectedCell else { return } | |
| 122 | + let toVC = toNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 123 | + let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: fromVC.view) | |
| 124 | + //2.Set presentation original size. | |
| 125 | + toVC.view.frame = frame | |
| 126 | + toVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 127 | + toVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 128 | + | |
| 129 | + containerView.addSubview(toNaviVC.view) | |
| 130 | + | |
| 131 | + //3.Change original size to final size with animation. | |
| 132 | + UIView.animate(withDuration: transitonDuration, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: { | |
| 133 | + toVC.view.frame = UIScreen.main.bounds | |
| 134 | + toVC.scrollView.imageView.frame.size.width = KSreenWidth | |
| 135 | + toVC.scrollView.imageView.frame.size.height = KSreenWidth*DownSlideSingleCourseImgH/DownSlideSingleCourseW | |
| 136 | + toVC.closeBtn.alpha = 1 | |
| 137 | + | |
| 138 | + }) { (completed) in | |
| 139 | + transitionContext.completeTransition(completed) | |
| 140 | + } | |
| 64 | 141 | } |
| 65 | 142 | } |
| 66 | 143 | |
| 67 | 144 | func animationForDismiss(using transitionContext: UIViewControllerContextTransitioning) { |
| 68 | - guard let fromNaviVC = transitionContext.viewController(forKey: .from) as? CNSlideBaseNavigationController else { return } | |
| 69 | - guard let toVC = transitionContext.viewController(forKey: .to) as? CNUpSlideViewController else { return } | |
| 70 | - guard let selectedCell = toVC.selectedCell else { return } | |
| 71 | - let fromVC = fromNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 72 | - | |
| 73 | - UIView.animate(withDuration: transitonDuration - 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: { | |
| 74 | - let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: toVC.view) | |
| 75 | - fromVC.view.frame = frame | |
| 76 | - fromVC.view.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius | |
| 77 | - fromVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 78 | - fromVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 79 | - fromVC.closeBtn.alpha = 0 | |
| 145 | + if self.cellType == .playlet{ | |
| 146 | + guard let fromNaviVC = transitionContext.viewController(forKey: .from) as? CNSlideBaseNavigationController else { return } | |
| 147 | + guard let toVCTabbar = transitionContext.viewController(forKey: .to) as? CNLiveBaseTabBarViewController else { return } | |
| 148 | + let toVCNav = toVCTabbar.viewControllers?.first as! CNLiveBaseNavigationController | |
| 149 | + let toVC = toVCNav.viewControllers.first as! CNLiveAuthViewController | |
| 150 | + if fromNaviVC.topViewController is CNUpSlideDetailViewController{ | |
| 151 | + guard let selectedCell = toVC.selectedCell else { return } | |
| 152 | + let fromVC = fromNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 153 | + | |
| 154 | + UIView.animate(withDuration: transitonDuration - 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: { | |
| 155 | + let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: toVC.view) | |
| 156 | + fromVC.view.frame = frame | |
| 157 | + fromVC.view.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius | |
| 158 | + fromVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 159 | + fromVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 160 | + fromVC.closeBtn.alpha = 0 | |
| 161 | + | |
| 162 | + }) { (completed) in | |
| 163 | + transitionContext.completeTransition(completed) | |
| 164 | + } | |
| 165 | + }else if fromNaviVC.topViewController is CNHomepageDuanJuDetailViewController{ | |
| 166 | + guard let selectedCell = toVC.selectedDuanjuCell else { return } | |
| 167 | + let fromVC = fromNaviVC.topViewController as! CNHomepageDuanJuDetailViewController | |
| 168 | + UIView.animate(withDuration: transitonDuration - 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: { | |
| 169 | + let frame = selectedCell.convert(selectedCell.totalView.frame, to: toVC.view) | |
| 170 | + fromVC.view.frame = frame | |
| 171 | + fromVC.view.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius | |
| 172 | + fromVC.closeBtn.alpha = 0 | |
| 173 | + | |
| 174 | + }) { (completed) in | |
| 175 | + transitionContext.completeTransition(completed) | |
| 176 | + } | |
| 177 | + | |
| 178 | + }else{ | |
| 179 | + return | |
| 180 | + } | |
| 181 | + | |
| 182 | + }else if self.cellType == .course{ | |
| 183 | + guard let fromNaviVC = transitionContext.viewController(forKey: .from) as? CNSlideBaseNavigationController else { return } | |
| 184 | + guard let toVC = transitionContext.viewController(forKey: .to) as? CNUpSlideViewController else { return } | |
| 185 | + guard let selectedCell = toVC.selectedCell else { return } | |
| 186 | + let fromVC = fromNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 187 | + | |
| 188 | + UIView.animate(withDuration: transitonDuration - 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: { | |
| 189 | + let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: toVC.view) | |
| 190 | + fromVC.view.frame = frame | |
| 191 | + fromVC.view.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius | |
| 192 | + fromVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 193 | + fromVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 194 | + fromVC.closeBtn.alpha = 0 | |
| 195 | + | |
| 196 | + }) { (completed) in | |
| 197 | + transitionContext.completeTransition(completed) | |
| 198 | + } | |
| 199 | + | |
| 200 | + }else if self.cellType == .playletToCourse{ | |
| 201 | + guard let fromNaviVC = transitionContext.viewController(forKey: .from) as? CNSlideBaseNavigationController else { return } | |
| 202 | + guard let toVCTabbar = transitionContext.viewController(forKey: .to) as? CNLiveBaseTabBarViewController else { return } | |
| 203 | + let toVCNav = toVCTabbar.viewControllers?.first as! CNLiveBaseNavigationController | |
| 204 | + let toVC = toVCNav.viewControllers.first as! CNLiveAuthViewController | |
| 205 | + guard let selectedCell = toVC.selectedCell else { return } | |
| 206 | + let fromVC = fromNaviVC.topViewController as! CNUpSlideDetailViewController | |
| 80 | 207 | |
| 81 | - }) { (completed) in | |
| 82 | - transitionContext.completeTransition(completed) | |
| 208 | + UIView.animate(withDuration: transitonDuration - 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: { | |
| 209 | + let frame = selectedCell.convert(selectedCell.bgBackView.frame, to: toVC.view) | |
| 210 | + fromVC.view.frame = frame | |
| 211 | + fromVC.view.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius | |
| 212 | + fromVC.scrollView.imageView.frame.size.width = GlobalConstants.todayCardSize.width | |
| 213 | + fromVC.scrollView.imageView.frame.size.height = GlobalConstants.todayCardSize.height | |
| 214 | + fromVC.closeBtn.alpha = 0 | |
| 215 | + | |
| 216 | + }) { (completed) in | |
| 217 | + transitionContext.completeTransition(completed) | |
| 218 | + } | |
| 219 | + | |
| 83 | 220 | } |
| 221 | + | |
| 84 | 222 | } |
| 85 | 223 | |
| 86 | 224 | } | ... | ... |