Commit e9eb8d51 authored by Steven杜宇's avatar Steven杜宇

// lint

parent 87fa4d4a
......@@ -270,12 +270,16 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
let msg = messages[indexPath.row]
let msgType = msg.getType()
if msgType == .text {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as? YHAITextMessageCell else {
return UITableViewCell()
}
cell.message = msg
return cell
} else if msgType == .recommendText {
let cell = tableView.dequeueReusableCell(withIdentifier: YHRecommendTextMessageCell.cellReuseIdentifier, for: indexPath) as! YHRecommendTextMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHRecommendTextMessageCell.cellReuseIdentifier, for: indexPath) as? YHRecommendTextMessageCell else {
return UITableViewCell()
}
cell.message = msg
cell.messageClick = {
[weak self] text in
......@@ -293,11 +297,15 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
return cell
} else if msgType == .thinking {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAIThinkingMessageCell.cellReuseIdentifier, for: indexPath) as! YHAIThinkingMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAIThinkingMessageCell.cellReuseIdentifier, for: indexPath) as? YHAIThinkingMessageCell else {
return UITableViewCell()
}
return cell
} else if msgType == .productList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHProductListMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHProductListMessageCell.cellReuseIdentifier, for: indexPath) as? YHProductListMessageCell else {
return UITableViewCell()
}
if let listModel = msg.body.cardsInfo {
cell.listModel = listModel
}
......@@ -305,7 +313,9 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
} else if msgType == .cardList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as! YHCardMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as? YHCardMessageCell else {
return UITableViewCell()
}
if let listModel = msg.body.cardsInfo {
cell.cardListModel = listModel
cell.evaluationResultCallback = {
......@@ -345,7 +355,9 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
return cell
} else if msgType == .picture {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAIPictureMessageCell.cellReuseIdentifier, for: indexPath) as! YHAIPictureMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAIPictureMessageCell.cellReuseIdentifier, for: indexPath) as? YHAIPictureMessageCell else {
return UITableViewCell()
}
if let imgInfo = msg.body.imageInfo {
cell.imgInfo = imgInfo
}
......
......@@ -77,9 +77,11 @@ class YHAIRequestManager: NSObject {
self.uuid = UUID().uuidString + NSDate().timeIntervalSince1970.description
// body 请求体参数
let parameters = ["botId": botId,
"conversationId": conversationId,
"question": question] as! [String: Any]
guard let parameters = ["botId": botId,
"conversationId": conversationId,
"question": question] as? [String: Any] else {
return
}
print("AI QUESTION PARAM: \(parameters)")
let headers = self.getCommonHeaders()
......@@ -147,8 +149,11 @@ class YHAIRequestManager: NSObject {
func stopChat(chatId: String, conversationId: String, callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let url = YHBaseUrlManager.shared.curURL() + YHAllApiName.AIChat.cancelAIChat
let param = ["chatId": chatId,
"conversationId": conversationId] as! [String: Any]
guard let param = ["chatId": chatId,
"conversationId": conversationId] as? [String: Any] else {
return
}
_ = YHNetRequest.postRequest(url: url, params: param) { [weak self] json, _ in
// 1. json字符串 转 对象
......
......@@ -417,12 +417,16 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
msg = messages[indexPath.row]
msgType = msg.getType()
if msgType == .text {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as! YHAITextMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAITextMessageCell.cellReuseIdentifier, for: indexPath) as? YHAITextMessageCell else {
return UITableViewCell()
}
cell.message = msg
return cell
} else if msgType == .recommendText {
let cell = tableView.dequeueReusableCell(withIdentifier: YHRecommendTextMessageCell.cellReuseIdentifier, for: indexPath) as! YHRecommendTextMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHRecommendTextMessageCell.cellReuseIdentifier, for: indexPath) as? YHRecommendTextMessageCell else {
return UITableViewCell()
}
cell.message = msg
cell.messageClick = {
[weak self] text in
......@@ -439,11 +443,15 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return cell
} else if msgType == .thinking {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAIThinkingMessageCell.cellReuseIdentifier, for: indexPath) as! YHAIThinkingMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAIThinkingMessageCell.cellReuseIdentifier, for: indexPath) as? YHAIThinkingMessageCell else {
return UITableViewCell()
}
return cell
} else if msgType == .productList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHProductListMessageCell.cellReuseIdentifier, for: indexPath) as! YHProductListMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHProductListMessageCell.cellReuseIdentifier, for: indexPath) as? YHProductListMessageCell else {
return UITableViewCell()
}
if let listModel = msg.body.cardsInfo {
cell.listModel = listModel
}
......@@ -451,7 +459,10 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
} else if msgType == .cardList {
let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as! YHCardMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHCardMessageCell.cellReuseIdentifier, for: indexPath) as? YHCardMessageCell else {
return UITableViewCell()
}
if let listModel = msg.body.cardsInfo {
cell.cardListModel = listModel
cell.evaluationResultCallback = {
......@@ -491,7 +502,9 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return cell
} else if msgType == .picture {
let cell = tableView.dequeueReusableCell(withIdentifier: YHAIPictureMessageCell.cellReuseIdentifier, for: indexPath) as! YHAIPictureMessageCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAIPictureMessageCell.cellReuseIdentifier, for: indexPath) as? YHAIPictureMessageCell else {
return UITableViewCell()
}
if let imgInfo = msg.body.imageInfo {
cell.imgInfo = imgInfo
}
......
......@@ -99,7 +99,9 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIProductCell.cellReuseIdentifier, for: indexPath) as! YHAIProductCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIProductCell.cellReuseIdentifier, for: indexPath) as? YHAIProductCell else {
return UICollectionViewCell()
}
if 0 <= indexPath.item && indexPath.item < serviceArr.count {
let model = serviceArr[indexPath.item]
......@@ -187,7 +189,9 @@ extension YHAIServiceListViewController: UICollectionViewDelegate, UICollectionV
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader {
let headerView: YHAIGreetCollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: YHAIGreetCollectionReusableView.reuseIdentifier, for: indexPath) as! YHAIGreetCollectionReusableView
guard let headerView: YHAIGreetCollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: YHAIGreetCollectionReusableView.reuseIdentifier, for: indexPath) as? YHAIGreetCollectionReusableView else {
return UICollectionReusableView()
}
headerView.updateGreetingText()
return headerView
}
......
......@@ -309,6 +309,9 @@ extension YHAITabViewController: JXSegmentedListContainerViewDataSource {
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
guard let vc = arrItemVCs[index] as? JXSegmentedListContainerViewListDelegate else {
return YHAIMainChatViewController()
}
return vc
}
}
......@@ -49,7 +49,9 @@ class YHAIChatMessage: CustomStringConvertible, NSCopying {
msg.messageId = self.messageId
msg.isSelf = self.isSelf
msg.isDone = self.isDone
msg.body = self.body.copy() as! YHAIMessageBody
if let body = self.body.copy() as? YHAIMessageBody {
msg.body = body
}
return msg
}
......
......@@ -247,7 +247,9 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier, at: index) as! YHAIChatBannerItemCell
guard let cell = pagerView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier, at: index) as? YHAIChatBannerItemCell else {
return FSPagerViewCell()
}
if index < bannerArr.count {
let model = bannerArr[index]
cell.model = model
......@@ -292,7 +294,9 @@ extension YHAIChatBannerView: UICollectionViewDelegate, UICollectionViewDataSour
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerCollectionCell.cellReuseIdentifier, for: indexPath) as! YHAIChatBannerCollectionCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerCollectionCell.cellReuseIdentifier, for: indexPath) as? YHAIChatBannerCollectionCell else {
return UICollectionViewCell()
}
if 0 <= indexPath.item && indexPath.item < messages.count {
cell.titleLabel.text = messages[indexPath.item]
}
......
......@@ -45,14 +45,18 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
let credential = authorization.credential
if credential is ASPasswordCredential {
let passwdCredential = credential as! ASPasswordCredential
guard let passwdCredential = credential as? ASPasswordCredential else {
return
}
userId = passwdCredential.user
let username = passwdCredential.user
let password = passwdCredential.password
printLog("username:\(username), passwd:\(password)")
} else if credential is ASAuthorizationAppleIDCredential {
let appleIdCredential = credential as! ASAuthorizationAppleIDCredential
guard let appleIdCredential = credential as? ASAuthorizationAppleIDCredential else {
return
}
userId = appleIdCredential.user
email = appleIdCredential.email ?? ""
fullName = appleIdCredential.fullName?.givenName ?? ""
......
......@@ -269,24 +269,32 @@ extension YHActivityDetailViewController: UITableViewDelegate, UITableViewDataSo
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell.cellReuseIdentifier, for: indexPath) as! YHActivityDetailCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell.cellReuseIdentifier, for: indexPath) as? YHActivityDetailCell else {
return UITableViewCell()
}
cell.dataModel = viewModel.activityDetailModel
if indexPath.row < viewModel.arrActivityDetail.count {
let model = viewModel.arrActivityDetail[indexPath.row]
if model.type == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell0.cellReuseIdentifier, for: indexPath) as! YHActivityDetailCell0
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell0.cellReuseIdentifier, for: indexPath) as? YHActivityDetailCell0 else {
return UITableViewCell()
}
cell.dataModel = model.activityDetailModel ?? YHActivityDetailModel()
return cell
} else if model.type == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell1.cellReuseIdentifier, for: indexPath) as! YHActivityDetailCell1
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell1.cellReuseIdentifier, for: indexPath) as? YHActivityDetailCell1 else {
return cell
}
cell.dataModel = model.activityDetailModel ?? YHActivityDetailModel()
return cell
} else if model.type == 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell2.cellReuseIdentifier, for: indexPath) as! YHActivityDetailCell2
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHActivityDetailCell2.cellReuseIdentifier, for: indexPath) as? YHActivityDetailCell2 else {
return cell
}
cell.dataModel = model.activityDetailModel ?? YHActivityDetailModel()
return cell
}
......
......@@ -265,14 +265,14 @@ extension YHApplyActivityAlert {
}
@objc func clickSubBtn() {
applyNumber = applyNumber - 1
applyNumber -= 1
applyNumberTextField.text = String(applyNumber)
handleSubAndAddButtonUI()
}
@objc func clickAddBtn() {
applyNumber = applyNumber + 1
applyNumber += 1
applyNumberTextField.text = String(applyNumber)
handleSubAndAddButtonUI()
}
......
......@@ -234,7 +234,7 @@ extension YHActivityViewModel {
self.arrActivityListData = result.data
curPageIndex = 1
} else {
curPageIndex = curPageIndex + 1
curPageIndex += 1
self.arrActivityListData.append(contentsOf: result.data)
}
......
......@@ -333,7 +333,10 @@ extension YHCommunityViewController: JXSegmentedListContainerViewDataSource {
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
guard let vc = arrItemVCs[index] as? JXSegmentedListContainerViewListDelegate else {
return YHMessageListVC()
}
return vc
}
}
......
......@@ -439,7 +439,9 @@ extension YHMatchResultListViewController: DragCardDelegate {
print("displayTopCardAt: \(index)")
if cardView is YHNameCardInfoView {
let cardInfoView = cardView as! YHNameCardInfoView
guard let cardInfoView = cardView as? YHNameCardInfoView else {
return
}
cardInfoView.backgroundColor = .white
if let secondCardView = dragCard.viewWithTag(1000+index+1) as? YHNameCardInfoView {
secondCardView.backgroundColor = self.secondCardColor
......
......@@ -241,7 +241,9 @@ extension YHMyInterestTopicCell: UICollectionViewDelegate, UICollectionViewDataS
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHTopicItemCell.cellReuseIdentifier, for: indexPath) as! YHTopicItemCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHTopicItemCell.cellReuseIdentifier, for: indexPath) as? YHTopicItemCell else {
return UICollectionViewCell()
}
if 0 <= indexPath.item && indexPath.item < topicArr.count {
cell.titleLabel.text = topicArr[indexPath.item]
}
......
......@@ -541,7 +541,10 @@ extension YHHomeHoldViewPageViewController: JXSegmentedListContainerViewDataSour
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
guard let vc = arrItemVCs[index] as? JXSegmentedListContainerViewListDelegate else {
return YHHomePageViewController()
}
return vc
}
}
......
......@@ -154,7 +154,9 @@ extension YHHomeIdentityListVC: JXSegmentedViewDelegate {
extension YHHomeIdentityListVC: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHHomeIdentityCell.cellReuseIdentifier, for: indexPath) as! YHHomeIdentityCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHHomeIdentityCell.cellReuseIdentifier, for: indexPath) as? YHHomeIdentityCell else {
return UITableViewCell()
}
if 0 <= indexPath.row, indexPath.row < self.imgItems.count {
let item = self.imgItems[indexPath.row]
cell.image = item.img
......
......@@ -27,7 +27,9 @@ class YHHomeIdentityViewController: YHBaseViewController {
if 0 <= index, index < self.children.count {
let vc = self.children[index]
if vc.isKind(of: YHHomeIdentityListVC.self) {
(vc as! YHHomeIdentityListVC).isShowBottomView = false
if let vc = vc as? YHHomeIdentityListVC {
vc.isShowBottomView = false
}
self.hideBottomOnTabbar()
}
}
......
......@@ -118,6 +118,9 @@ extension YHHomeInfoDetailContainerViewController: JXSegmentedListContainerViewD
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
guard let vc = arrItemVCs[index] as? JXSegmentedListContainerViewListDelegate else {
return YHHomeInfoDetailViewController()
}
return vc
}
}
......@@ -82,7 +82,9 @@ extension YHHomeInfoDetailViewController: UICollectionViewDelegate, UICollection
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHHomeCollectionViewCell
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as? YHHomeCollectionViewCell else {
return UICollectionViewCell()
}
cell.listModel = self.viewModel.arrHomeNewsData?[indexPath.row]
return cell
}
......
......@@ -92,7 +92,9 @@ extension YHHomeInformationViewController: UICollectionViewDelegate, UICollectio
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == CollectionViewWaterfallElementKindSectionHeader {
let headerView: YHHomeInfoSectionHeadView = collectionView.dequeueReusableSupplementaryView(ofKind: CollectionViewWaterfallElementKindSectionHeader, withReuseIdentifier: YHHomeInfoSectionHeadView.reuseIdentifier, for: indexPath) as! YHHomeInfoSectionHeadView
guard let headerView: YHHomeInfoSectionHeadView = collectionView.dequeueReusableSupplementaryView(ofKind: CollectionViewWaterfallElementKindSectionHeader, withReuseIdentifier: YHHomeInfoSectionHeadView.reuseIdentifier, for: indexPath) as? YHHomeInfoSectionHeadView else {
return UICollectionReusableView()
}
headerView.items = sectionItems
return headerView
}
......
......@@ -375,7 +375,7 @@ private extension YHHomePageViewController {
}
var r = tmpHeadView.frame
r.origin.y = r.origin.y - headViewH
r.origin.y -= headViewH
tmpHeadView.frame = r
printLog(tmpHeadView.frame)
......
......@@ -376,7 +376,10 @@ extension YHMyViewController: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHPersonalCenterCell.cellReuseIdentifier, for: indexPath) as! YHPersonalCenterCell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHPersonalCenterCell.cellReuseIdentifier, for: indexPath) as? YHPersonalCenterCell else {
return UITableViewCell()
}
let item: PersonalModuleItem = items[indexPath.row]
cell.updateItem(item: item)
return cell
......
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