Commit 065bee76 authored by Steven杜宇's avatar Steven杜宇

// AI

parent ace7ccb2
...@@ -679,6 +679,11 @@ ...@@ -679,6 +679,11 @@
04BE393E2CF9B67700BD31DB /* ai_chat_input_pause.json in Resources */ = {isa = PBXBuildFile; fileRef = 04BE393D2CF9B67700BD31DB /* ai_chat_input_pause.json */; }; 04BE393E2CF9B67700BD31DB /* ai_chat_input_pause.json in Resources */ = {isa = PBXBuildFile; fileRef = 04BE393D2CF9B67700BD31DB /* ai_chat_input_pause.json */; };
04BE39402CF9B95800BD31DB /* YHAIRobotChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE393F2CF9B95800BD31DB /* YHAIRobotChatViewController.swift */; }; 04BE39402CF9B95800BD31DB /* YHAIRobotChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE393F2CF9B95800BD31DB /* YHAIRobotChatViewController.swift */; };
04BE39422CF9B99200BD31DB /* YHAIChatConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39412CF9B99200BD31DB /* YHAIChatConfiguration.swift */; }; 04BE39422CF9B99200BD31DB /* YHAIChatConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39412CF9B99200BD31DB /* YHAIChatConfiguration.swift */; };
04BE39442CFAB46100BD31DB /* YHAIChatBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39432CFAB46100BD31DB /* YHAIChatBannerView.swift */; };
04BE39462CFAB5F200BD31DB /* YHAIChatBannerItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39452CFAB5F100BD31DB /* YHAIChatBannerItemCell.swift */; };
04BE39482CFABB7F00BD31DB /* YHAIChatBannerCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39472CFABB7F00BD31DB /* YHAIChatBannerCollectionCell.swift */; };
04BE394A2CFABC5E00BD31DB /* YHAIChatShadowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE39492CFABC5E00BD31DB /* YHAIChatShadowView.swift */; };
04BE394C2CFAC16600BD31DB /* YHAIChatCustomFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04BE394B2CFAC16600BD31DB /* YHAIChatCustomFlowLayout.swift */; };
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; }; 04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; };
04C693642B723B56004C1758 /* YHMySettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693632B723B56004C1758 /* YHMySettingCell.swift */; }; 04C693642B723B56004C1758 /* YHMySettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693632B723B56004C1758 /* YHMySettingCell.swift */; };
04C85DDF2C364FE9008B20D6 /* YHAboutUsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */; }; 04C85DDF2C364FE9008B20D6 /* YHAboutUsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */; };
...@@ -1740,6 +1745,11 @@ ...@@ -1740,6 +1745,11 @@
04BE393D2CF9B67700BD31DB /* ai_chat_input_pause.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ai_chat_input_pause.json; sourceTree = "<group>"; }; 04BE393D2CF9B67700BD31DB /* ai_chat_input_pause.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = ai_chat_input_pause.json; sourceTree = "<group>"; };
04BE393F2CF9B95800BD31DB /* YHAIRobotChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIRobotChatViewController.swift; sourceTree = "<group>"; }; 04BE393F2CF9B95800BD31DB /* YHAIRobotChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIRobotChatViewController.swift; sourceTree = "<group>"; };
04BE39412CF9B99200BD31DB /* YHAIChatConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatConfiguration.swift; sourceTree = "<group>"; }; 04BE39412CF9B99200BD31DB /* YHAIChatConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatConfiguration.swift; sourceTree = "<group>"; };
04BE39432CFAB46100BD31DB /* YHAIChatBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatBannerView.swift; sourceTree = "<group>"; };
04BE39452CFAB5F100BD31DB /* YHAIChatBannerItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatBannerItemCell.swift; sourceTree = "<group>"; };
04BE39472CFABB7F00BD31DB /* YHAIChatBannerCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatBannerCollectionCell.swift; sourceTree = "<group>"; };
04BE39492CFABC5E00BD31DB /* YHAIChatShadowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatShadowView.swift; sourceTree = "<group>"; };
04BE394B2CFAC16600BD31DB /* YHAIChatCustomFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIChatCustomFlowLayout.swift; sourceTree = "<group>"; };
04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.swift; sourceTree = "<group>"; }; 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.swift; sourceTree = "<group>"; };
04C693632B723B56004C1758 /* YHMySettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingCell.swift; sourceTree = "<group>"; }; 04C693632B723B56004C1758 /* YHMySettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingCell.swift; sourceTree = "<group>"; };
04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsCell.swift; sourceTree = "<group>"; }; 04C85DDE2C364FE9008B20D6 /* YHAboutUsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsCell.swift; sourceTree = "<group>"; };
...@@ -3996,6 +4006,11 @@ ...@@ -3996,6 +4006,11 @@
04BE39292CF85F8900BD31DB /* YHAITabIndicatorView.swift */, 04BE39292CF85F8900BD31DB /* YHAITabIndicatorView.swift */,
04BE392F2CF964F800BD31DB /* YHProductItemView.swift */, 04BE392F2CF964F800BD31DB /* YHProductItemView.swift */,
04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */, 04BE39352CF9AFF200BD31DB /* YHFixProductItemView.swift */,
04BE39432CFAB46100BD31DB /* YHAIChatBannerView.swift */,
04BE39452CFAB5F100BD31DB /* YHAIChatBannerItemCell.swift */,
04BE39472CFABB7F00BD31DB /* YHAIChatBannerCollectionCell.swift */,
04BE39492CFABC5E00BD31DB /* YHAIChatShadowView.swift */,
04BE394B2CFAC16600BD31DB /* YHAIChatCustomFlowLayout.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -6078,6 +6093,7 @@ ...@@ -6078,6 +6093,7 @@
044EE23C2C92BFDC00A2FE3A /* YHResignCertificateModel.swift in Sources */, 044EE23C2C92BFDC00A2FE3A /* YHResignCertificateModel.swift in Sources */,
049D62C22C6F258700E811A1 /* YHFamilyInfoConfirmViewController.swift in Sources */, 049D62C22C6F258700E811A1 /* YHFamilyInfoConfirmViewController.swift in Sources */,
0430E64C2C732821000511E2 /* YHNoAdopterAlertView.swift in Sources */, 0430E64C2C732821000511E2 /* YHNoAdopterAlertView.swift in Sources */,
04BE39482CFABB7F00BD31DB /* YHAIChatBannerCollectionCell.swift in Sources */,
04CE1ADE2C2AD91F001CB80A /* YHActivityTravelCell.swift in Sources */, 04CE1ADE2C2AD91F001CB80A /* YHActivityTravelCell.swift in Sources */,
045EEF072B9F171A0022A143 /* YHBasicInfoFillViewModel.swift in Sources */, 045EEF072B9F171A0022A143 /* YHBasicInfoFillViewModel.swift in Sources */,
045EEF212B9F171A0022A143 /* YHMainInformationTableViewCell.swift in Sources */, 045EEF212B9F171A0022A143 /* YHMainInformationTableViewCell.swift in Sources */,
...@@ -6099,6 +6115,7 @@ ...@@ -6099,6 +6115,7 @@
04FB01D02C23FA420040115D /* YHMatchUserInfo.swift in Sources */, 04FB01D02C23FA420040115D /* YHMatchUserInfo.swift in Sources */,
045EEEE92B9F171A0022A143 /* YHFamilyRequestViewModel.swift in Sources */, 045EEEE92B9F171A0022A143 /* YHFamilyRequestViewModel.swift in Sources */,
04B360E72C60CD37001EB053 /* YHPrincipleUploadFileCell.swift in Sources */, 04B360E72C60CD37001EB053 /* YHPrincipleUploadFileCell.swift in Sources */,
04BE394C2CFAC16600BD31DB /* YHAIChatCustomFlowLayout.swift in Sources */,
04F957472C203033003C631C /* YHMyGoodFriendsVC.swift in Sources */, 04F957472C203033003C631C /* YHMyGoodFriendsVC.swift in Sources */,
044867B42BA1953B00DFAD4A /* YHCertificateFilterView.swift in Sources */, 044867B42BA1953B00DFAD4A /* YHCertificateFilterView.swift in Sources */,
045EEEDF2B9F171A0022A143 /* YHCollegeSearchBar.swift in Sources */, 045EEEDF2B9F171A0022A143 /* YHCollegeSearchBar.swift in Sources */,
...@@ -6217,6 +6234,7 @@ ...@@ -6217,6 +6234,7 @@
04F243662C9D5CB200DF2C74 /* YHResignDocumentViewModel.swift in Sources */, 04F243662C9D5CB200DF2C74 /* YHResignDocumentViewModel.swift in Sources */,
A567E5B22BD7643D00D5D5A0 /* YHHomeBannerCollectionViewCell.swift in Sources */, A567E5B22BD7643D00D5D5A0 /* YHHomeBannerCollectionViewCell.swift in Sources */,
0430E68A2C77415D000511E2 /* YHAdopterAddModel.swift in Sources */, 0430E68A2C77415D000511E2 /* YHAdopterAddModel.swift in Sources */,
04BE39442CFAB46100BD31DB /* YHAIChatBannerView.swift in Sources */,
045EEF082B9F171A0022A143 /* YHBasicInfoCellModel.swift in Sources */, 045EEF082B9F171A0022A143 /* YHBasicInfoCellModel.swift in Sources */,
045F284A2CF6F5B100520F19 /* YHAIViewModel.swift in Sources */, 045F284A2CF6F5B100520F19 /* YHAIViewModel.swift in Sources */,
A59B43C92C491FB100B28379 /* YHH5WebViewVC.swift in Sources */, A59B43C92C491FB100B28379 /* YHH5WebViewVC.swift in Sources */,
...@@ -6277,6 +6295,7 @@ ...@@ -6277,6 +6295,7 @@
0430E65A2C7436CD000511E2 /* YHAdopterNewPeopleViewModel.swift in Sources */, 0430E65A2C7436CD000511E2 /* YHAdopterNewPeopleViewModel.swift in Sources */,
04256E1D2C75C74200A37BA4 /* YHAppointHKResultModel.swift in Sources */, 04256E1D2C75C74200A37BA4 /* YHAppointHKResultModel.swift in Sources */,
04564D592CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift in Sources */, 04564D592CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift in Sources */,
04BE394A2CFABC5E00BD31DB /* YHAIChatShadowView.swift in Sources */,
047F3DE62CE83A0F001B2A6D /* YHHKRequiredItemView.swift in Sources */, 047F3DE62CE83A0F001B2A6D /* YHHKRequiredItemView.swift in Sources */,
04CE1ADB2C2AD91F001CB80A /* YHActivityTitleItemView.swift in Sources */, 04CE1ADB2C2AD91F001CB80A /* YHActivityTitleItemView.swift in Sources */,
042B20E32CEC92C400655093 /* YHMajorNameCell.swift in Sources */, 042B20E32CEC92C400655093 /* YHMajorNameCell.swift in Sources */,
...@@ -6738,6 +6757,7 @@ ...@@ -6738,6 +6757,7 @@
045EEF1F2B9F171A0022A143 /* YHDatePickView.swift in Sources */, 045EEF1F2B9F171A0022A143 /* YHDatePickView.swift in Sources */,
04B401E42CE76B10005C61A9 /* YHIncomeInputMoneyCell.swift in Sources */, 04B401E42CE76B10005C61A9 /* YHIncomeInputMoneyCell.swift in Sources */,
04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */, 04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */,
04BE39462CFAB5F200BD31DB /* YHAIChatBannerItemCell.swift in Sources */,
04BE39362CF9AFF200BD31DB /* YHFixProductItemView.swift in Sources */, 04BE39362CF9AFF200BD31DB /* YHFixProductItemView.swift in Sources */,
04912F942CB921C300CC3105 /* YHResignAppointContainerViewController.swift in Sources */, 04912F942CB921C300CC3105 /* YHResignAppointContainerViewController.swift in Sources */,
045EEE972B9F171A0022A143 /* YHPreviewInfoWorkExpView.swift in Sources */, 045EEE972B9F171A0022A143 /* YHPreviewInfoWorkExpView.swift in Sources */,
......
...@@ -132,9 +132,12 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -132,9 +132,12 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
return UITableView.automaticDimension return UITableView.automaticDimension
} }
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { let view = YHAIChatBannerView()
return 1.0 let arr:[YHBannerModel] = [YHBannerModel(), YHBannerModel(), YHBannerModel()]
view.dataArr = arr
view.historyItems = ["阿萨法吉林师范", "阿萨法", "啊设计立卡", "啊积", "阿基德拉屎就发了", "asfasf", "阿萨法", "啊设计立卡", "啊积", "阿基德拉屎就发了"]
return view
} }
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
...@@ -143,7 +146,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc ...@@ -143,7 +146,7 @@ extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSourc
} }
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 1.0 return 360.0
} }
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import JXSegmentedView import JXSegmentedView
import IQKeyboardManagerSwift
class YHAIServiceListViewController: YHBaseViewController { class YHAIServiceListViewController: YHBaseViewController {
...@@ -83,6 +84,8 @@ class YHAIServiceListViewController: YHBaseViewController { ...@@ -83,6 +84,8 @@ class YHAIServiceListViewController: YHBaseViewController {
super.viewDidLoad() super.viewDidLoad()
gk_navBarAlpha = 0 gk_navBarAlpha = 0
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
IQKeyboardManager.shared.enable = false
view.backgroundColor = .clear view.backgroundColor = .clear
view.addSubview(collectionView) view.addSubview(collectionView)
view.addSubview(bottomInputView) view.addSubview(bottomInputView)
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import JXSegmentedView import JXSegmentedView
import IQKeyboardManagerSwift
class YHAITabViewController: YHBaseViewController { class YHAITabViewController: YHBaseViewController {
...@@ -54,6 +55,7 @@ class YHAITabViewController: YHBaseViewController { ...@@ -54,6 +55,7 @@ class YHAITabViewController: YHBaseViewController {
//分类title 所对应的VC //分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = { lazy var listContainerView: JXSegmentedListContainerView! = {
let view = JXSegmentedListContainerView(dataSource: self, type: .scrollView) let view = JXSegmentedListContainerView(dataSource: self, type: .scrollView)
view.scrollView.isScrollEnabled = false
view.backgroundColor = .clear view.backgroundColor = .clear
return view return view
}() }()
...@@ -100,6 +102,8 @@ class YHAITabViewController: YHBaseViewController { ...@@ -100,6 +102,8 @@ class YHAITabViewController: YHBaseViewController {
func createUI() { func createUI() {
IQKeyboardManager.shared.enable = false
NotificationCenter.default.addObserver(self, selector: #selector(didJumoToAIChat), name: YhConstant.YhNotification.didSwitchToAIChatNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(didJumoToAIChat), name: YhConstant.YhNotification.didSwitchToAIChatNotification, object: nil)
view.addSubview(bgImgView) view.addSubview(bgImgView)
......
//
// YHAIChatBannerCollectionCell.swift
// galaxy
//
// Created by Dufet on 2024/11/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAIChatBannerCollectionCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHAIChatBannerCollectionCell"
lazy var titleLabel: UILabel = {
var label = UILabel()
label.font = .PFSC_R(ofSize: 12)
label.textAlignment = .left
label.textColor = UIColor.mainTextColor
return label
}()
lazy var shadowView: YHAIChatShadowView = {
let v = YHAIChatShadowView()
return v
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
contentView.backgroundColor = .white
contentView.layer.cornerRadius = 6.0
contentView.addSubview(shadowView)
contentView.addSubview(titleLabel)
shadowView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
titleLabel.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.left.equalToSuperview().offset(10.0)
make.right.equalToSuperview().offset(-10.0)
}
}
}
//
// YHAIChatBannerItemCell.swift
// galaxy
//
// Created by Dufet on 2024/11/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
import VisualEffectView
class YHAIChatBannerItemCell: FSPagerViewCell {
static let cellReuseIdentifier = "YHAIChatBannerItemCell"
lazy var effectView:VisualEffectView = {
let visualEffectView = VisualEffectView()
visualEffectView.colorTint = UIColor(hex: 0xAFAFAF).withAlphaComponent(0.15)
visualEffectView.blurRadius = 16
visualEffectView.scale = 1
return visualEffectView
}()
lazy var bannerImagV: UIImageView = {
let imagV : UIImageView = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.clipsToBounds = true
imagV.image = UIImage(named: "global_default_image")
return imagV
}()
lazy var titleLabel: UILabel = {
let lable = UILabel()
lable.font = UIFont.PFSC_B(ofSize: 14)
lable.textColor = UIColor.brandMainColor
lable.text = "银河明星产品"
return lable
}()
lazy var subtitleLabel: UILabel = {
let lable = UILabel()
lable.font = UIFont.PFSC_R(ofSize: 13)
lable.textColor = UIColor.mainTextColor
lable.text = "这里是副标题"
return lable
}()
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func initView() {
contentView.layer.shadowColor = UIColor.clear.cgColor
contentView.layer.shadowRadius = 0
contentView.layer.shadowOpacity = 0
contentView.layer.shadowOffset = .zero
contentView.addSubview(bannerImagV)
bannerImagV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
contentView.addSubview(effectView)
effectView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(95)
}
contentView.addSubview(subtitleLabel)
subtitleLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(20)
make.bottom.equalTo(-35)
}
contentView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(24)
make.bottom.equalTo(subtitleLabel.snp.top)
}
}
}
//
// YHAIChatBannerView.swift
// galaxy
//
// Created by Dufet on 2024/11/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
class YHAIChatBannerView: UIView {
static let bannerHeight = 242.0
let cellHeight: CGFloat = 33.0 // 单元格的固定高度
var historyItems:[String] = [] {
didSet {
layout.dataSource = historyItems
collectionView.reloadData()
}
}
var dataArr: [YHBannerModel] = [] {
didSet {
// 设置为0是先停掉自动滑动定时器
bannerView.automaticSlidingInterval = 0
self.indicatorView.indicatorItems = self.dataArr.count
bannerView.reloadData()
// 指定指示器为第一个
self.indicatorView.curIndicatorIndex = 0
// 指定显示图片为第一个
bannerView.selectItem(at: 0, animated: false)
// 开启定时器开始滚动
bannerView.automaticSlidingInterval = bannerSildingInterval
bannerView.removesInfiniteLoopForSingleItem = true
bannerView.alwaysBounceHorizontal = true
}
}
private lazy var bannerView: FSPagerView = {
let view = FSPagerView()
view.delegate = self
view.dataSource = self
view.bounces = false
view.isInfinite = true
view.automaticSlidingInterval = bannerSildingInterval
view.register(YHAIChatBannerItemCell.self, forCellWithReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier)
view.itemSize = CGSizeMake(KScreenWidth-40.0, YHAIChatBannerView.bannerHeight)//FSPagerView.automaticSize
return view
}()
lazy var indicatorView : YHHomeBannerIndicatorView = {
let view = YHHomeBannerIndicatorView()
return view
}()
lazy var layout: YHAIChatCustomFlowLayout = {
let layout = YHAIChatCustomFlowLayout()
layout.scrollDirection = .horizontal
layout.dataSource = []
return layout
}()
lazy var collectionView: UICollectionView = {
let collectView = UICollectionView(frame:.zero, collectionViewLayout: layout)
collectView.delegate = self
collectView.dataSource = self
collectView.backgroundColor = .clear
collectView.showsHorizontalScrollIndicator = false
collectView.showsVerticalScrollIndicator = false
// 注册自定义单元格
collectView.register(YHAIChatBannerCollectionCell.self, forCellWithReuseIdentifier: YHAIChatBannerCollectionCell.cellReuseIdentifier)
return collectView
}()
override init(frame: CGRect) {
super.init(frame: frame)
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func createUI() {
addSubview(bannerView)
bannerView.snp.makeConstraints { make in
make.top.equalTo(10)
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(YHAIChatBannerView.bannerHeight)
}
bannerView.addSubview(indicatorView)
indicatorView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(2)
make.bottom.equalTo(-14)
}
bannerView.reloadData()
addSubview(collectionView)
collectionView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(33.0*2+10.0 + 10.0*2.0)
make.top.equalTo(bannerView.snp.bottom).offset(6)
make.bottom.equalTo(-6)
}
}
// 计算文字宽度大小
func getwith(font: UIFont, height: CGFloat, string: String) -> CGSize {
let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height)
let dic = [NSAttributedString.Key.font: font] // swift 4.2
let strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(ceil(strSize.width), strSize.height)
}
}
extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.dataArr.count
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerItemCell.cellReuseIdentifier, at: index) as! YHAIChatBannerItemCell
if index < dataArr.count {
}
return cell
}
// MARK: - FSPagerView Delegate
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
pagerView.scrollToItem(at: index, animated: true)
if index >= dataArr.count {
return
}
}
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.indicatorView.curIndicatorIndex = targetIndex
}
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.indicatorView.curIndicatorIndex = pagerView.currentIndex
}
}
extension YHAIChatBannerView: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
// 返回单元格数量
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return historyItems.count
}
// 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return layout.getSize(index: indexPath.item)
}
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAIChatBannerCollectionCell.cellReuseIdentifier, for: indexPath) as! YHAIChatBannerCollectionCell
if 0 <= indexPath.item && indexPath.item < historyItems.count {
cell.titleLabel.text = historyItems[indexPath.item]
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < historyItems.count {
let text = historyItems[indexPath.item]
}
}
}
//
// YHAIChatCustomFlowLayout.swift
// galaxy
//
// Created by Dufet on 2024/11/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAIChatCustomFlowLayout: UICollectionViewFlowLayout {
let cellHeight = 33.0
let verticalGap = 10.0
let horizonalGap = 10.0
var firstLineX: CGFloat = 0.0
var secondLineX: CGFloat = 0.0
var attributes: [UICollectionViewLayoutAttributes] = []
var dataSource:[String] = [] {
didSet {
attributes.removeAll()
firstLineX = 0.0
secondLineX = 0.0
for (index, text) in dataSource.enumerated() {
let attribute = UICollectionViewLayoutAttributes(forCellWith: IndexPath(row: index, section: 0))
if index % 2 == 0 { // 第一行的数据
let size = self.getSize(index: index)
attribute.frame = CGRectMake(firstLineX, verticalGap, size.width, size.height)
firstLineX = firstLineX + attribute.frame.width + horizonalGap
} else { // 第二行的数据
let size = self.getSize(index: index)
attribute.frame = CGRectMake(secondLineX, verticalGap+cellHeight+verticalGap, size.width, size.height)
secondLineX = secondLineX + attribute.frame.width + horizonalGap
}
attributes.append(attribute)
}
collectionView?.reloadData()
}
}
override func prepare() {
super.prepare()
}
override func invalidateLayout() {
super.invalidateLayout()
}
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
if 0 <= indexPath.item, indexPath.item < attributes.count {
return attributes[indexPath.item]
}
return nil
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
return attributes
}
override var collectionViewContentSize: CGSize {
guard let _ = collectionView else { return .zero }
let width = max(firstLineX, secondLineX)
let size = CGSize(width: width, height: cellHeight*2.0 + verticalGap)
print("XXXX:\(size)")
return size
}
func getSize(index:Int) -> CGSize {
if 0 <= index, index < dataSource.count {
let size = self.getwith(font: UIFont.PFSC_R(ofSize: 12), height: cellHeight, string: dataSource[index])
let gap = 10.0
let width = size.width + gap*2.0
return CGSize(width: width, height: cellHeight)
}
return .zero
}
// 计算文字宽度大小
func getwith(font: UIFont, height: CGFloat, string: String) -> CGSize {
let size = CGSize.init(width: CGFloat(MAXFLOAT), height: height)
let dic = [NSAttributedString.Key.font: font] // swift 4.2
let strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(ceil(strSize.width), strSize.height)
}
}
//
// YHAIChatShadowView.swift
// galaxy
//
// Created by Dufet on 2024/11/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAIChatShadowView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setupShadow()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupShadow()
}
private func setupShadow() {
// 创建阴影路径
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 6)
// 设置阴影属性
layer.shadowPath = shadowPath.cgPath
layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.06).cgColor
layer.shadowOpacity = 1
layer.shadowRadius = 20
layer.shadowOffset = CGSize(width: 0, height: 4)
}
override func layoutSubviews() {
super.layoutSubviews()
// 确保在布局更新时更新阴影路径
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 6)
layer.shadowPath = shadowPath.cgPath
}
}
...@@ -17,8 +17,9 @@ class YHProductItemView: UIView { ...@@ -17,8 +17,9 @@ class YHProductItemView: UIView {
titleLabel.text = productModel.title titleLabel.text = productModel.title
let aa: ASAttributedString = .init("¥", .font(UIFont(name: "DINAlternate-Bold", size: 14)!),.foreground(UIColor.mainTextColor)) let aa: ASAttributedString = .init("¥", .font(UIFont(name: "DINAlternate-Bold", size: 14)!),.foreground(UIColor.mainTextColor))
let bb: ASAttributedString = .init("\(productModel.discount_price)", .font(UIFont(name: "DINAlternate-Bold", size: 20)!),.foreground(UIColor.mainTextColor)) let bb: ASAttributedString = .init("\(productModel.discount_price)", .font(UIFont(name: "DINAlternate-Bold", size: 20)!),.foreground(UIColor.mainTextColor))
let cc: ASAttributedString = .init("¥\(productModel.original_price)", .font(UIFont(name: "DINAlternate-Bold", size: 14)!),.foreground(UIColor.init(hex: 0xB9C1CC)), .strikethrough(.single)) let cc: ASAttributedString = .init(" ", .font(UIFont(name: "DINAlternate-Bold", size: 14)!),.foreground(UIColor.init(hex: 0xB9C1CC)))
priceLabel.attributed.text = aa+bb+cc let dd: ASAttributedString = .init("¥\(productModel.original_price)", .font(UIFont(name: "DINAlternate-Bold", size: 14)!),.foreground(UIColor.init(hex: 0xB9C1CC)), .strikethrough(.single))
priceLabel.attributed.text = aa+bb+cc+dd
tagContentView.removeSubviews() tagContentView.removeSubviews()
var lastTagView:YHProductTagView? = nil var lastTagView:YHProductTagView? = nil
......
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