|
@@ -1,102 +0,0 @@
|
|
|
-//
|
|
|
-// CommunityViewController.swift
|
|
|
-// Koala
|
|
|
-//
|
|
|
-// Created by 刘千军 on 2023/4/2.
|
|
|
-// Copyright © 2023 刘千军. All rights reserved.
|
|
|
-//
|
|
|
-
|
|
|
-import SafariServices
|
|
|
-import UIKit
|
|
|
-
|
|
|
-class CommunityViewController: BaseViewController {
|
|
|
- @IBOutlet var tableView: UITableView!
|
|
|
-
|
|
|
- lazy var headerView: CommunityHeaderView = {
|
|
|
- let view = CommunityHeaderView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 290))
|
|
|
-
|
|
|
- return view
|
|
|
- }()
|
|
|
-
|
|
|
- lazy var listData: [MediumModel] = {
|
|
|
- let arr = [MediumModel]()
|
|
|
- return arr
|
|
|
- }()
|
|
|
-
|
|
|
- override func viewDidLoad() {
|
|
|
- super.viewDidLoad()
|
|
|
- myNavigationBar.title_Label.text = switchLanguage("加入DDSE社区")
|
|
|
-
|
|
|
- tableView.delegate = self
|
|
|
- tableView.dataSource = self
|
|
|
- tableView.separatorStyle = .none
|
|
|
- tableView.backgroundColor = .clear
|
|
|
- tableView.tableFooterView = UIView()
|
|
|
- tableView.tableHeaderView = headerView
|
|
|
- tableView.showsVerticalScrollIndicator = false
|
|
|
- tableView.showsVerticalScrollIndicator = false
|
|
|
-
|
|
|
- tableView.register(UINib(nibName: "MineViewCell", bundle: nil), forCellReuseIdentifier: "MineViewCell")
|
|
|
-
|
|
|
- getIndexMedium()
|
|
|
- }
|
|
|
-
|
|
|
- func getIndexMedium() {
|
|
|
- NetWork.NetWorkInstance.requestData(requestType: .Post, URLString: netForIndexMedium, success: { _, result in
|
|
|
- ProgressHUD.hideHud()
|
|
|
- if let list: [NSDictionary] = result as? [NSDictionary] {
|
|
|
- self.listData.removeAll()
|
|
|
- for dic in list {
|
|
|
- let model = MediumModel.deserialize(from: dic)!
|
|
|
- self.listData.append(model)
|
|
|
- }
|
|
|
- self.tableView.reloadData()
|
|
|
- } else {}
|
|
|
-
|
|
|
- }) { _, result in
|
|
|
- ProgressHUD.showError(status: result as! String)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 代理
|
|
|
-extension CommunityViewController: UITableViewDelegate, UITableViewDataSource {
|
|
|
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
- return listData.count
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
- let cell: MineViewCell = tableView.dequeueReusableCell(withIdentifier: "MineViewCell") as! MineViewCell
|
|
|
- let model = listData[indexPath.row]
|
|
|
- cell.updateMediumCellWithModel(model: model)
|
|
|
- return cell
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
- return 54
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
|
- return UIView()
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
|
- return UIView()
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
|
- return 0
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
- return 2
|
|
|
- }
|
|
|
-
|
|
|
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
- let model = listData[indexPath.row]
|
|
|
- if let url = URL(string: model.url) {
|
|
|
- let safariVC = SFSafariViewController(url: url)
|
|
|
- currentVc()?.navigationController?.present(safariVC, animated: true, completion: nil)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|