Commit 6bee5c52 authored by David黄金龙's avatar David黄金龙

首页 添加测试代码

parent a7042762
......@@ -84,6 +84,8 @@
A5C5B2F92B5515CE00A7C5D1 /* YHPageContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B2F82B5515CE00A7C5D1 /* YHPageContentView.swift */; };
A5C5B2FB2B5535DF00A7C5D1 /* YHHomeBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B2FA2B5535DF00A7C5D1 /* YHHomeBannerView.swift */; };
A5C5B2FD2B55361700A7C5D1 /* YHBannerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B2FC2B55361700A7C5D1 /* YHBannerModel.swift */; };
A5C5B3002B55623800A7C5D1 /* ContentBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B2FE2B55623700A7C5D1 /* ContentBaseViewController.swift */; };
A5C5B3012B55623800A7C5D1 /* ListBaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B2FF2B55623800A7C5D1 /* ListBaseViewController.swift */; };
A5D6AB1B2B46A1CC001C10A5 /* YHHomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D6AB1A2B46A1CC001C10A5 /* YHHomeModel.swift */; };
A5D6AB1D2B46AAFB001C10A5 /* YHHomePageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */; };
/* End PBXBuildFile section */
......@@ -202,6 +204,8 @@
A5C5B2F82B5515CE00A7C5D1 /* YHPageContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHPageContentView.swift; sourceTree = "<group>"; };
A5C5B2FA2B5535DF00A7C5D1 /* YHHomeBannerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHHomeBannerView.swift; sourceTree = "<group>"; };
A5C5B2FC2B55361700A7C5D1 /* YHBannerModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHBannerModel.swift; sourceTree = "<group>"; };
A5C5B2FE2B55623700A7C5D1 /* ContentBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentBaseViewController.swift; sourceTree = "<group>"; };
A5C5B2FF2B55623800A7C5D1 /* ListBaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListBaseViewController.swift; sourceTree = "<group>"; };
A5D6AB1A2B46A1CC001C10A5 /* YHHomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeModel.swift; sourceTree = "<group>"; };
A5D6AB1C2B46AAFB001C10A5 /* YHHomePageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomePageViewModel.swift; sourceTree = "<group>"; };
B6BB01E4C5DB87B66F0ECE84 /* Pods-galaxy.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.release.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.release.xcconfig"; sourceTree = "<group>"; };
......@@ -615,6 +619,8 @@
A5ACE95C2B457133002C94D2 /* C */ = {
isa = PBXGroup;
children = (
A5C5B2FE2B55623700A7C5D1 /* ContentBaseViewController.swift */,
A5C5B2FF2B55623800A7C5D1 /* ListBaseViewController.swift */,
A5ACE95D2B4571BF002C94D2 /* YHHomeViewController.swift */,
A5C5B2E52B4EC0BF00A7C5D1 /* YHDavidTestViewController.swift */,
);
......@@ -815,8 +821,10 @@
A5ACE92C2B4564F7002C94D2 /* YHLoginStyleButton.swift in Sources */,
A5ACE92F2B4564F7002C94D2 /* YHMyViewController.swift in Sources */,
A5C5B2E62B4EC0BF00A7C5D1 /* YHDavidTestViewController.swift in Sources */,
A5C5B3012B55623800A7C5D1 /* ListBaseViewController.swift in Sources */,
A5ACE9332B4564F7002C94D2 /* NetBaseModel.swift in Sources */,
049A48AA2B49536000D0C641 /* YHAboutUsAdvantageCell.swift in Sources */,
A5C5B3002B55623800A7C5D1 /* ContentBaseViewController.swift in Sources */,
A5573ED22B317BFF00D98EC0 /* AppDelegate.swift in Sources */,
A5ACE9542B4564F7002C94D2 /* YHNavigationController.swift in Sources */,
A5ACE95E2B4571BF002C94D2 /* YHHomeViewController.swift in Sources */,
......
//
// ContentBaseViewController.swift
// JXSegmentedView
//
// Created by jiaxin on 2018/12/26.
// Copyright © 2018 jiaxin. All rights reserved.
//
import UIKit
import JXSegmentedView
class ContentBaseViewController: UIViewController {
let arrItemTitles = ["推荐","子女教育","税务规划","民生医疗","成功案例","我的服务","行业资讯","香港生活","你我他","我是很长的tag呀"]
var segmentedView : JXSegmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 40))
lazy var segmentedDataSource: JXSegmentedBaseDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.isTitleColorGradientEnabled = true
dataSource.titles = arrItemTitles
dataSource.titleNormalFont = UIFont.PFSCM(ofSize: 16)
dataSource.titleNormalColor = .commonColor25
dataSource.titleSelectedFont = UIFont.PFSCM(ofSize: 18)
dataSource.titleSelectedColor = .commonColor100
dataSource.isItemSpacingAverageEnabled = false
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 24
return dataSource
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self)
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
view.addSubview(segmentedView)
segmentedView.listContainer = listContainerView
view.addSubview(listContainerView)
for indicaotr in segmentedView.indicators {
if (indicaotr as? JXSegmentedIndicatorLineView) != nil ||
(indicaotr as? JXSegmentedIndicatorDotLineView) != nil ||
(indicaotr as? JXSegmentedIndicatorDoubleLineView) != nil ||
(indicaotr as? JXSegmentedIndicatorRainbowLineView) != nil ||
(indicaotr as? JXSegmentedIndicatorImageView) != nil ||
(indicaotr as? JXSegmentedIndicatorTriangleView) != nil {
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "指示器位置切换", style: UIBarButtonItem.Style.plain, target: self, action: #selector(didIndicatorPositionChanged))
break
}
}
if (segmentedDataSource as? JXSegmentedTitleImageDataSource) != nil {
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "设置", style: UIBarButtonItem.Style.plain, target: self, action: #selector(didSetingsButtonClicked))
}
if let _ = segmentedDataSource as? JXSegmentedNumberDataSource {
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "刷新", style: UIBarButtonItem.Style.plain, target: self, action: #selector(hanldeNumberRefresh))
}
//分类Title
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = .blue
segmentedView.indicators = [indicator]
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//处于第一个item的时候,才允许屏幕边缘手势返回
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//离开页面的时候,需要恢复屏幕边缘手势,不能影响其他页面
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
segmentedView.frame = CGRect(x: 0, y: 0, width: view.bounds.size.width, height: 50)
listContainerView.frame = CGRect(x: 0, y: 50, width: view.bounds.size.width, height: view.bounds.size.height - 50)
}
@objc func didSetingsButtonClicked() {
// let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "TitleImageSettingViewController") as! TitleImageSettingViewController
// vc.title = title
// vc.clickedClosure = {[weak self] (type) in
// (self?.segmentedDataSource as? JXSegmentedTitleImageDataSource)?.titleImageType = type
// //先更新数据源
// self?.segmentedDataSource?.reloadData(selectedIndex: self?.segmentedView.selectedIndex ?? 0)
// //再更新segmentedView
// self?.segmentedView.reloadData()
// }
// navigationController?.pushViewController(vc, animated: true)
}
@objc func didIndicatorPositionChanged() {
for indicaotr in (segmentedView.indicators as! [JXSegmentedIndicatorBaseView]) {
if indicaotr.indicatorPosition == .bottom {
indicaotr.indicatorPosition = .top
}else {
indicaotr.indicatorPosition = .bottom
}
}
segmentedView.reloadDataWithoutListContainer()
}
//MARK: 数字刷新demo
@objc func hanldeNumberRefresh()
{
if let _segDataSource = segmentedDataSource as? JXSegmentedNumberDataSource {
let newNumbers = [223, 12, 435, 332, 0, 32, 98, 0, 99999, 112]
_segDataSource.numberHeight = 18
_segDataSource.numberOffset = CGPoint(x: -5, y: 5)
_segDataSource.numbers = newNumbers
segmentedView.reloadDataWithoutListContainer()
}
}
}
extension ContentBaseViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
if let dotDataSource = segmentedDataSource as? JXSegmentedDotDataSource {
//先更新数据源的数据
dotDataSource.dotStates[index] = false
//再调用reloadItem(at: index)
segmentedView.reloadItem(at: index)
}
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
}
extension ContentBaseViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
return titleDataSource.dataSource.count
}
return 0
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return YHDavidTestViewController()
}
}
//
// ListBaseViewController.swift
// JXSegmentedView
//
// Created by jiaxin on 2018/12/26.
// Copyright © 2018 jiaxin. All rights reserved.
//
import UIKit
import JXSegmentedView
class ListBaseViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor(red: CGFloat(arc4random()%255)/255, green: CGFloat(arc4random()%255)/255, blue: CGFloat(arc4random()%255)/255, alpha: 1)
}
}
extension ListBaseViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
......@@ -21,6 +21,9 @@ class YHHomeViewController: YHBaseViewController {
}
}
let cellView: ContentBaseViewController = ContentBaseViewController()
//model 及网络请求
lazy var homeReqVM : YHHomePageViewModel = {
return YHHomePageViewModel()
......@@ -159,12 +162,8 @@ class YHHomeViewController: YHBaseViewController {
super.viewDidLayoutSubviews()
view.backgroundColor = .white
segmentView.frame = CGRect(x: 0, y: 0, width: view.bounds.size.width, height: sectionHeaderHeight)
// listContainerView.frame = CGRect(x: 0, y: segmentedView.y + segmentedView.height, width: view.bounds.size.width, height: view.bounds.size.height - segmentedView.y - segmentedView.height - UIDevice.bs_tabBarFullHeight())
//
// printLog("segmentedView.frame.size.height ===> \(segmentedView.frame.size.height)")
// printLog("listContainerView.frame.size.height ===> \(listContainerView.frame.size.height)")
// segmentView.frame = CGRect(x: 0, y: 0, width: view.bounds.size.width, height: sectionHeaderHeight)
cellView.view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: myCellHeight)
}
}
......@@ -286,7 +285,7 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
if section == 0 {
return 0
}
return sectionHeaderHeight
return 0
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
......@@ -294,8 +293,10 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
return UIView()
}
segmentView.backgroundColor = .white
return segmentView
return UIView()
// segmentView.backgroundColor = .white
// return segmentView
}
......@@ -338,7 +339,8 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
let cell = UITableViewCell()
cell.contentView.backgroundColor = .orange
cell.contentView.addSubview(pageContentView)
cell.contentView.addSubview(cellView.view)
cellView.view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: myCellHeight)
return cell
}
......
......@@ -50,8 +50,6 @@ class YHHomeBannerView: UIView {
make.height.equalTo(25)
}
setupPageControl()
bannerView.reloadData()
}
......
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