Commit 640e57a3 authored by Steven杜宇's avatar Steven杜宇

// 分享

parent cdcd0627
......@@ -9,9 +9,66 @@
import UIKit
import JXSegmentedView
enum YHPlanShareBgType: Int {
case link = 1
case pdf = 2
}
class YHPlanShareBgView: UIView, JXSegmentedListContainerViewListDelegate {
let bgWidth = 293.0
let bgHeight = 380.0
var index: YHPlanShareBgType = .link {
didSet {
imgV.image = index == .link ? UIImage(named: "plan_share_link_bg") : UIImage(named: "plan_share_pdf_bg")
imgV.snp.remakeConstraints { make in
make.width.equalTo( index == .link ? bgWidth : 217)
make.height.equalTo(bgHeight)
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var imgV: UIImageView = {
let imgV = UIImageView()
imgV.image = UIImage(named: "plan_share_link_bg")
return imgV
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func createUI() {
self.addSubview(imgV)
imgV.snp.makeConstraints { make in
make.width.equalTo(bgWidth)
make.height.equalTo(bgHeight)
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
}
}
func listView() -> UIView {
return self
}
}
class YHPlanShareViewController: YHBaseViewController {
let segmentTitles = ["分享链接", "分享PDF"]
let bgWidth = 293.0
let bgHeight = 380.0
lazy var segmentedView: JXSegmentedView = {
let view = JXSegmentedView(frame: CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: KScreenWidth, height: 30))
......@@ -23,9 +80,10 @@ class YHPlanShareViewController: YHBaseViewController {
indicator.indicatorWidth = 16
indicator.indicatorHeight = 2
indicator.indicatorCornerRadius = 0.0
indicator.indicatorColor = UIColor.white
indicator.indicatorColor = UIColor.mainTextColor
view.indicators = [indicator]
view.dataSource = segmentedDataSource
view.listContainer = listContainerView
return view
}()
......@@ -42,9 +100,10 @@ class YHPlanShareViewController: YHBaseViewController {
return dataSource
}()
lazy var scrollView: UIScrollView = {
let v = UIScrollView(frame: .zero)
return v
lazy var listContainerView: JXSegmentedListContainerView! = {
let view = JXSegmentedListContainerView(dataSource: self, type: .scrollView)
view.backgroundColor = .clear
return view
}()
lazy var bottomShareView: YHPlanShareView = {
......@@ -52,24 +111,38 @@ class YHPlanShareViewController: YHBaseViewController {
return v
}()
lazy var shareLinkBgView: YHPlanShareBgView = {
let v = YHPlanShareBgView()
v.index = .link
return v
}()
lazy var sharePdfBgView: YHPlanShareBgView = {
let v = YHPlanShareBgView()
v.index = .pdf
return v
}()
override func viewDidLoad() {
super.viewDidLoad()
gk_navigationBar.backgroundColor = .clear
view.backgroundColor = .init(hex: 0xF5F6F8)
view.addSubview(segmentedView)
view.addSubview(scrollView)
view.addSubview(listContainerView)
view.addSubview(bottomShareView)
segmentedView.snp.makeConstraints { make in
make.top.equalTo(8+k_Height_NavigationtBarAndStatuBar)
make.height.equalTo(34)
make.width.equalTo(64.0*2.0 + 24.0)
make.width.equalTo(64.0*2.0 + 24.0 + 22*2)
make.centerX.equalToSuperview()
}
scrollView.snp.makeConstraints { make in
listContainerView.snp.makeConstraints { make in
make.top.equalTo(segmentedView.snp.bottom).offset(20)
make.centerX.equalToSuperview()
make.width.equalTo(293)
make.height.equalTo(380)
make.width.equalTo(bgWidth)
make.height.equalTo(bgHeight)
}
bottomShareView.snp.makeConstraints { make in
......@@ -85,3 +158,18 @@ extension YHPlanShareViewController: JXSegmentedViewDelegate {
}
}
extension YHPlanShareViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
return segmentTitles.count
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
if index == 0 {
return shareLinkBgView
}
return sharePdfBgView
}
}
......@@ -93,14 +93,14 @@ class YHPlanShareView: UIView {
make.width.equalTo(64)
make.height.equalTo(74)
make.top.equalTo(20)
make.centerX.equalToSuperview().offset(35)
make.left.equalTo(self.snp.centerX).offset(35)
}
wechatBtn.snp.makeConstraints { make in
make.width.equalTo(64)
make.height.equalTo(74)
make.top.equalTo(24)
make.centerX.equalToSuperview().offset(35)
make.top.equalTo(20)
make.right.equalTo(self.snp.centerX).offset(-35)
}
cancelBtn.snp.makeConstraints { make in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment