Bladeren bron

优化交易页搜索页面

Vincent Hu 2 weken geleden
bovenliggende
commit
3af340cc62

+ 16 - 8
Koala/Koala/Modular/Deal/VC/DealSelectSymbolViewController.swift

@@ -33,10 +33,13 @@ class DealSelectSymbolViewController: BaseViewController {
         return arr
     }()
     
-    lazy var hotList: [ProductHotListModel] = { // 热门搜索
-        let arr = [ProductHotListModel]()
-        return arr
-    }()
+    lazy var hotList: [ProductHotListModel] = [] {
+        didSet {
+            if hotList.count > 5 {
+                hotList = Array(hotList.prefix(5))
+            }
+        }
+    }
 
     var symbol_string: [String] = []
     
@@ -78,7 +81,7 @@ class DealSelectSymbolViewController: BaseViewController {
         tableView.separatorInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
         tableView.delegate = self
         tableView.dataSource = self
-        tableView.backgroundColor = .clear
+        tableView.backgroundColor = .white
         tableView.tableHeaderView = UIView()
         tableView.tableFooterView = UIView()
         tableView.showsHorizontalScrollIndicator = false
@@ -86,6 +89,7 @@ class DealSelectSymbolViewController: BaseViewController {
         tableView.register(UINib(nibName: "MSHotCell", bundle: nil), forCellReuseIdentifier: "MSHotCell")
         tableView.register(JDSearchListCell.self, forCellReuseIdentifier: JDSearchListCell.description())
         tableView.contentInsetAdjustmentBehavior = .never
+        tableView.keyboardDismissMode = .onDrag
         tableView.mj_header = MJRefreshHeader(refreshingBlock: { [weak self] in
             self?.requestSymbolList(isUp: false)
         })
@@ -366,10 +370,14 @@ extension DealSelectSymbolViewController: UITableViewDelegate, UITableViewDataSo
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         if self.isSearch {
+            tableView.separatorStyle = .singleLine
+            
             let cell = tableView.dequeueReusableCell(withIdentifier: JDSearchListCell.description()) as! JDSearchListCell
             cell.updateDealSelectCellWith(model: self.symbolList[indexPath.row])
             return cell
         } else {
+            tableView.separatorStyle = .none
+            
             let cell: MSHotCell = tableView.dequeueReusableCell(withIdentifier: "MSHotCell") as! MSHotCell
             cell.market = self.market
             cell.updateCellWith(list: [self.hotList])
@@ -385,7 +393,7 @@ extension DealSelectSymbolViewController: UITableViewDelegate, UITableViewDataSo
         if self.isSearch {
             return 60
         }
-        return 40 + 60 + 5*40
+        return 40 + 60 + 5 * 40
     }
     
     func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
@@ -394,13 +402,13 @@ extension DealSelectSymbolViewController: UITableViewDelegate, UITableViewDataSo
         }
         
         let view = UIView()
-        view.backgroundColor = _color("#F6FAFE&#F6FAFE")
+        view.backgroundColor = .white
         return view
     }
     
     func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
         let view = UIView()
-        view.backgroundColor = _color("#F6FAFE&#F6FAFE")
+        view.backgroundColor = .white
         return view
     }
     

+ 3 - 7
Koala/Koala/Modular/Market/V/MarketSearch/JDMSHotListCell.swift

@@ -11,9 +11,9 @@ import UIKit
 class JDMSHotListCell: UICollectionViewCell {
     lazy var bgView: UIView = {
         let v = UIView()
-        v.backgroundColor = .white
+        v.backgroundColor = _color("#FAFBFC&#FAFBFC")
+        v.layer.cornerRadius = 10
         v.layer.masksToBounds = true
-        v.setViewLayerBorderColor(myColor: .clear, borderWidth: 0, maskBounds: 6)
         return v
     }()
 
@@ -42,7 +42,6 @@ class JDMSHotListCell: UICollectionViewCell {
         v.tableFooterView = UIView()
         v.tableHeaderView = UIView()
         v.showsVerticalScrollIndicator = false
-        v.showsVerticalScrollIndicator = false
         v.register(UINib(nibName: "MSHListCell", bundle: nil), forCellReuseIdentifier: "MSHListCell")
         v.isScrollEnabled = false
         return v
@@ -70,7 +69,7 @@ class JDMSHotListCell: UICollectionViewCell {
         
         bgView.addSubview(imgView)
         imgView.snp.makeConstraints { make in
-            make.top.equalTo(bgView.snp.top).offset(13)
+            make.top.equalTo(bgView.snp.top).offset(15)
             make.left.equalTo(bgView.snp.left).offset(9)
             make.size.equalTo(CGSize(width: 14, height: 14))
         }
@@ -95,9 +94,6 @@ class JDMSHotListCell: UICollectionViewCell {
             make.left.right.equalTo(bgView)
             make.bottom.equalTo(bgView.snp.bottom).offset(-12)
         }
-        bgView.backgroundColor = _color("#FAFBFC&#FAFBFC")
-        bgView.layer.cornerRadius = 6
-        bgView.layer.masksToBounds = true
     }
     
     @available(*, unavailable)

+ 5 - 1
Koala/Koala/Modular/Market/V/MarketSearch/MarketSearchView.swift

@@ -89,7 +89,7 @@ class MarketSearchView: BaseView {
         tableView.showsHorizontalScrollIndicator = false
         tableView.showsVerticalScrollIndicator = false
         tableView.contentInsetAdjustmentBehavior = .never
-        
+        tableView.keyboardDismissMode = .onDrag
         tableView.register(UINib(nibName: "MSHotCell", bundle: nil), forCellReuseIdentifier: "MSHotCell")
         
         tableView.register(JDSearchListCell.self, forCellReuseIdentifier: JDSearchListCell.description())
@@ -267,6 +267,8 @@ extension MarketSearchView: UITableViewDelegate, UITableViewDataSource {
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         if self.VM!.isSearch {
+            tableView.separatorStyle = .singleLine
+            
             let cell = tableView.dequeueReusableCell(withIdentifier: JDSearchListCell.description()) as! JDSearchListCell
             if indexPath.row < self.VM!.symbolList.count {
                 let model = self.VM!.symbolList[indexPath.row]
@@ -290,6 +292,8 @@ extension MarketSearchView: UITableViewDelegate, UITableViewDataSource {
             }
             return cell
         } else {
+            tableView.separatorStyle = .none
+            
             let cell: MSHotCell = tableView.dequeueReusableCell(withIdentifier: "MSHotCell") as! MSHotCell
           
             cell.updateCellWith(list: self.VM!.productHotList)