CNLiveShopTransViewController.swift
4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// CNLiveShopTransViewController.swift
// metaCode
//
// Created by open on 2023/11/15.
//
import Foundation
import JXSegmentedView
import JXPagingView
class CNLiveShopTransViewController: CNLiveBaseViewController {
lazy var viewControllers: NSMutableArray = {
let viewControllers = NSMutableArray.init()
viewControllers.add(CNLiveShopTransListViewController.init(show_type: .all))
viewControllers.add(CNLiveShopTransListViewController.init(show_type: .income))
viewControllers.add(CNLiveShopTransListViewController.init(show_type: .outcome))
return viewControllers
}()
lazy var dataSource: JXSegmentedNumberDataSource = {
let dataSource = JXSegmentedNumberDataSource()
dataSource.titles = ["全部","收入","支出"]
dataSource.numbers = [0,0,0,0]
dataSource.isTitleColorGradientEnabled = true
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 0
dataSource.titleNormalFont = Font_15_Fit
dataSource.titleSelectedFont = Font_15_Fit
dataSource.titleNormalColor = HexColor("#999999")!
dataSource.titleSelectedColor = HexColor("#28C1C6")!
return dataSource
}()
lazy var categoryView: JXSegmentedView = {
let categoryView = JXSegmentedView.init(frame: CGRectMake(0, KNavigationHeight, KSreenWidth, CGFloat(kCNLiveShopOrderListSectionTitleHeight)))
categoryView.dataSource = dataSource
categoryView.delegate = self
categoryView.collectionView.backgroundColor = HexColor("fafbfd")
categoryView.backgroundColor = .white
let lineView = JXSegmentedIndicatorBackgroundView.init()
lineView.indicatorColor = HexColor("#28C1C6")!
lineView.indicatorHeight = 2
lineView.indicatorPosition = .bottom
lineView.indicatorWidthIncrement = 0
lineView.indicatorCornerRadius = 0
categoryView.indicators = [lineView]
return categoryView
}()
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self)
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = (categoryView.selectedIndex == 0)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
navigationBarHidden = false
titleName = "交易记录"
view.addSubview(categoryView)
categoryView.listContainer = listContainerView
view.addSubview(listContainerView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
categoryView.frame = CGRect(x: 0, y: KNavigationHeight, width: view.bounds.size.width, height: CGFloat(kCNLiveShopOrderListSectionTitleHeight))
listContainerView.frame = CGRect(x: 0, y: KNavigationHeight+CGFloat(kCNLiveShopOrderListSectionTitleHeight), width: view.bounds.size.width, height: view.bounds.size.height - CGFloat(kCNLiveShopOrderListSectionTitleHeight) - KNavigationHeight)
}
}
extension CNLiveShopTransViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
}
extension CNLiveShopTransViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
if let titleDataSource = categoryView.dataSource as? JXSegmentedBaseDataSource {
return titleDataSource.dataSource.count
}
return 0
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return viewControllers[index] as! JXSegmentedListContainerViewListDelegate
}
}