Commit b45d62a9 authored by David黄金龙's avatar David黄金龙

首页 指示器

parent 3cbfa210
...@@ -288,6 +288,8 @@ ...@@ -288,6 +288,8 @@
6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; }; 6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; };
A501BE662BC2B76200C4F1FB /* YHHomeHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A501BE652BC2B76200C4F1FB /* YHHomeHeadView.swift */; }; A501BE662BC2B76200C4F1FB /* YHHomeHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A501BE652BC2B76200C4F1FB /* YHHomeHeadView.swift */; };
A501BE682BC2B85F00C4F1FB /* YHHomeSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A501BE672BC2B85F00C4F1FB /* YHHomeSearchView.swift */; }; A501BE682BC2B85F00C4F1FB /* YHHomeSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A501BE672BC2B85F00C4F1FB /* YHHomeSearchView.swift */; };
A50A747C2BC8EC86003D28D9 /* YHHomeBannerCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50A747B2BC8EC86003D28D9 /* YHHomeBannerCollectionViewCell.swift */; };
A50A747E2BC91308003D28D9 /* YHHomeBannerIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A50A747D2BC91308003D28D9 /* YHHomeBannerIndicatorView.swift */; };
A51044182B493675006B60BB /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = A51044172B493675006B60BB /* README.md */; }; A51044182B493675006B60BB /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = A51044172B493675006B60BB /* README.md */; };
A510441A2B495DD0006B60BB /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51044192B495DD0006B60BB /* UIView+Extension.swift */; }; A510441A2B495DD0006B60BB /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51044192B495DD0006B60BB /* UIView+Extension.swift */; };
A514E5DC2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */; }; A514E5DC2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */; };
...@@ -729,6 +731,8 @@ ...@@ -729,6 +731,8 @@
987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_galaxy.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_galaxy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A501BE652BC2B76200C4F1FB /* YHHomeHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeHeadView.swift; sourceTree = "<group>"; }; A501BE652BC2B76200C4F1FB /* YHHomeHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeHeadView.swift; sourceTree = "<group>"; };
A501BE672BC2B85F00C4F1FB /* YHHomeSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeSearchView.swift; sourceTree = "<group>"; }; A501BE672BC2B85F00C4F1FB /* YHHomeSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeSearchView.swift; sourceTree = "<group>"; };
A50A747B2BC8EC86003D28D9 /* YHHomeBannerCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeBannerCollectionViewCell.swift; sourceTree = "<group>"; };
A50A747D2BC91308003D28D9 /* YHHomeBannerIndicatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeBannerIndicatorView.swift; sourceTree = "<group>"; };
A51044172B493675006B60BB /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; A51044172B493675006B60BB /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
A51044192B495DD0006B60BB /* UIView+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; }; A51044192B495DD0006B60BB /* UIView+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; };
A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceCenterSecondViewController.swift; sourceTree = "<group>"; }; A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceCenterSecondViewController.swift; sourceTree = "<group>"; };
...@@ -2195,6 +2199,8 @@ ...@@ -2195,6 +2199,8 @@
A5173D6B2BC3C273007D4E74 /* YHHomeKingKongBlockView.swift */, A5173D6B2BC3C273007D4E74 /* YHHomeKingKongBlockView.swift */,
A5F9AD322BC3CD66000323F8 /* YHHkLifeAndIdItemView.swift */, A5F9AD322BC3CD66000323F8 /* YHHkLifeAndIdItemView.swift */,
A53F42BA2BC3DE6F009CAC70 /* YHHomeKingKongBlockItem.swift */, A53F42BA2BC3DE6F009CAC70 /* YHHomeKingKongBlockItem.swift */,
A50A747B2BC8EC86003D28D9 /* YHHomeBannerCollectionViewCell.swift */,
A50A747D2BC91308003D28D9 /* YHHomeBannerIndicatorView.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -2622,6 +2628,7 @@ ...@@ -2622,6 +2628,7 @@
04754A952B96FF3D00F8ADCA /* UITextField+Extension.swift in Sources */, 04754A952B96FF3D00F8ADCA /* UITextField+Extension.swift in Sources */,
A5ACE9312B4564F7002C94D2 /* YHPersonalCenterCell.swift in Sources */, A5ACE9312B4564F7002C94D2 /* YHPersonalCenterCell.swift in Sources */,
045EEE9A2B9F171A0022A143 /* YHWorkIntroductionViewModel.swift in Sources */, 045EEE9A2B9F171A0022A143 /* YHWorkIntroductionViewModel.swift in Sources */,
A50A747E2BC91308003D28D9 /* YHHomeBannerIndicatorView.swift in Sources */,
A5ACE9532B4564F7002C94D2 /* YHBaseViewController.swift in Sources */, A5ACE9532B4564F7002C94D2 /* YHBaseViewController.swift in Sources */,
045EEE9D2B9F171A0022A143 /* YHWorkItemListViewModel.swift in Sources */, 045EEE9D2B9F171A0022A143 /* YHWorkItemListViewModel.swift in Sources */,
A5ACE9392B4564F7002C94D2 /* UIDevice+Extension.swift in Sources */, A5ACE9392B4564F7002C94D2 /* UIDevice+Extension.swift in Sources */,
...@@ -2764,6 +2771,7 @@ ...@@ -2764,6 +2771,7 @@
045EEEF92B9F171A0022A143 /* YHFormItemTitleCell.swift in Sources */, 045EEEF92B9F171A0022A143 /* YHFormItemTitleCell.swift in Sources */,
A580371E2BAD784B0031C312 /* YHMySchemeViewModel.swift in Sources */, A580371E2BAD784B0031C312 /* YHMySchemeViewModel.swift in Sources */,
0425E6482BA96B4100A5E763 /* YHSchemeHeadScoreItemView.swift in Sources */, 0425E6482BA96B4100A5E763 /* YHSchemeHeadScoreItemView.swift in Sources */,
A50A747C2BC8EC86003D28D9 /* YHHomeBannerCollectionViewCell.swift in Sources */,
A501BE662BC2B76200C4F1FB /* YHHomeHeadView.swift in Sources */, A501BE662BC2B76200C4F1FB /* YHHomeHeadView.swift in Sources */,
04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */, 04A271252BAC33BB00652B1B /* YHFilePreviewTool.swift in Sources */,
044413F92BC279D200784A14 /* YHHomeWebBottomView.swift in Sources */, 044413F92BC279D200784A14 /* YHHomeWebBottomView.swift in Sources */,
......
//
// YHHomeBannerCollectionViewCell.swift
// galaxy
//
// Created by davidhuangA on 2024/4/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
class YHHomeBannerCollectionViewCell: FSPagerViewCell {
override init(frame: CGRect) {
super.init(frame: frame)
textLabel?.text = ""
textLabel?.isHidden = true
imageView?.isHidden = true
initView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var bannerImagV: UIImageView = {
let imagV : UIImageView = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.clipsToBounds = true
return imagV
}()
lazy var bannerTitleLable: UILabel = {
let lable = UILabel()
lable.font = UIFont.PFSC_R(ofSize: 16)
lable.textColor = UIColor.white
return lable
}()
lazy var effectV : UIVisualEffectView = {
let effect = UIBlurEffect(style: .light)
let effectV = UIVisualEffectView.init(effect: effect)
return effectV
}()
var dataModel : YHBannerModel? {
didSet {
updateUI()
}
}
}
private extension YHHomeBannerCollectionViewCell {
func initView() {
contentView.addSubview(bannerImagV)
bannerImagV.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
contentView.addSubview(effectV)
effectV.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.height.equalTo(77)
}
contentView.addSubview(bannerTitleLable)
bannerTitleLable.snp.makeConstraints { make in
make.right.equalTo(-20)
make.bottom.equalTo(-35)
make.left.equalTo(20)
make.height.equalTo(22)
}
}
func updateUI() {
guard let model = dataModel else { return }
if let url = URL(string: model.img_url) {
bannerImagV.kf.setImage(with: url)
}
bannerTitleLable.text = model.name
}
}
//
// YHHomeBannerIndicatorView.swift
// galaxy
//
// Created by davidhuangA on 2024/4/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHHomeBannerIndicatorView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
initView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var indicatorItems : Int = 0 {
didSet {
createUI()
}
}
var curIndicatorIndex : Int = 0 {
didSet {
updateUI()
}
}
private var arrViews : [UIView] = []
private var normalColor : UIColor = UIColor(hex: 0xffffff, alpha: 0.3)
private var selectedColor : UIColor = UIColor(hex: 0xffffff)
lazy var subHoldView: UIView = {
let view = UIView()
return view
}()
}
extension YHHomeBannerIndicatorView {
func initView() {
addSubview(subHoldView)
subHoldView.snp.makeConstraints { make in
make.centerX.centerY.equalToSuperview()
make.top.bottom.equalToSuperview()
}
}
func createUI() {
arrViews.removeAll()
subHoldView.removeSubviews()
if indicatorItems == 1 {
let view = UIView()
view.backgroundColor = normalColor
subHoldView.addSubview(view)
view.snp.makeConstraints { make in
make.left.equalToSuperview()
make.right.equalToSuperview()
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
} else {
var tagView : UIView?
for i in 0..<indicatorItems {
let view = UIView()
view.backgroundColor = normalColor
subHoldView.addSubview(view)
if i == 0 {
view.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
} else if i == indicatorItems - 1 {
view.snp.makeConstraints { make in
make.left.equalTo(tagView!.snp.right).offset(3)
make.right.equalToSuperview()
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
} else {
view.snp.makeConstraints { make in
make.left.equalTo(tagView!.snp.right).offset(3)
make.top.bottom.equalToSuperview()
make.width.equalTo(16)
}
}
tagView = view
arrViews.append(view)
}
}
}
func updateUI() {
if curIndicatorIndex < indicatorItems {
for (index,item) in arrViews.enumerated() {
if index == curIndicatorIndex {
item.backgroundColor = selectedColor
} else {
item.backgroundColor = normalColor
}
}
}
}
}
...@@ -11,10 +11,10 @@ import FSPagerView ...@@ -11,10 +11,10 @@ import FSPagerView
import Kingfisher import Kingfisher
class YHHomeBannerView: UIView { class YHHomeBannerView: UIView {
static let viewH : CGFloat = KScreenWidth - 20 * 2 static let viewH : CGFloat = KScreenWidth - 20.0 * 2
var dataArr: [YHBannerModel] = [] { var dataArr: [YHBannerModel] = [] {
didSet { didSet {
self.pageControl.numberOfPages = self.dataArr.count self.indicatorView.indicatorItems = self.dataArr.count
bannerView.reloadData() bannerView.reloadData()
} }
} }
...@@ -33,16 +33,15 @@ class YHHomeBannerView: UIView { ...@@ -33,16 +33,15 @@ class YHHomeBannerView: UIView {
view.delegate = self view.delegate = self
view.dataSource = self view.dataSource = self
view.automaticSlidingInterval = 4 view.automaticSlidingInterval = 4
view.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell") view.register(YHHomeBannerCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
view.itemSize = FSPagerView.automaticSize view.itemSize = CGSizeMake(YHHomeBannerView.viewH, YHHomeBannerView.viewH)//FSPagerView.automaticSize
return view return view
}() }()
lazy var pageControl: FSPageControl = { lazy var indicatorView : YHHomeBannerIndicatorView = {
let view = FSPageControl() let view = YHHomeBannerIndicatorView()
return view return view
}() }()
} }
private extension YHHomeBannerView { private extension YHHomeBannerView {
...@@ -55,29 +54,15 @@ private extension YHHomeBannerView { ...@@ -55,29 +54,15 @@ private extension YHHomeBannerView {
make.height.equalTo(YHHomeBannerView.viewH) make.height.equalTo(YHHomeBannerView.viewH)
} }
bannerView.addSubview(pageControl) bannerView.addSubview(indicatorView)
pageControl.snp.makeConstraints { make in indicatorView.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview() make.left.right.equalToSuperview()
make.height.equalTo(16.5) make.height.equalTo(2)
make.bottom.equalTo(-14)
} }
setupPageControl()
bannerView.reloadData() bannerView.reloadData()
} }
func setupPageControl() {
self.pageControl.numberOfPages = self.dataArr.count
self.pageControl.contentHorizontalAlignment = .center
self.pageControl.contentInsets = UIEdgeInsets(top: 0, left: 12, bottom: 10, right: 12)
let normalImage = UIImage(color: UIColor(hex: 0xff0000, alpha: 1.0), size: CGSize(width: 5, height: 5))
let selectImage = UIImage(color: .white, size: CGSize(width: 8, height: 5))
self.pageControl.setImage(normalImage, for: .normal)
self.pageControl.setImage(selectImage, for: .selected)
self.pageControl.interitemSpacing = 3
}
func goAppTab(tabBarName : String) { func goAppTab(tabBarName : String) {
if !tabBarName.isEmpty { if !tabBarName.isEmpty {
if tabBarName.contains("tabBarHome",caseSensitive: false) { if tabBarName.contains("tabBarHome",caseSensitive: false) {
...@@ -92,7 +77,6 @@ private extension YHHomeBannerView { ...@@ -92,7 +77,6 @@ private extension YHHomeBannerView {
} else if tabBarName.contains("tabBarMine",caseSensitive: false) { } else if tabBarName.contains("tabBarMine",caseSensitive: false) {
//我的 //我的
goTabBarBy(tabType: .mine) goTabBarBy(tabType: .mine)
} else { } else {
} }
...@@ -107,20 +91,10 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -107,20 +91,10 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
} }
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell { public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index) let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index) as! YHHomeBannerCollectionViewCell
let image = UIImage(named: "default_placeholder_image")
cell.imageView?.image = image
if index < dataArr.count { if index < dataArr.count {
let model = dataArr[index] cell.dataModel = dataArr[index]
if let url = URL(string: model.img_url) {
cell.imageView?.kf.setImage(with: url)
}
cell.textLabel?.text = model.name
} }
cell.imageView?.contentMode = .scaleAspectFill
cell.backgroundColor = .contentBkgColor
cell.contentView.layer.shadowColor = UIColor.clear.cgColor
return cell return cell
} }
...@@ -156,10 +130,10 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate { ...@@ -156,10 +130,10 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
} }
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) { func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.pageControl.currentPage = targetIndex self.indicatorView.curIndicatorIndex = targetIndex
} }
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) { func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.pageControl.currentPage = pagerView.currentIndex self.indicatorView.curIndicatorIndex = 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