Commit 2f3c1e45 authored by David黄金龙's avatar David黄金龙

Merge branch 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into develop

* 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  解决闪频问题
  // 搜索
  // 消息
  // 搜索
parents 651bbcf9 ef2e929f
......@@ -10,11 +10,28 @@ import UIKit
class YHSearchInfomationVC: YHBaseViewController {
var items:[String] = ["阿斯顿法师法师法师","发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法","发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法","啊发顺丰"]
var items:[YHHomeListModel] = []
lazy var viewModel : YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
return viewModel
}()
lazy var searchBar: YHSearchInfoBar = {
let bar = YHSearchInfoBar(frame: CGRect(x: 20, y: k_Height_NavigationtBarAndStatuBar+8.0, width: KScreenWidth-40, height: 36.0))
bar.searchBlock = {
[weak self] text in
guard let self = self else { return }
self.viewModel.searchArticleList(text ?? "") {
[weak self] success, error in
guard let self = self else { return }
items.removeAll()
if let arr = self.viewModel.arrHomeNewsData {
items.append(contentsOf: arr)
}
self.tableView.reloadData()
}
}
return bar
}()
......@@ -54,6 +71,7 @@ class YHSearchInfomationVC: YHBaseViewController {
view.addSubview(searchBar)
view.addSubview(searchHistoryView)
view.addSubview(tableView)
searchBar.textField.becomeFirstResponder()
searchBar.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20)
......@@ -92,7 +110,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section]
cell.titleLabel.text = items[indexPath.section]
cell.updateModel(item)
}
return cell
}
......@@ -104,7 +122,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.section && indexPath.section < items.count {
let text = items[indexPath.section]
let articleInfo = items[indexPath.section]
self.tableView.isHidden = true
self.searchHistoryView.isHidden = false
}
......
......@@ -40,7 +40,7 @@ class YHHomeListModel: YHBaseModel {
var img_height_cell : CGFloat = 0
//描述的高度
var textH : CGFloat = 20.0
var textH : CGFloat = 16.0
......@@ -81,6 +81,5 @@ class YHHomeListModel: YHBaseModel {
self.img_width_cell = width
self.img_height_cell = totalHeight
}
}
......@@ -7,8 +7,7 @@
//
import UIKit
import Kingfisher
class YHSearchInfoCell: UITableViewCell {
......@@ -41,6 +40,13 @@ class YHSearchInfoCell: UITableViewCell {
return label
}()
func updateModel(_ model: YHHomeListModel) {
titleLabel.text = model.title
if let url = URL(string: model.img_url) {
headImgView.kf.setImage(with: url)
}
}
func setupUI() {
contentView.backgroundColor = .white
......
......@@ -200,4 +200,36 @@ extension YHHomePageViewModel {
callBackBlock(false,err)
}
}
// 搜索
func searchArticleList(_ title: String, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10,
"title": title]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHHomeListTotalModel.deserialize(from: dic as? Dictionary) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
for item in result.data {
item.calHeightParam()
}
self.arrHomeNewsData = result.data
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -172,7 +172,6 @@ extension YHHomeCollectionViewCell {
make.top.equalToSuperview().offset(10)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.height.equalTo(listModel.textH)
make.bottom.equalTo(-36)
}
numLable.text = listModel.like_count.string
......
......@@ -39,7 +39,7 @@ class YHServiceSectionView: UIView {
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.contentInset = UIEdgeInsets(top: 10, left: 20, bottom: 0, right: 20)
collectinoView.contentInset = UIEdgeInsets(top: 8, left: 20, bottom: 0, right: 20)
collectinoView.register(YHServiceSectionCollectionViewCell.self, forCellWithReuseIdentifier:YHServiceSectionCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
......
......@@ -10,7 +10,7 @@ import UIKit
class YHMyNotifySettingVC: YHBaseViewController {
var items:[YHPermissionItem] = [YHPermissionItem(title: "接收推送消息通知".local, enableStatus: false)]
var items:[YHPermissionItem] = [YHPermissionItem(title: "接收推送消息通知".local, type:.notify, enableStatus: false)]
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
......
......@@ -8,22 +8,34 @@
import UIKit
enum YHPermissionType: Int {
case none = 0
case network = 1
case photo = 2
case camera = 3
case location = 4
case file = 5
case notify = 6
}
class YHPermissionItem {
var type: YHPermissionType = .none
var title:String = ""
var enableStatus:Bool = false
init(title: String, enableStatus: Bool) {
init(title: String, type:YHPermissionType, enableStatus: Bool) {
self.title = title
self.type = type
self.enableStatus = enableStatus
}
}
class YHMyPermissionSettingVC: YHBaseViewController {
var items:[YHPermissionItem] = [YHPermissionItem(title: "网络".local, enableStatus: true),
YHPermissionItem(title: "照片".local, enableStatus: true),
YHPermissionItem(title: "相机".local, enableStatus: false),
YHPermissionItem(title: "位置".local, enableStatus: true),
YHPermissionItem(title: "文件".local, enableStatus: false)]
var items:[YHPermissionItem] = [YHPermissionItem(title: "网络".local, type:.network, enableStatus: true),
YHPermissionItem(title: "照片".local, type:.photo, enableStatus: true),
YHPermissionItem(title: "相机".local, type:.camera, enableStatus: false),
YHPermissionItem(title: "位置".local, type:.location, enableStatus: true),
YHPermissionItem(title: "文件".local, type:.file, enableStatus: false)]
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
......@@ -76,7 +88,28 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < items.count {
let item = items[indexPath.row]
if item.type == .photo || item.type == .camera {
let url = URL(string: UIApplication.openSettingsURLString)
if let url = url, UIApplication .shared.canOpenURL(url) {
UIApplication .shared.open(url, options: [:], completionHandler: {
(success) in
})
}
return
}
if item.type == .location {
if let url = URL(string: "App-prefs:Photos") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
} else if item.type == .file {
}
}
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment