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

// AI

parent c4557570
...@@ -566,6 +566,7 @@ ...@@ -566,6 +566,7 @@
048058352C7DC7AC00502CAA /* YHMyTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058342C7DC7AC00502CAA /* YHMyTestViewController.swift */; }; 048058352C7DC7AC00502CAA /* YHMyTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058342C7DC7AC00502CAA /* YHMyTestViewController.swift */; };
048058372C7F03B500502CAA /* YHTravelCertificateUploadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058362C7F03B500502CAA /* YHTravelCertificateUploadCell.swift */; }; 048058372C7F03B500502CAA /* YHTravelCertificateUploadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058362C7F03B500502CAA /* YHTravelCertificateUploadCell.swift */; };
048058392C7F289700502CAA /* YHTravelCertificateItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058382C7F289700502CAA /* YHTravelCertificateItemView.swift */; }; 048058392C7F289700502CAA /* YHTravelCertificateItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048058382C7F289700502CAA /* YHTravelCertificateItemView.swift */; };
048063612D0BE9CF0021A44F /* YHPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048063602D0BE9CF0021A44F /* YHPageControl.swift */; };
0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */; }; 0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */; };
0480976D2BA158A1000B9DCA /* YHCertificateListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */; }; 0480976D2BA158A1000B9DCA /* YHCertificateListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */; };
048097712BA18D66000B9DCA /* YHCertificateSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */; }; 048097712BA18D66000B9DCA /* YHCertificateSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */; };
...@@ -1687,6 +1688,7 @@ ...@@ -1687,6 +1688,7 @@
048058342C7DC7AC00502CAA /* YHMyTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyTestViewController.swift; sourceTree = "<group>"; }; 048058342C7DC7AC00502CAA /* YHMyTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyTestViewController.swift; sourceTree = "<group>"; };
048058362C7F03B500502CAA /* YHTravelCertificateUploadCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTravelCertificateUploadCell.swift; sourceTree = "<group>"; }; 048058362C7F03B500502CAA /* YHTravelCertificateUploadCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTravelCertificateUploadCell.swift; sourceTree = "<group>"; };
048058382C7F289700502CAA /* YHTravelCertificateItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTravelCertificateItemView.swift; sourceTree = "<group>"; }; 048058382C7F289700502CAA /* YHTravelCertificateItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTravelCertificateItemView.swift; sourceTree = "<group>"; };
048063602D0BE9CF0021A44F /* YHPageControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPageControl.swift; sourceTree = "<group>"; };
0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateInfoCell.swift; sourceTree = "<group>"; }; 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateInfoCell.swift; sourceTree = "<group>"; };
0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateListVC.swift; sourceTree = "<group>"; }; 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateListVC.swift; sourceTree = "<group>"; };
048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchBar.swift; sourceTree = "<group>"; }; 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchBar.swift; sourceTree = "<group>"; };
...@@ -5639,6 +5641,7 @@ ...@@ -5639,6 +5641,7 @@
04F2432E2C94704200DF2C74 /* YHPaddedLabel.swift */, 04F2432E2C94704200DF2C74 /* YHPaddedLabel.swift */,
04395F892CEDB26500D3005C /* YHAutoTextView.swift */, 04395F892CEDB26500D3005C /* YHAutoTextView.swift */,
045F283F2CF5ED3400520F19 /* YHAITabBarItemContentView.swift */, 045F283F2CF5ED3400520F19 /* YHAITabBarItemContentView.swift */,
048063602D0BE9CF0021A44F /* YHPageControl.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -6204,6 +6207,7 @@ ...@@ -6204,6 +6207,7 @@
045EEEC72B9F171A0022A143 /* YHOtherYesOrNoItemView.swift in Sources */, 045EEEC72B9F171A0022A143 /* YHOtherYesOrNoItemView.swift in Sources */,
A5FF0F3E2C32F2590069852B /* YHActivityDetailCell2.swift in Sources */, A5FF0F3E2C32F2590069852B /* YHActivityDetailCell2.swift in Sources */,
04256DD42C70538400A37BA4 /* YHFamilyInfoUpdateViewController.swift in Sources */, 04256DD42C70538400A37BA4 /* YHFamilyInfoUpdateViewController.swift in Sources */,
048063612D0BE9CF0021A44F /* YHPageControl.swift in Sources */,
04F243682C9D670E00DF2C74 /* YHResignDocumentListModel.swift in Sources */, 04F243682C9D670E00DF2C74 /* YHResignDocumentListModel.swift in Sources */,
04FD85702C21646200BEF9C5 /* YHMyInterestTopicCell.swift in Sources */, 04FD85702C21646200BEF9C5 /* YHMyInterestTopicCell.swift in Sources */,
04F243742CA07C6C00DF2C74 /* YHCollectionViewLeftAlignedFlowLayout.swift in Sources */, 04F243742CA07C6C00DF2C74 /* YHCollectionViewLeftAlignedFlowLayout.swift in Sources */,
......
//
// YHPageControl.swift
// galaxy
//
// Created by Dufet on 2024/12/13.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHPageControl: UIView {
// MARK: - Properties
private var dots: [UIView] = []
var dotSize: CGSize = CGSize(width: 40, height: 8) // 普通点的大小
var selectedDotSize: CGSize = CGSize(width: 60, height: 8) // 选中点的大小
var spacing: CGFloat = 8 // 点之间的间距
// 当前页码
var currentPage: Int = 0 {
didSet {
guard oldValue != currentPage else { return }
updateDots(animated: true)
}
}
// 总页数
var numberOfPages: Int = 0 {
didSet {
guard oldValue != numberOfPages else { return }
setupDots()
}
}
// 自定义颜色
var dotColor: UIColor = UIColor.lightGray {
didSet {
dots.forEach { $0.backgroundColor = dotColor }
dots[safe: currentPage]?.backgroundColor = selectedDotColor
}
}
var selectedDotColor: UIColor = UIColor.systemBlue {
didSet {
dots[safe: currentPage]?.backgroundColor = selectedDotColor
}
}
// MARK: - Initialization
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
// MARK: - Setup
private func setupView() {
backgroundColor = .clear
}
private func setupDots() {
// 移除现有的点
dots.forEach { $0.removeFromSuperview() }
dots.removeAll()
// 创建新的点
for _ in 0..<numberOfPages {
let dot = UIView()
dot.backgroundColor = dotColor
dot.layer.shadowOffset = .zero
addSubview(dot)
dots.append(dot)
}
// 更新布局
setNeedsLayout()
updateDots(animated: false)
}
// MARK: - Layout
override func layoutSubviews() {
super.layoutSubviews()
let totalWidth = CGFloat(numberOfPages - 1) * (dotSize.width + spacing) + selectedDotSize.width
var xOffset = (bounds.width - totalWidth) / 2
for (index, dot) in dots.enumerated() {
let isSelected = index == currentPage
let width = isSelected ? selectedDotSize.width : dotSize.width
dot.frame = CGRect(x: xOffset,
y: (bounds.height - dotSize.height) / 2,
width: width,
height: dotSize.height)
dot.layer.cornerRadius = self.dotSize.height / 2
dot.clipsToBounds = true
xOffset += width + spacing
}
}
// MARK: - Updates
private func updateDots(animated: Bool) {
guard !dots.isEmpty else { return }
let update = {
self.dots.enumerated().forEach { index, dot in
let isSelected = index == self.currentPage
dot.backgroundColor = isSelected ? self.selectedDotColor : self.dotColor
let width = isSelected ? self.selectedDotSize.width : self.dotSize.width
var frame = dot.frame
frame.size.width = width
dot.layer.cornerRadius = self.dotSize.height / 2
dot.clipsToBounds = true
dot.frame = frame
}
self.layoutSubviews()
}
if animated {
UIView.animate(withDuration: 0.3,
delay: 0,
usingSpringWithDamping: 0.7,
initialSpringVelocity: 0.5,
options: [.curveEaseInOut],
animations: update)
} else {
update()
}
}
}
// MARK: - Safe Array Access
private extension Array {
subscript(safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import FSPagerView import FSPagerView
import JXPageControl
class YHAIChatBannerItem { class YHAIChatBannerItem {
var id: Int = 0 var id: Int = 0
...@@ -47,7 +48,7 @@ class YHAIChatBannerView: UIView { ...@@ -47,7 +48,7 @@ class YHAIChatBannerView: UIView {
descLabel.text = config.desc descLabel.text = config.desc
bgCardView.backgroundColor = config.bgColor bgCardView.backgroundColor = config.bgColor
bgImgV.image = UIImage(named: config.bgImageName) bgImgV.image = UIImage(named: config.bgImageName)
indicatorView.selectedColor = config.indicatorColor indicatorView.selectedDotColor = config.indicatorColor
bannerArr = config.bannerItems bannerArr = config.bannerItems
messages = config.flowMessages messages = config.flowMessages
} }
...@@ -96,10 +97,10 @@ class YHAIChatBannerView: UIView { ...@@ -96,10 +97,10 @@ class YHAIChatBannerView: UIView {
didSet { didSet {
// 设置为0是先停掉自动滑动定时器 // 设置为0是先停掉自动滑动定时器
bannerView.automaticSlidingInterval = 0 bannerView.automaticSlidingInterval = 0
self.indicatorView.indicatorItems = self.bannerArr.count self.indicatorView.numberOfPages = self.bannerArr.count
bannerView.reloadData() bannerView.reloadData()
// 指定指示器为第一个 // 指定指示器为第一个
self.indicatorView.curIndicatorIndex = 0 self.indicatorView.currentPage = 0
// 指定显示图片为第一个 // 指定显示图片为第一个
bannerView.selectItem(at: 0, animated: false) bannerView.selectItem(at: 0, animated: false)
// 开启定时器开始滚动 // 开启定时器开始滚动
...@@ -121,13 +122,17 @@ class YHAIChatBannerView: UIView { ...@@ -121,13 +122,17 @@ class YHAIChatBannerView: UIView {
return view return view
}() }()
lazy var indicatorView : YHHomeBannerIndicatorView = { lazy var indicatorView: YHPageControl = {
let view = YHHomeBannerIndicatorView() let pageControl = YHPageControl(frame: .zero)
view.normalColor = .init(hex: 0xD5DAE1) let dotHeight = 3.0
view.selectedColor = .brandMainColor pageControl.spacing = 2.0
view.layer.cornerRadius = 1.0 pageControl.dotSize = CGSizeMake(5, dotHeight)
view.clipsToBounds = true pageControl.selectedDotSize = CGSizeMake(12, dotHeight)
return view pageControl.numberOfPages = 0
pageControl.currentPage = 0
pageControl.dotColor = .init(hex: 0xD5DAE1)
pageControl.selectedDotColor = .brandMainColor
return pageControl
}() }()
lazy var layout: YHAIChatCustomFlowLayout = { lazy var layout: YHAIChatCustomFlowLayout = {
...@@ -212,7 +217,7 @@ class YHAIChatBannerView: UIView { ...@@ -212,7 +217,7 @@ class YHAIChatBannerView: UIView {
indicatorView.snp.makeConstraints { make in indicatorView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.height.equalTo(2) make.height.equalTo(3)
make.bottom.equalTo(-16) make.bottom.equalTo(-16)
} }
bannerView.reloadData() bannerView.reloadData()
...@@ -263,11 +268,11 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -263,11 +268,11 @@ extension YHAIChatBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
} }
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) { func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.indicatorView.curIndicatorIndex = targetIndex self.indicatorView.currentPage = targetIndex
} }
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) { func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.indicatorView.curIndicatorIndex = pagerView.currentIndex self.indicatorView.currentPage = pagerView.currentIndex
} }
} }
......
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