Quellcode durchsuchen

买卖画面进入时选中状态修复

lintong vor 2 Wochen
Ursprung
Commit
2861f1b040

+ 5 - 5
Koala/Koala/Modular/Deal/V/Deal/DealSimCell.swift

@@ -220,7 +220,7 @@ class DealSimCell: BaseTableViewCell {
     func updateCellWith(vm: DealViewModel) {
         self.VM = vm
         
-        self.updateBuySell(isSell: vm.isSell)
+        self.updateBuySell(isSell: vm.isSell.value)
         
         if vm.isMarket {
             self.typeLab.text = switchLanguage("市价单")
@@ -276,12 +276,12 @@ class DealSimCell: BaseTableViewCell {
 
 extension DealSimCell {
     @objc func clickBuyBtnAction() {
-        self.VM?.isSell = false
+        self.VM?.isSell.value = false
         self.updateBuySell(isSell: false)
     }
     
     @objc func clickSellBtnAction() {
-        self.VM?.isSell = true
+        self.VM?.isSell.value = true
         self.updateBuySell(isSell: true)
     }
     
@@ -407,7 +407,7 @@ extension DealSimCell {
         }
         /// 是否是市单价
         if self.VM?.isMarket == true {
-            if self.VM?.isSell == true {
+            if self.VM?.isSell.value == true {
                 self.VM?.selectOrderType = 1
             } else {
                 self.VM?.selectOrderType = 0
@@ -433,7 +433,7 @@ extension DealSimCell {
 //            let double_price = Double(self.VM.price) ?? 0.0
             let double_price = Double(self.VM?.enterPrice ?? "0.00") ?? 0.0
             /// 是否是卖
-            if self.VM?.isSell == true {
+            if self.VM?.isSell.value == true {
                 // 卖出
                 if double_price > market_price {
                     // 3-高价做空(挂单卖出,挂单价比当前价格高)

+ 6 - 6
Koala/Koala/Modular/Deal/V/Deal/DealSimplenessCell.swift

@@ -442,7 +442,7 @@ extension DealSimplenessCell {
         
         let pop = KMenuPopupMenuView()
         var list = [(UIImage, String, Bool)]()
-        if self.VM?.isSell == true {
+        if self.VM?.isSell.value == true {
             list = [
                 (UIImage(), switchLanguage("高价挂单卖出"), true),
                 (UIImage(), switchLanguage("低价挂单卖出"), true),
@@ -457,7 +457,7 @@ extension DealSimplenessCell {
         pop.showRelyPopupView(view: self.limitView, source: list, sStr: self.limitTypeLab.text ?? "") { [weak self] index in
             if index >= 0 {
                 self?.limitTypeLab.text = list[index].1
-                if self!.VM?.isSell == true {
+                if self!.VM?.isSell.value == true {
                     if index == 0 {
                         self?.VM?.selectOrderType = 3
                     } else {
@@ -504,14 +504,14 @@ extension DealSimplenessCell {
     
     @objc func clickSellBtnAction() {
         self.endEditing(true)
-        self.VM?.isSell = true
+        self.VM?.isSell.value = true
         self.updateLayer()
         self.clickRefreshBlock?()
     }
     
     @objc func clickBuyBtnAction() {
         self.endEditing(true)
-        self.VM?.isSell = false
+        self.VM?.isSell.value = false
         self.updateLayer()
         self.clickRefreshBlock?()
     }
@@ -528,7 +528,7 @@ extension DealSimplenessCell {
         }
        
         if self.VM?.isMarket == true {
-            if self.VM?.isSell == true {
+            if self.VM?.isSell.value == true {
                 self.VM?.selectOrderType = 1
             } else {
                 self.VM?.selectOrderType = 0
@@ -579,7 +579,7 @@ extension DealSimplenessCell {
             self.cashBgView.isHidden = true
         }
         
-        if VM.isSell {
+        if VM.isSell.value {
             self.sellBtn.backgroundColor = exchangeColorAndImage(increase: -1).0
             self.sellTitleLab.textColor = WhiteTextColor
             self.sellLab.textColor = WhiteTextColor

+ 1 - 0
Koala/Koala/Modular/Deal/V/Deal/DealTableSectionView.swift

@@ -486,6 +486,7 @@ extension DealTableSectionView {
                     }
                     else {
                         liteInfoView.vm = vm
+                        self.dealSimCell.updateBuySell(isSell: vm.isSell.value)
                     }
                 }
             }

+ 9 - 0
Koala/Koala/Modular/Deal/V/Deal/DealView.swift

@@ -12,6 +12,7 @@ import SkeletonView
 
 class DealView: BaseView {
     weak var VM: DealViewModel?
+    
     lazy var tipsView: ClosedMarketTipsView = {
         let tipsView = ClosedMarketTipsView.showTips()
         return tipsView
@@ -1039,6 +1040,14 @@ class DealView: BaseView {
                 }
             }
         }
+        
+        
+        self.VM?.isSell.producer
+            .skipRepeats()
+            .delay(1.0, on: QueueScheduler.main)
+            .take(during: lifetime).startWithValues({[weak self] newflag in
+            self?.tabHeaderView.updateSimData()
+        })
     }
     
     func clearData() {

+ 1 - 1
Koala/Koala/Modular/Deal/VC/DealViewController.swift

@@ -77,7 +77,7 @@ class DealViewController: BaseViewController {
         }
         
         if DealBuySell > -1 {
-            self.viewModel.isSell = DealBuySell == 1
+            self.viewModel.isSell.value = DealBuySell == 1
             DealBuySell = -1
         }
         

+ 1 - 1
Koala/Koala/Modular/Deal/VM/DealViewModel.swift

@@ -177,7 +177,7 @@ class DealViewModel: BaseViewModel {
     
     var isUpdateKline = true // 是否
     var isSimpleness = true // 是否
-    var isSell = false // 是否
+    let isSell =  MutableProperty<Bool>(false) // 是否
     var isMarket = true // 是否
     var isShowKline = false // 是否
     var isDayLimit = true // 是否

+ 1 - 1
Koala/Koala/Modular/Market/VC/MarketDetailViewController.swift

@@ -102,7 +102,7 @@ class MarketDetailViewController: BaseViewController {
                 dealVC.viewModel.updateSymbols(symbol: symbolModel)
                 dealVC.viewModel.curSymbol = symbolModel.symbol
                 dealVC.viewModel.selectSymbolModel = symbolModel
-                dealVC.viewModel.isSell = true
+                dealVC.viewModel.isSell.value = true
                 dealVC.viewModel.server = symbolModel.market
                 OperationalSymbolSocketManager.shared().skipSymbolDisconnect = true
                 OperationalSymbolSocketManager.shared().skipTradeDisconnect = true

+ 1 - 1
Koala/Koala/Modular/MarketDetail/C/MarketAuoteViewController.swift

@@ -103,9 +103,9 @@ class MarketAuoteViewController: BaseViewController {
             dealVC.viewModel.updateSymbols(symbol: symbolModel)
             dealVC.viewModel.curSymbol = symbolModel.symbol
             dealVC.viewModel.selectSymbolModel = symbolModel
-            dealVC.viewModel.isSell = true
             dealVC.viewModel.server = symbolModel.market
             self.navigationController?.pushViewController(dealVC, animated: true)
+            dealVC.viewModel.isSell.value = true
         }
         return view
     }()