|
@@ -0,0 +1,79 @@
|
|
|
+//
|
|
|
+// JDSelectIdentityTypePopView.swift
|
|
|
+// Koala
|
|
|
+//
|
|
|
+// Created by mac on 2024/9/3.
|
|
|
+// Copyright © 2024 Koala. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
+import UIKit
|
|
|
+
|
|
|
+class JDSelectIdentityTypePopView: JDBaseTableAlertView {
|
|
|
+ var sourceArray: [(UIImage, String, Bool)] = .init()
|
|
|
+ var selectTitle: String = switchLanguage("身份证")
|
|
|
+
|
|
|
+ var myCompletion: ((_ index: Int, _ title: String) -> Void)?
|
|
|
+
|
|
|
+ override init(containerViewHeight: CGFloat) {
|
|
|
+ super.init(containerViewHeight: containerViewHeight)
|
|
|
+
|
|
|
+ tableView.rowHeight = 60
|
|
|
+ tableView.register(JDFinancialStatusCell.self, forCellReuseIdentifier: JDFinancialStatusCell.description())
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func confirmBtnAction() {
|
|
|
+ if let block = myCompletion {
|
|
|
+ block(selectedIndex, selectTitle)
|
|
|
+ }
|
|
|
+ dismissAlert()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension JDSelectIdentityTypePopView {
|
|
|
+ func showPopupView(source: [(UIImage, String, Bool)], index: Int, completion: @escaping (_ index: Int, _ title: String) -> Void) {
|
|
|
+ sourceArray = source
|
|
|
+ myCompletion = completion
|
|
|
+
|
|
|
+ super.showPopupView(selectIndex: index, completion: convertCompletion(completion: completion))
|
|
|
+ }
|
|
|
+
|
|
|
+ func convertCompletion(completion: @escaping (_ index: Int, _ title: String) -> Void) -> (_ index: Int) -> Void {
|
|
|
+ return { index in
|
|
|
+ completion(index, "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension JDSelectIdentityTypePopView {
|
|
|
+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
+ return sourceArray.count
|
|
|
+ }
|
|
|
+
|
|
|
+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
+ let cell = tableView.dequeueReusableCell(withIdentifier: JDFinancialStatusCell.description()) as! JDFinancialStatusCell
|
|
|
+
|
|
|
+ cell.statusLb.text = sourceArray[indexPath.row].1
|
|
|
+
|
|
|
+ if selectedIndex == indexPath.row {
|
|
|
+ cell.bgView.backgroundColor = .white
|
|
|
+ cell.bgView.layer.borderColor = _color("#858585󑧙").cgColor
|
|
|
+ cell.iconIv.isHidden = false
|
|
|
+ } else {
|
|
|
+ cell.bgView.backgroundColor = .white
|
|
|
+ cell.bgView.layer.borderColor = _color("#FFFFFF&#FFFFFF").cgColor
|
|
|
+ cell.iconIv.isHidden = true
|
|
|
+ }
|
|
|
+
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+
|
|
|
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
+ selectedIndex = indexPath.row
|
|
|
+ selectTitle = sourceArray[indexPath.row].1
|
|
|
+
|
|
|
+ self.tableView.reloadData()
|
|
|
+
|
|
|
+ confirmBtnAction()
|
|
|
+ }
|
|
|
+}
|