//
//  PQImageSelectedController.swift
//  PQSpeed
//
//  Created by SanW on 2020/8/14.
//  Copyright © 2020 BytesFlow. All rights reserved.
//

import UIKit
import BFCommonKit

class PQImageSelectedController: PQUploadController {
    var updataVideoData: PQVideoListModel? // 如果updataVideoData不为空则为修改视频
    override func viewDidLoad() {
        super.viewDidLoad()
        emptyData?.title = "哦呜~ 你没有可上传的图片~"
        emptyData?.emptyImageName = "icon_authorError"
        // Do any additional setup after loading the view.
    }

    @objc override func btnClick(sender: UIButton) {
        switch sender.tag {
        case 1: // 返回
            navigationController?.popViewController(animated: true)
        case 2: // 筛选
            showCollects()
        case 3: // 下一步
            if selectedData == nil {
                cShowHUB(superView: nil, msg: "请选择图片")
                return
            }
            PQPHAssetVideoParaseUtil.requestAssetOringinImage(asset: (selectedData?.asset)!) { [weak self] _, _, image, _ in
                if image != nil {
                    self?.selectedData?.image = image
                }
                self?.selectedData?.videoBucketKey = self?.uploadData?.videoBucketKey
                let vc = PQImageCropVC(image: (self?.selectedData?.image)!, aspectWidth: self?.videoWidth ?? 0.0, aspectHeight: self?.videoHeight ?? 0.0)
                self?.selectedData?.duration = self?.uploadData?.duration ?? 0.0

                self?.selectedData?.localPath = self?.uploadData?.localPath
                vc.uploadData = self?.selectedData
                vc.updataVideoData = self?.updataVideoData
                self?.navigationController?.pushViewController(vc, animated: true)
            }
        case 4: // 播放
            break
        default:
            break
        }
    }
}
