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

完善 首页逻辑

parent 6bee5c52
......@@ -63,6 +63,10 @@ target 'galaxy' do
pod 'SensorsAnalyticsSDK','4.6.0'
#主流APP分类切换滚动视图
pod 'JXSegmentedView','1.3.0'
#UI调试组件
# pod 'LookinServer',:configurations => ['Debug'],'1.2.6'
pod 'LookinServer','1.2.6',:subspecs => ['Swift'], :configurations => ['Debug']
end
......
......@@ -85,7 +85,7 @@
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 */; };
A5C5B3102B57677300A7C5D1 /* BsGestureTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5C5B30F2B57677300A7C5D1 /* BsGestureTableView.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 */
......@@ -205,7 +205,7 @@
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>"; };
A5C5B30F2B57677300A7C5D1 /* BsGestureTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BsGestureTableView.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>"; };
......@@ -608,6 +608,7 @@
A5ACE95B2B45712D002C94D2 /* V */ = {
isa = PBXGroup;
children = (
A5C5B30F2B57677300A7C5D1 /* BsGestureTableView.swift */,
A5C5B2FA2B5535DF00A7C5D1 /* YHHomeBannerView.swift */,
A5C5B2F82B5515CE00A7C5D1 /* YHPageContentView.swift */,
A530268F2B4E6F2700F35102 /* YHHomeCustomCell.swift */,
......@@ -619,9 +620,8 @@
A5ACE95C2B457133002C94D2 /* C */ = {
isa = PBXGroup;
children = (
A5C5B2FE2B55623700A7C5D1 /* ContentBaseViewController.swift */,
A5C5B2FF2B55623800A7C5D1 /* ListBaseViewController.swift */,
A5ACE95D2B4571BF002C94D2 /* YHHomeViewController.swift */,
A5C5B2FE2B55623700A7C5D1 /* ContentBaseViewController.swift */,
A5C5B2E52B4EC0BF00A7C5D1 /* YHDavidTestViewController.swift */,
);
path = C;
......@@ -821,7 +821,6 @@
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 */,
......@@ -859,6 +858,7 @@
A5ACE93F2B4564F7002C94D2 /* UIViewController+Extension.swift in Sources */,
A5ACE9472B4564F7002C94D2 /* YHHUD.swift in Sources */,
A5ACE9412B4564F7002C94D2 /* Dictionary+Extension.swift in Sources */,
A5C5B3102B57677300A7C5D1 /* BsGestureTableView.swift in Sources */,
A5ACE9312B4564F7002C94D2 /* YHPersonalCenterCell.swift in Sources */,
A5ACE9532B4564F7002C94D2 /* YHBaseViewController.swift in Sources */,
A5ACE9392B4564F7002C94D2 /* UIDevice+Extension.swift in Sources */,
......
......@@ -30,7 +30,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//3.其他第三方sdk设置
thirdSetting()
YHAnalytics.analyticsStart(launchOptions: launchOptions)
// YHAnalytics.analyticsStart(launchOptions: launchOptions)
return true
}
......@@ -141,7 +142,6 @@ extension AppDelegate {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()
// window?.backgroundColor = .white
}
}
......
......@@ -10,7 +10,18 @@ import UIKit
import JXSegmentedView
class ContentBaseViewController: UIViewController {
var canScroll : Bool = false {
didSet {
for vc in arrItemVCs {
vc.vcCanScroll = canScroll
}
}
}
let arrItemTitles = ["推荐","子女教育","税务规划","民生医疗","成功案例","我的服务","行业资讯","香港生活","你我他","我是很长的tag呀"]
var arrItemVCs : [YHDavidTestViewController] = []
var segmentedView : JXSegmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 40))
lazy var segmentedDataSource: JXSegmentedBaseDataSource = {
let dataSource = JXSegmentedTitleDataSource()
......@@ -32,13 +43,15 @@ class ContentBaseViewController: UIViewController {
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self)
return JXSegmentedListContainerView(dataSource: self, type: .collectionView)
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
for _ in arrItemTitles {
arrItemVCs.append(YHDavidTestViewController())
}
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
......@@ -47,27 +60,6 @@ class ContentBaseViewController: UIViewController {
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
......@@ -79,6 +71,9 @@ class ContentBaseViewController: UIViewController {
indicator.indicatorWidth = 16
indicator.indicatorColor = .blue
segmentedView.indicators = [indicator]
}
override func viewWillAppear(_ animated: Bool) {
......@@ -100,55 +95,12 @@ class ContentBaseViewController: UIViewController {
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)
// view.backgroundColor = .purple//for test hjl
}
@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)
}
}
......@@ -162,7 +114,6 @@ extension ContentBaseViewController: JXSegmentedListContainerViewDataSource {
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return YHDavidTestViewController()
return arrItemVCs[index]
}
}
//
// 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
}
}
......@@ -12,6 +12,7 @@ import JXSegmentedView
import GKNavigationBarSwift
class YHDavidTestViewController: YHBaseViewController {
var vcCanScroll : Bool = true
lazy var descripeLable:UILabel = {
let label = UILabel()
......@@ -79,15 +80,15 @@ class YHDavidTestViewController: YHBaseViewController {
let flowLayout = UICollectionViewFlowLayout()
let margin = 20.0
let gap = 20.0
let itemWidth = floor((KScreenWidth-2*margin-gap)/2.0)
let itemWidth = ceil((KScreenWidth - 2*margin - gap)/2.0)
flowLayout.itemSize = CGSize(width: itemWidth, height: 210 + 87 + 4)
flowLayout.minimumInteritemSpacing = 20.0
flowLayout.minimumLineSpacing = 20.0
flowLayout.minimumInteritemSpacing = 10.0
flowLayout.minimumLineSpacing = 10.0
flowLayout.scrollDirection = .vertical
let collectinoView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.contentInset = UIEdgeInsets(top: 20, left: margin, bottom: 20, right: margin)
collectinoView.backgroundColor = UIColor.white
let collectinoView = BsGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.contentInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
collectinoView.backgroundColor = .white
collectinoView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectinoView.register(YHDavidTestCollectionViewCell.self, forCellWithReuseIdentifier:YHDavidTestCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
......@@ -134,81 +135,84 @@ extension YHDavidTestViewController {
func setupUI() {
gk_navTitle = "David的测试UI"
view.backgroundColor = .white
view.addSubview(bannerView)
let bannerHeight: CGFloat = 143/343 * (KScreenWidth - 16 * 2)
bannerView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(bannerHeight)
}
let subHoldView = UIView()
subHoldView.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
subHoldView.layer.borderWidth = 0.5
subHoldView.layer.borderColor = UIColor(red: 0.798, green: 0.798, blue: 0.798, alpha: 1).cgColor
view.addSubview(subHoldView)
subHoldView.snp.makeConstraints { make in
make.top.equalTo(bannerView.snp.bottom).offset(2)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.height.equalTo(87)
}
subHoldView.addSubview(descripeLable)
descripeLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.height.equalTo(30)
}
subHoldView.addSubview(headImageView)
headImageView.snp.makeConstraints { make in
make.top.equalTo(descripeLable.snp.bottom).offset(10)
make.left.equalTo(descripeLable.snp.left)
make.height.width.equalTo(25)
}
subHoldView.addSubview(nameLable)
nameLable.snp.makeConstraints { make in
make.top.equalTo(headImageView.snp.top)
make.left.equalTo(headImageView.snp.right).offset(5)
make.height.equalTo(12)
make.width.equalTo(50)
}
subHoldView.addSubview(dateLable)
dateLable.snp.makeConstraints { make in
make.top.equalTo(nameLable.snp.bottom).offset(2)
make.left.equalTo(nameLable.snp.left)
make.height.equalTo(12)
make.right.equalTo(nameLable.snp.right)
}
subHoldView.addSubview(numLable)
numLable.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8)
make.height.equalTo(12)
make.centerY.equalTo(headImageView.snp.centerY)
}
subHoldView.addSubview(heartImageView)
heartImageView.snp.makeConstraints { make in
make.right.equalTo(numLable.snp.left).offset(-6)
make.height.width.equalTo(12)
make.centerY.equalTo(headImageView.snp.centerY)
}
// view.addSubview(bannerView)
//
// let bannerHeight: CGFloat = 143/343 * (KScreenWidth - 16 * 2)
// bannerView.snp.makeConstraints { make in
// make.top.left.right.equalToSuperview()
// make.height.equalTo(bannerHeight)
// }
//
// let subHoldView = UIView()
// subHoldView.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
// subHoldView.layer.borderWidth = 0.5
// subHoldView.layer.borderColor = UIColor(red: 0.798, green: 0.798, blue: 0.798, alpha: 1).cgColor
// subHoldView.backgroundColor = .red
// view.addSubview(subHoldView)
// subHoldView.snp.makeConstraints { make in
// make.top.equalTo(bannerView.snp.bottom).offset(2)
// make.left.equalToSuperview().offset(16)
// make.right.equalToSuperview().offset(-16)
// make.height.equalTo(87)
// }
//
// subHoldView.addSubview(descripeLable)
// descripeLable.snp.makeConstraints { make in
// make.top.equalToSuperview().offset(8)
// make.left.equalToSuperview().offset(8)
// make.right.equalToSuperview().offset(-8)
// make.height.equalTo(30)
// }
//
// subHoldView.addSubview(headImageView)
// headImageView.snp.makeConstraints { make in
// make.top.equalTo(descripeLable.snp.bottom).offset(10)
// make.left.equalTo(descripeLable.snp.left)
// make.height.width.equalTo(25)
// }
//
// subHoldView.addSubview(nameLable)
// nameLable.snp.makeConstraints { make in
// make.top.equalTo(headImageView.snp.top)
// make.left.equalTo(headImageView.snp.right).offset(5)
// make.height.equalTo(12)
// make.width.equalTo(50)
// }
//
// subHoldView.addSubview(dateLable)
// dateLable.snp.makeConstraints { make in
// make.top.equalTo(nameLable.snp.bottom).offset(2)
// make.left.equalTo(nameLable.snp.left)
// make.height.equalTo(12)
// make.right.equalTo(nameLable.snp.right)
// }
//
// subHoldView.addSubview(numLable)
// numLable.snp.makeConstraints { make in
// make.right.equalToSuperview().offset(-8)
// make.height.equalTo(12)
// make.centerY.equalTo(headImageView.snp.centerY)
// }
//
// subHoldView.addSubview(heartImageView)
// heartImageView.snp.makeConstraints { make in
// make.right.equalTo(numLable.snp.left).offset(-6)
// make.height.width.equalTo(12)
// make.centerY.equalTo(headImageView.snp.centerY)
// }
view.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(subHoldView.snp.bottom).offset(10)//.offset(k_Height_NavigationtBarAndStatuBar)
make.top.equalToSuperview().offset(10)
}
// self.myCollectView.backgroundColor = UIColor.green
self.myCollectView.es.addPullToRefresh {
self.loadFirstItem()
}
self.myCollectView.es.startPullToRefresh()
// self.myCollectView.es.startPullToRefresh()
self.myCollectView.es.addInfiniteScrolling {
self.loadFakeData()
}
......@@ -238,6 +242,32 @@ extension YHDavidTestViewController: UICollectionViewDelegateFlowLayout, UIColle
// MARK: - JXSegmentedListContainerViewListDelegate
extension YHDavidTestViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return self.view
return view
}
}
// MARK: - 滑动使用
extension YHDavidTestViewController: UIScrollViewDelegate {
//控制滑动交互
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView === myCollectView {
let scrollViewSet: CGFloat = scrollView.contentOffset.y
printLog("subTableView --- scrollView.contentOffset.y = \(scrollViewSet) scrollView.contentOffset.x = \(scrollView.contentOffset.y)")
if vcCanScroll == false {//不能滚动时
scrollView.contentOffset = CGPoint(x: -20, y: 0)
printLog("vcCanScroll == false")
} else {
if (scrollViewSet <= 0) {
scrollView.contentOffset = CGPoint(x: -20, y: 0)
vcCanScroll = false
NotificationCenter.default.post(name: Notification.Name(rawValue: "leaveTop"), object: nil)
} else {
scrollView.contentOffset = CGPoint(x: -20, y: scrollViewSet)
}
}
}
}
}
......@@ -15,13 +15,14 @@ class YHHomeViewController: YHBaseViewController {
let sectionHeaderHeight : CGFloat = 40
let cellHeight : CGFloat = 80
var arrItemVc : [UIViewController] = []
var canScroll : Bool = true
var myCellHeight : CGFloat {
get {
return view.height - homeNavBarView.height - k_TabBar_Height - k_Height_NavigationtBarAndStatuBar - cellHeight * 2 - sectionHeaderHeight
return view.bounds.size.height - homeNavBarView.height - k_TabBar_Height - k_Height_NavigationtBarAndStatuBar - cellHeight * 2
}
}
let cellView: ContentBaseViewController = ContentBaseViewController()
//model 及网络请求
......@@ -78,9 +79,9 @@ class YHHomeViewController: YHBaseViewController {
}()
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
var homeTableView: BsGestureTableView = {
let tableView = BsGestureTableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .yellow//for test hjl
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
......@@ -111,40 +112,13 @@ class YHHomeViewController: YHBaseViewController {
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self)
}()
lazy var pageContentView: YHPageContentView = {
self.arrItemVc.removeAll()
for model in arrItemTitles {
let vc = YHDavidTestViewController()
// vc.view.backgroundColor = .brown
arrItemVc.append(vc)
// //滑动使用
// vc.changeScrollBlock = { [weak self] in
// self?.canScroll = true
// }
}
let frame = CGRect(x: 0, y: 0, width: UIDevice.kScreenW, height: myCellHeight)
let view = YHPageContentView.init(frame: frame, childVcs: arrItemVc, parentViewController: self)
view.banScrollEnabled()
view.delegate = self
return view
}()
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(leaveTopOp), name:Notification.Name(rawValue: "leaveTop"), object: nil)
//1.UI
initView()
......@@ -156,26 +130,20 @@ class YHHomeViewController: YHBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
view.backgroundColor = .white
// 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)
}
}
// MARK: - 私有方法
extension YHHomeViewController {
@objc func leaveTopOp() {
canScroll = true
}
private func requestData() {
self.homeReqVM.getHomeConfig { flag, error in
if flag == true {
//1. 调用model 刷新界面
YHHUD.flash(message: "数据已更新")
} else {
//2. 给出 错误提示
if let error = error {
......@@ -220,24 +188,6 @@ extension YHHomeViewController {
self.homeTableView.es.addInfiniteScrolling {
self.loadFakeData()
}
//分类Title
segmentView.dataSource = segmentedDataSource
segmentView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = .blue
segmentView.indicators = [indicator]
//
arrItemVc.removeAll()
for title in arrItemTitles {
arrItemVc.append(YHDavidTestViewController())
}
}
private func loadFirstItem() {
......@@ -257,12 +207,8 @@ extension YHHomeViewController {
@objc func tapSearch() {
printLog("*")
navigationController?.pushViewController(YHDavidTestViewController())
}
}
// MARK: - UITableViewDelegate 和 UITableViewDataSource
......@@ -294,13 +240,8 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
}
return UIView()
// segmentView.backgroundColor = .white
// return segmentView
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
......@@ -317,7 +258,7 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
if indexPath.section == 0 {
return cellHeight
}
return myCellHeight
return CGRectGetHeight(self.view.bounds)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
......@@ -327,59 +268,50 @@ extension YHHomeViewController : UITableViewDelegate,UITableViewDataSource {
cell.contentView.backgroundColor = .systemPink
} else {
cell.contentView.backgroundColor = .brown
}
cell.textLabel?.text = "第\(indexPath.section + 1)个section - 第\(indexPath.row + 1) 行"
cell.textLabel?.text = "第\(indexPath.section)个section - 第\(indexPath.row) 行"
return cell
}
let cell = UITableViewCell()
cell.contentView.backgroundColor = .orange
let cell = UITableViewCell()
view.backgroundColor = .blue //for test hjl
tableView.backgroundColor = .yellow//for test hjl
cellView.view.frame = CGRect(x: 0, y: 0, width: cell.contentView.bounds.size.width, height: KScreenHeight - 64)
cell.contentView.addSubview(cellView.view)
cellView.view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: myCellHeight)
// cell.contentView.backgroundColor = .red for test hjl
// cellView.view.backgroundColor = .systemPink //for test hjl
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
printLog("点击了 tableView Cell \(indexPath.row)")
}
}
// MARK: - JXSegmentedViewDelegate
extension YHHomeViewController : JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
printLog("选择了: \(index)")
}
}
// MARK: - JXSegmentedListContainerViewDataSource
extension YHHomeViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
return arrItemTitles.count
}
extension YHHomeViewController: UIScrollViewDelegate {
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
if index < arrItemVc.count {
return arrItemVc[index] as? JXSegmentedListContainerViewListDelegate ?? YHDavidTestViewController()
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let bottomCellOffset: CGFloat = homeTableView.rect(forSection: 1).origin.y - 64 + 80 - 12
printLog("Main scrollView.contentOffset.y = \(scrollView.contentOffset.y) bottomCellOffset= \(bottomCellOffset)")
if (scrollView.contentOffset.y >= bottomCellOffset) {
scrollView.contentOffset = CGPointMake(0, bottomCellOffset)
if canScroll == true {
canScroll = false
//传递参数到 子VC
cellView.canScroll = true
}
}else{
if canScroll == false {
scrollView.contentOffset = CGPoint(x: 0, y: bottomCellOffset)
}
}
return YHDavidTestViewController()
}
}
// MARK: - BsPageContentViewDelegate
extension YHHomeViewController: YHPageContentViewDelegate {
func pageContentView(_ contentView: YHPageContentView, progress: CGFloat, sourceIndex: Int, targetIndex: Int) {
// self.pageTitleView.setTitleWithProgress(progress, sourceIndex: sourceIndex, targetIndex: targetIndex)
printLog("-----progress:\(progress) sourceIndex:\(sourceIndex) targetIndex:\(targetIndex)")
self.homeTableView.showsVerticalScrollIndicator = canScroll ? true : false
}
}
......@@ -22,8 +22,6 @@ class YHAboutUsViewController: YHBaseViewController {
return [AboutAdvantageItem(iconName: "about_match", title: "ABC".local, detail: "大数据精准匹配,专属方案获批率更高"),
AboutAdvantageItem(iconName: "about_response", title: "快速响应", detail: "身份规划师一对一专业服务,第一时间响应您的需求"),
AboutAdvantageItem(iconName: "about_service", title: "专业服务", detail: "5年经验+英语专8级文案导师团队倾力支持"),
AboutAdvantageItem(iconName: "about_service2", title: "精准匹配", detail: "香港专才、香港留学获批常年保持90%以上"),
AboutAdvantageItem(iconName: "about_service2", title: "精准匹配", detail: "香港专才、香港留学获批常年保持90%以上"),
AboutAdvantageItem(iconName: "about_service2", title: "精准匹配", detail: "香港专才、香港留学获批常年保持90%以上")]
}()
......@@ -45,7 +43,7 @@ class YHAboutUsViewController: YHBaseViewController {
collectinoView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.backgroundColor = .purple //for test hjl
collectinoView.backgroundColor = .clear //for test hjl
return collectinoView
}()
......
......@@ -21,7 +21,7 @@ let APP_NAME = Bundle.main.infoDictionary!["CFBundleName"] as! String
/// - line: 所在行
public func printLog<T>(_ message: T, file: String = #file, method: String = #function, line: Int = #line) {
#if DEBUG
print("\n开始一段日志输出=========>\n[文件]:\((file as NSString).lastPathComponent)\n[所在行]:\(line)\n[方法名称]:\(method)\n[打印信息]:\(message)\n结束该段日志输出<=========\n\n\n")
print("\n开始一段日志输出=========>\n[文件]:\((file as NSString).lastPathComponent)\n[所在行]:\(line)\n[方法名称]:\(method)\n[打印信息]:\(message)\n结束该段日志输出<=========")
#endif
}
......
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