|
@@ -11,16 +11,22 @@ import UIKit
|
|
|
|
|
|
class JDHomeExponentCell: BaseTableViewCell {
|
|
class JDHomeExponentCell: BaseTableViewCell {
|
|
|
|
|
|
|
|
+ lazy var listData:[KSymbolModel] = {
|
|
|
|
+ let arr:[KSymbolModel] = [KSymbolModel]()
|
|
|
|
+ return arr
|
|
|
|
+ }()
|
|
|
|
|
|
lazy var collectionView : UICollectionView = {
|
|
lazy var collectionView : UICollectionView = {
|
|
|
|
|
|
let layout = UICollectionViewFlowLayout.init()
|
|
let layout = UICollectionViewFlowLayout.init()
|
|
|
|
|
|
|
|
|
|
- let itemW = (SCREEN_WIDTH - 60)/3
|
|
|
|
|
|
+ let itemW = (SCREEN_WIDTH - 40)/3.0 - 1
|
|
|
|
+
|
|
|
|
+ layout.minimumInteritemSpacing = 10
|
|
|
|
+ layout.minimumLineSpacing = 10
|
|
|
|
|
|
- layout.minimumInteritemSpacing = 6
|
|
|
|
- layout.itemSize = CGSizeMake(CGFloat(itemW), 133)
|
|
|
|
|
|
+ layout.itemSize = CGSizeMake(CGFloat(itemW), 150)
|
|
layout.sectionInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
|
|
layout.sectionInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
|
|
|
|
|
|
|
@@ -37,13 +43,13 @@ class JDHomeExponentCell: BaseTableViewCell {
|
|
|
|
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
-
|
|
|
|
|
|
+ contentView.backgroundColor = ALLBackGroundColor
|
|
contentView.addSubview(collectionView)
|
|
contentView.addSubview(collectionView)
|
|
collectionView.snp.makeConstraints { make in
|
|
collectionView.snp.makeConstraints { make in
|
|
- make.top.equalTo(contentView.snp.top).offset(15)
|
|
|
|
- make.left.equalTo(contentView.snp.left).offset(18)
|
|
|
|
- make.right.equalTo(contentView.snp.right).offset(-18)
|
|
|
|
- make.bottom.equalTo(contentView.snp.bottom).offset(-19)
|
|
|
|
|
|
+ make.top.equalTo(contentView.snp.top).offset(10)
|
|
|
|
+ make.left.equalTo(contentView.snp.left).offset(10)
|
|
|
|
+ make.right.equalTo(contentView.snp.right).offset(-10)
|
|
|
|
+ make.bottom.equalTo(contentView.snp.bottom).offset(-10)
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -52,20 +58,26 @@ class JDHomeExponentCell: BaseTableViewCell {
|
|
fatalError("init(coder:) has not been implemented")
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func updateCellDataWith(list:[KSymbolModel]) -> Void {
|
|
|
|
+ listData.removeAll()
|
|
|
|
+ self.listData = list
|
|
|
|
+ self.collectionView.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
extension JDHomeExponentCell : UICollectionViewDataSource{
|
|
extension JDHomeExponentCell : UICollectionViewDataSource{
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
- return 6
|
|
|
|
|
|
+ return self.listData.count
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
|
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: JDHomeExponentItem.description(), for: indexPath) as! JDHomeExponentItem
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: JDHomeExponentItem.description(), for: indexPath) as! JDHomeExponentItem
|
|
-
|
|
|
|
|
|
+ cell.updateCellDataWith(model: self.listData[indexPath.row])
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
|
|
|
|
@@ -83,61 +95,60 @@ class JDHomeExponentItem: UICollectionViewCell {
|
|
|
|
|
|
lazy var bgView : UIView = {
|
|
lazy var bgView : UIView = {
|
|
let v = UIView()
|
|
let v = UIView()
|
|
- v.backgroundColor = UIColor.pg_color(withHexString: "E4FFF6")
|
|
|
|
-
|
|
|
|
- v.layer.masksToBounds = true
|
|
|
|
- v.layer.cornerRadius = 6
|
|
|
|
|
|
+ v.backgroundColor = ALLBackGroundColor
|
|
|
|
+ v.setViewLayerBorderColor(myColor: ViewBorderColor, borderWidth: 1, maskBounds: 4)
|
|
|
|
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
lazy var nameLb : UILabel = {
|
|
lazy var nameLb : UILabel = {
|
|
let v = UILabel()
|
|
let v = UILabel()
|
|
- v.textColor = .black
|
|
|
|
- v.font = .systemFont(ofSize: 14)
|
|
|
|
- v.textAlignment = .center
|
|
|
|
- v.text = "上证指数"
|
|
|
|
|
|
+ v.setTextFont(.PFSR, 12)
|
|
|
|
+ v.textAlignment = .left
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
lazy var priceLb : UILabel = {
|
|
lazy var priceLb : UILabel = {
|
|
let v = UILabel()
|
|
let v = UILabel()
|
|
- v.textColor = UIColor.pg_color(withHexString: "1BB570")
|
|
|
|
- v.textAlignment = .center
|
|
|
|
- v.font = .boldSystemFont(ofSize: 19)
|
|
|
|
- v.text = "2363.91"
|
|
|
|
|
|
+ v.textAlignment = .left
|
|
|
|
+ v.setTextFont(.PFSM, 14)
|
|
|
|
+ v.text = "0.00"
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
lazy var todayRateLb : UILabel = {
|
|
lazy var todayRateLb : UILabel = {
|
|
let v = UILabel()
|
|
let v = UILabel()
|
|
- v.textColor = UIColor.pg_color(withHexString: "1BB570")
|
|
|
|
- v.textAlignment = .center
|
|
|
|
- v.font = .systemFont(ofSize: 11)
|
|
|
|
- v.text = "-16.27"
|
|
|
|
|
|
+ v.textColor = MidTextColor
|
|
|
|
+ v.textAlignment = .left
|
|
|
|
+ v.setTextFont(.PFSR, 9)
|
|
|
|
+ v.text = "0.00"
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
lazy var totalRateLb : UILabel = {
|
|
lazy var totalRateLb : UILabel = {
|
|
let v = UILabel()
|
|
let v = UILabel()
|
|
- v.textColor = UIColor.pg_color(withHexString: "1BB570")
|
|
|
|
- v.textAlignment = .center
|
|
|
|
- v.font = .systemFont(ofSize: 11)
|
|
|
|
- v.text = "-14.26"
|
|
|
|
|
|
+ v.textColor = MidTextColor
|
|
|
|
+ v.textAlignment = .left
|
|
|
|
+ v.setTextFont(.PFSR, 9)
|
|
|
|
+ v.text = "0.00"
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
+ lazy var lineView:JDChartLineView = {
|
|
|
|
+ let view:JDChartLineView = JDChartLineView()
|
|
|
|
+ view.lineChartView.minOffset = 0
|
|
|
|
+ view.shadowSize = CGSize(width: 0, height: 3)
|
|
|
|
+ view.isUserInteractionEnabled = false
|
|
|
|
+ view.lineChartView.isUserInteractionEnabled = false
|
|
|
|
+ return view
|
|
|
|
+ }()
|
|
|
|
+
|
|
lazy var buyBtn : UIButton = {
|
|
lazy var buyBtn : UIButton = {
|
|
|
|
|
|
let v = UIButton(type: .custom)
|
|
let v = UIButton(type: .custom)
|
|
- v.setTitle("买入", for: .normal)
|
|
|
|
- v.setTitleColor( UIColor.pg_color(withHexString: "FF6F30"), for: .normal)
|
|
|
|
- v.titleLabel?.font = .systemFont(ofSize: 12)
|
|
|
|
-
|
|
|
|
|
|
+ v.setTextFont(.PFSR, 10)
|
|
v.layer.masksToBounds = true
|
|
v.layer.masksToBounds = true
|
|
- v.layer.cornerRadius = 12.5
|
|
|
|
- v.layer.borderColor = UIColor.pg_color(withHexString: "FE6F30").cgColor
|
|
|
|
- v.layer.borderWidth = 1
|
|
|
|
|
|
+ v.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 4)
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -145,14 +156,9 @@ class JDHomeExponentItem: UICollectionViewCell {
|
|
lazy var sellBtn : UIButton = {
|
|
lazy var sellBtn : UIButton = {
|
|
|
|
|
|
let v = UIButton(type: .custom)
|
|
let v = UIButton(type: .custom)
|
|
- v.setTitle("卖出", for: .normal)
|
|
|
|
- v.setTitleColor( UIColor.pg_color(withHexString: "62D585"), for: .normal)
|
|
|
|
- v.titleLabel?.font = .systemFont(ofSize: 12)
|
|
|
|
-
|
|
|
|
|
|
+ v.setTextFont(.PFSR, 10)
|
|
v.layer.masksToBounds = true
|
|
v.layer.masksToBounds = true
|
|
- v.layer.cornerRadius = 12.5
|
|
|
|
- v.layer.borderColor = UIColor.pg_color(withHexString: "62D585").cgColor
|
|
|
|
- v.layer.borderWidth = 1
|
|
|
|
|
|
+ v.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 4)
|
|
return v
|
|
return v
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -169,47 +175,100 @@ class JDHomeExponentItem: UICollectionViewCell {
|
|
|
|
|
|
bgView.addSubview(nameLb)
|
|
bgView.addSubview(nameLb)
|
|
nameLb.snp.makeConstraints { make in
|
|
nameLb.snp.makeConstraints { make in
|
|
- make.centerX.equalTo(bgView)
|
|
|
|
- make.top.equalTo(bgView.snp.top).offset(14)
|
|
|
|
|
|
+ make.left.equalTo(5)
|
|
|
|
+ make.right.equalTo(-5)
|
|
|
|
+ make.top.equalTo(10)
|
|
}
|
|
}
|
|
|
|
|
|
bgView.addSubview(priceLb)
|
|
bgView.addSubview(priceLb)
|
|
priceLb.snp.makeConstraints { make in
|
|
priceLb.snp.makeConstraints { make in
|
|
- make.top.equalTo(nameLb.snp.bottom).offset(12)
|
|
|
|
- make.centerX.equalTo(bgView)
|
|
|
|
|
|
+ make.top.equalTo(nameLb.snp.bottom).offset(10)
|
|
|
|
+ make.left.equalTo(5)
|
|
|
|
+ make.right.equalTo(-5)
|
|
}
|
|
}
|
|
|
|
|
|
bgView.addSubview(todayRateLb)
|
|
bgView.addSubview(todayRateLb)
|
|
todayRateLb.snp.makeConstraints { make in
|
|
todayRateLb.snp.makeConstraints { make in
|
|
- make.top.equalTo(priceLb.snp.bottom).offset(7)
|
|
|
|
- make.left.equalTo(bgView.snp.left).offset(16)
|
|
|
|
|
|
+ make.top.equalTo(priceLb.snp.bottom).offset(5)
|
|
|
|
+ make.left.equalTo(5)
|
|
}
|
|
}
|
|
|
|
|
|
bgView.addSubview(totalRateLb)
|
|
bgView.addSubview(totalRateLb)
|
|
totalRateLb.snp.makeConstraints { make in
|
|
totalRateLb.snp.makeConstraints { make in
|
|
make.centerY.equalTo(todayRateLb)
|
|
make.centerY.equalTo(todayRateLb)
|
|
- make.left.equalTo(todayRateLb.snp.right).offset(6)
|
|
|
|
|
|
+ make.left.equalTo(todayRateLb.snp.right).offset(5)
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- bgView.addSubview(buyBtn)
|
|
|
|
- buyBtn.snp.makeConstraints { make in
|
|
|
|
- make.bottom.equalTo(bgView.snp.bottom).offset(-12)
|
|
|
|
- make.right.equalTo(bgView.snp.centerX).offset(-2)
|
|
|
|
- make.size.equalTo(CGSizeMake(44, 22))
|
|
|
|
|
|
+ bgView.addSubview(self.lineView)
|
|
|
|
+ self.lineView.snp.makeConstraints { make in
|
|
|
|
+ make.top.equalTo(self.todayRateLb.snp.bottom).offset(15)
|
|
|
|
+ make.left.equalTo(10)
|
|
|
|
+ make.right.equalTo(-10)
|
|
|
|
+ make.bottom.equalTo(-35)
|
|
}
|
|
}
|
|
|
|
|
|
bgView.addSubview(sellBtn)
|
|
bgView.addSubview(sellBtn)
|
|
sellBtn.snp.makeConstraints { make in
|
|
sellBtn.snp.makeConstraints { make in
|
|
- make.centerY.equalTo(buyBtn)
|
|
|
|
- make.left.equalTo(bgView.snp.centerX).offset(2)
|
|
|
|
- make.size.equalTo(CGSizeMake(44, 22))
|
|
|
|
|
|
+ make.bottom.equalTo(0)
|
|
|
|
+ make.left.equalTo(0)
|
|
|
|
+ make.height.equalTo(20)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bgView.addSubview(buyBtn)
|
|
|
|
+ buyBtn.snp.makeConstraints { make in
|
|
|
|
+ make.bottom.equalTo(0)
|
|
|
|
+ make.right.equalTo(0)
|
|
|
|
+ make.left.equalTo(sellBtn.snp.right).offset(2)
|
|
|
|
+ make.width.equalTo(sellBtn.snp.width)
|
|
|
|
+ make.height.equalTo(20)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func updateCellDataWith(model:KSymbolModel) -> Void {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ self.nameLb.textColor = TitleTextColor
|
|
|
|
+
|
|
|
|
+ self.todayRateLb.textColor = MidTextColor
|
|
|
|
+ self.totalRateLb.textColor = MidTextColor
|
|
|
|
+
|
|
|
|
+ self.sellBtn.setTitle(switchLanguage("卖出"), for: .normal)
|
|
|
|
+ self.sellBtn.setTitleColor(MidTextColor, for: .normal)
|
|
|
|
+ self.sellBtn.backgroundColor = MidBackGroundColor;
|
|
|
|
+
|
|
|
|
+ self.buyBtn.setTitle(switchLanguage("买入"), for: .normal)
|
|
|
|
+ self.buyBtn.setTitleColor(MidTextColor, for: .normal)
|
|
|
|
+ self.buyBtn.backgroundColor = MidBackGroundColor;
|
|
|
|
+
|
|
|
|
+ self.nameLb.text = model.title
|
|
|
|
+
|
|
|
|
+ self.priceLb.text = precisionString(with: model.newPrice, precision: model.digits)
|
|
|
|
+
|
|
|
|
+ let today:Double = conerData(model.newPrice, .MyDouble).2! - conerData(model.open, .MyDouble).2!
|
|
|
|
+ if today > 0 {
|
|
|
|
+ self.todayRateLb.text = String(format: "+%.2f", today)
|
|
|
|
+ }else{
|
|
|
|
+ self.todayRateLb.text = String(format: "%.2f", today)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let increase = conerData(model.increase as Any, .MyFloat).1!
|
|
|
|
+ if increase > 0 {
|
|
|
|
+ self.totalRateLb.text = "+" + precisionString(with: model.increase, precision: "2") + "%"
|
|
|
|
+ }else{
|
|
|
|
+ self.totalRateLb.text = precisionString(with: model.increase, precision: "2") + "%"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self.priceLb.textColor = exchangeColorAndImage(increase: increase).0
|
|
|
|
+
|
|
|
|
+ self.lineView.updateHomeData(fillColor: self.priceLb.textColor , gradientColor: ALLBackGroundColor , data: model.data)
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|