Commit 564c2fc1 authored by pete谢兆麟's avatar pete谢兆麟

香港身份 香港生活二级tabbar

parent b6d24b80
......@@ -298,6 +298,11 @@
04EA376F2BEA071600DBAF64 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376E2BEA070500DBAF64 /* libc++.tbd */; };
04EA37742BEA0A3400DBAF64 /* YHShareManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04EA37732BEA0A3400DBAF64 /* YHShareManager.swift */; };
04F4B76B2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F4B76A2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift */; };
04F5F8602C1944D5004A463C /* YHHKCenterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F5F85F2C1944D5004A463C /* YHHKCenterViewController.swift */; };
04F5F8622C1945C0004A463C /* YHHKIdentityCardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F5F8612C1945C0004A463C /* YHHKIdentityCardViewController.swift */; };
04F5F8642C19460D004A463C /* YHHKLifeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F5F8632C19460D004A463C /* YHHKLifeViewController.swift */; };
04F5F8662C197FFF004A463C /* YHHKControllerHoldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F5F8652C197FFF004A463C /* YHHKControllerHoldViewController.swift */; };
04F5F8682C198372004A463C /* YHHKClassListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F5F8672C198372004A463C /* YHHKClassListViewController.swift */; };
04FA8B2B2C06F59D00ABE43F /* YHAppleLoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */; };
04FA8B2E2C084C7E00ABE43F /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */; };
04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */; };
......@@ -776,6 +781,11 @@
04EA376E2BEA070500DBAF64 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
04EA37732BEA0A3400DBAF64 /* YHShareManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareManager.swift; sourceTree = "<group>"; };
04F4B76A2BAA7E1E00D13284 /* YHCertificateTemplateSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateTemplateSheetView.swift; sourceTree = "<group>"; };
04F5F85F2C1944D5004A463C /* YHHKCenterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKCenterViewController.swift; sourceTree = "<group>"; };
04F5F8612C1945C0004A463C /* YHHKIdentityCardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKIdentityCardViewController.swift; sourceTree = "<group>"; };
04F5F8632C19460D004A463C /* YHHKLifeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKLifeViewController.swift; sourceTree = "<group>"; };
04F5F8652C197FFF004A463C /* YHHKControllerHoldViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKControllerHoldViewController.swift; sourceTree = "<group>"; };
04F5F8672C198372004A463C /* YHHKClassListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHKClassListViewController.swift; sourceTree = "<group>"; };
04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAppleLoginManager.swift; sourceTree = "<group>"; };
04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; };
04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOneKeyLoginViewModel.swift; sourceTree = "<group>"; };
......@@ -2378,11 +2388,16 @@
04E41DE72BD240570077EAE3 /* YHOrderDetailViewController.swift */,
048787D42BCE880B0036E221 /* YHServiceOrderListViewController.swift */,
044413FC2BC386DA00784A14 /* YHServiceViewController.swift */,
04F5F85F2C1944D5004A463C /* YHHKCenterViewController.swift */,
044413FE2BC391F000784A14 /* YHServiceListViewController.swift */,
04F5F8612C1945C0004A463C /* YHHKIdentityCardViewController.swift */,
04F5F8632C19460D004A463C /* YHHKLifeViewController.swift */,
044414002BC3979800784A14 /* YHServerHKLifeViewController.swift */,
A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */,
A5FD63BC2B623C2C00D1D9DA /* YHInformationPerfectListVC.swift */,
043D2C892C0EEF3F00172438 /* YHOrderSearchViewController.swift */,
04F5F8652C197FFF004A463C /* YHHKControllerHoldViewController.swift */,
04F5F8672C198372004A463C /* YHHKClassListViewController.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2712,6 +2727,7 @@
04A6715C2B9FE9EA00C1FB91 /* YHCertificateUploadContentListVC.swift in Sources */,
A592FE972BA6DB340062FACA /* YHCertificateViewModel.swift in Sources */,
045EEEF02B9F171A0022A143 /* YHChildPrimaryInfoVC.swift in Sources */,
04F5F8602C1944D5004A463C /* YHHKCenterViewController.swift in Sources */,
A5D001212BAA9D99001F003C /* YHChoiceButtonHoldView.swift in Sources */,
045EEEF62B9F171A0022A143 /* YHSpousePrimaryInfoVC.swift in Sources */,
044867B82BA1C75700DFAD4A /* YHCertificateUploadFailTipsView.swift in Sources */,
......@@ -2761,6 +2777,7 @@
045EEEB32B9F171A0022A143 /* YHWorkFileSyncTableViewCell.swift in Sources */,
045EEEF12B9F171A0022A143 /* YHChildInfoContainerVC.swift in Sources */,
045EEF0B2B9F171A0022A143 /* YHBasicInfoFillViewController.swift in Sources */,
04F5F8682C198372004A463C /* YHHKClassListViewController.swift in Sources */,
A582B2452BBA4CF9009D098C /* YHHKPlanDocModel.swift in Sources */,
045EEF142B9F171A0022A143 /* YHItemModel.swift in Sources */,
045EEED72B9F171A0022A143 /* YHEducationInfo.swift in Sources */,
......@@ -2802,6 +2819,7 @@
045EEE7A2B9F171A0022A143 /* YHPreviewForOtherInfoModel.swift in Sources */,
0414BDA92BC7E81500225367 /* YHMyPermissionSettingVC.swift in Sources */,
A567E5AA2BD7643D00D5D5A0 /* YHGestureTableView.swift in Sources */,
04F5F8642C19460D004A463C /* YHHKLifeViewController.swift in Sources */,
A5ACE94A2B4564F7002C94D2 /* YHHUDProgressView.swift in Sources */,
04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */,
A582B2412BB95998009D098C /* YHHKPlanTipsCell.swift in Sources */,
......@@ -3094,6 +3112,7 @@
045EEECA2B9F171A0022A143 /* YHMyDocumentsListViewController.swift in Sources */,
045EEF052B9F171A0022A143 /* YHFormItemExpireDateCell.swift in Sources */,
043B0A352C1190C6008A9BBA /* YHSelectFileSheetView.swift in Sources */,
04F5F8662C197FFF004A463C /* YHHKControllerHoldViewController.swift in Sources */,
A5ACE92D2B4564F7002C94D2 /* YHLoginPrivacyView.swift in Sources */,
045EEEB72B9F171A0022A143 /* YHWorkItemAddView.swift in Sources */,
A5ACE9372B4564F7002C94D2 /* YHBaseUrlManager.swift in Sources */,
......@@ -3101,6 +3120,7 @@
045EEF092B9F171A0022A143 /* YHBasicInfoFillModel.swift in Sources */,
A5ACE9352B4564F7002C94D2 /* YHNetRequest.swift in Sources */,
A5FD63CB2B63D6C300D1D9DA /* YHInformationFillTipsCell.swift in Sources */,
04F5F8622C1945C0004A463C /* YHHKIdentityCardViewController.swift in Sources */,
045EEF1F2B9F171A0022A143 /* YHDatePickView.swift in Sources */,
04174D7A2BCD5B74000BA46D /* YHDetailMessageCell.swift in Sources */,
045EEE972B9F171A0022A143 /* YHPreviewInfoWorkExpView.swift in Sources */,
......
......@@ -121,12 +121,12 @@ private extension YHHkLifeAndIdItemView {
@objc func tapView(gestureRecognizer:UITapGestureRecognizer) {
if itemType == .hkID {
//香港身份
let vc = YHServiceViewController()
let vc = YHHKCenterViewController()
vc.defaltIndex = 0
UIViewController.current?.navigationController?.pushViewController(vc)
} else if itemType == .hklife {
//香港生活
let vc = YHServiceViewController()
let vc = YHHKCenterViewController()
vc.defaltIndex = 1
UIViewController.current?.navigationController?.pushViewController(vc)
} else {
......
//
// YHHKCenterViewController.swift
// galaxy
//
// Created by EDY on 2024/6/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHKCenterViewController: YHBaseViewController {
var defaltIndex: Int = 0
let arrItemTitles = ["香港身份","香港生活"]
var arrItemVCs : [YHBaseViewController] = []
var segmentedView : JXSegmentedView = JXSegmentedView(frame: CGRect(x: 0, y: k_Height_safeAreaInsetsTop(), width: KScreenWidth, height: 48))
lazy var segmentedDataSource: JXSegmentedBaseDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.isTitleColorGradientEnabled = true
dataSource.titles = arrItemTitles
dataSource.titleNormalFont = UIFont.PFSC_M(ofSize: 15)
dataSource.titleNormalColor = .labelTextColor2
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 18)
dataSource.titleSelectedColor = .mainTextColor
dataSource.isItemSpacingAverageEnabled = false
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 90
return dataSource
}()
lazy var navBar: UIView = {
let bar = UIView()
let backBtn = UIButton()
backBtn.setImage(UIImage(named: "back_icon"), for: .normal)
backBtn.addTarget(self, action: #selector(didBackBtnClicked), for: .touchUpInside)
backBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
bar.addSubview(backBtn)
backBtn.snp.makeConstraints { make in
make.width.height.equalTo(21)
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(16)
}
return bar
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self, type: .scrollView)
}()
@objc func didBackBtnClicked() {
self.navigationController?.popViewController(animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
gk_navBarAlpha = 0
gk_navigationBar.isHidden = true
view.backgroundColor = .white
for i in 0..<arrItemTitles.count {
if i == 0 {
let vc = YHHKIdentityCardViewController()
arrItemVCs.append(vc)
} else {
let vc = YHHKLifeViewController()
arrItemVCs.append(vc)
}
}
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
segmentedView.collectionView.backgroundColor = .white
view.addSubview(segmentedView)
segmentedView.listContainer = listContainerView
view.addSubview(listContainerView)
//分类Title
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = UIColor.brandMainColor
segmentedView.indicators = [indicator]
segmentedView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1)
view.addSubview(navBar)
navBar.snp.makeConstraints { make in
make.left.equalToSuperview()
// make.top.equalToSuperview().offset(k_Height_statusBar())
make.height.equalTo(k_Height_NavContentBar)
make.width.equalTo(47)
make.centerY.equalTo(segmentedView.snp.centerY)
}
segmentedView.defaultSelectedIndex = defaltIndex
}
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: k_Height_safeAreaInsetsTop(), width: view.bounds.size.width, height: 48)
listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop())
}
}
extension YHHKCenterViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
}
extension YHHKCenterViewController {
func jumpToItemIndex(itemIndex : Int) {
self.segmentedView.selectItemAt(index: itemIndex)
}
}
extension YHHKCenterViewController: 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 arrItemVCs[index] as! JXSegmentedListContainerViewListDelegate
}
}
//
// YHHKClassListView.swift
// galaxy
//
// Created by EDY on 2024/6/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHKClassListViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var items:[YHHomeListModel?] = [] {
didSet {
self.myCollectView.reloadData()
}
}
lazy var myCollectView = {
// 设置布局方向
let flowLayout = YHHomeCollectionLayout()
flowLayout.minimumInteritemSpacing = 7.0
flowLayout.minimumColumnSpacing = 7.0
flowLayout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
let collectinoView = YHGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.backgroundColor = .white
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
// collectinoView.bounces = false
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
collectinoView.showsVerticalScrollIndicator = false
collectinoView.showsHorizontalScrollIndicator = false
return collectinoView
}()
var classId: Int = 0
public var vcCanScroll : Bool = true
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
setupUI()
NotificationCenter.default.addObserver(self, selector: #selector(beginDragging), name:Notification.Name(rawValue: "scrollViewWillBeginDragging0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(endDragging), name:Notification.Name(rawValue: "scrollViewDidEndDragging0"), object: nil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
}
}
extension YHHKClassListViewController {
func loadData() {
self.homeViewModel.getList(true, classId) {[weak self] success, error in
guard let self = self else { return }
self.items = self.homeViewModel.arrHomeNewsData ?? []
if self.homeViewModel.hasMoreForHomeNews == false {
self.myCollectView.es.noticeNoMoreData()
self.myCollectView.footer?.alpha = 1
}
}
}
func setupUI() {
gk_navBarAlpha = 1
view.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.top.left.right.bottom.equalToSuperview()
}
myCollectView.es.addInfiniteScrolling {[weak self] in
guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
CATransaction.setDisableActions(true)
self.items = self.homeViewModel.arrHomeNewsData ?? []
CATransaction.commit()
self.myCollectView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.myCollectView.es.noticeNoMoreData()
}
})
}
}
}
}
extension YHHKClassListViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
extension YHHKClassListViewController {
@objc func beginDragging() {
myCollectView.isScrollEnabled = false
vcCanScroll = false
}
@objc func endDragging() {
myCollectView.isScrollEnabled = true
vcCanScroll = true
}
}
extension YHHKClassListViewController: UIScrollViewDelegate {
//控制滑动交互
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let scrollViewSet: CGFloat = scrollView.contentOffset.y
if vcCanScroll == false {//不能滚动时
scrollView.contentOffset = CGPoint(x: 0, y: 0)
} else {
if (scrollViewSet <= 0) {
scrollView.contentOffset = CGPoint(x: 0, y: 0)
vcCanScroll = false
NotificationCenter.default.post(name: Notification.Name(rawValue: "leaveTop0"), object: nil)
} else {
scrollView.contentOffset = CGPoint(x: 0, y: scrollViewSet)
}
}
}
}
extension YHHKClassListViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHHomeCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHHomeCollectionViewCell
cell.listModel = items[indexPath.row]
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let model = items[indexPath.row] else { return }
if model.type == 2 {
let vc = YHHomeWebViewController()
vc.url = YHBaseUrlManager.shared.curH5URL() + "articleDetail.html" + "?id=\(model.id)"
vc.id = model.id
vc.block = {[weak self] model in
guard let self = self else { return }
let arr = self.items
for (index, targetItem) in arr.enumerated() {
guard let target = targetItem else { return }
if target.id == model.id {
target.is_like = model.is_like
target.like_count = model.like_count
self.myCollectView.reloadItems(at: [IndexPath.SubSequence(item: index, section: 0)])
}
}
}
UIViewController.current?.navigationController?.pushViewController(vc)
} else if model.type == 1 {
printLog("直接播放视频")
}
}
}
extension YHHKClassListViewController: CollectionViewWaterfallLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
guard let model = items[indexPath.row] else { return CGSize.zero }
return CGSize(width: model.img_width_cell, height: model.img_height_cell)
}
}
//
// YHHKControllerHoldViewController.swift
// galaxy
//
// Created by EDY on 2024/6/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHKControllerHoldViewController: UIViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var canScroll : Bool = false {
didSet {
for vc in arrItemVCs {
vc.vcCanScroll = canScroll
}
}
}
var items: [YHClassifyModel] = []
var classID = 0
var myDefaultNavItemIndex : Int = 0 {
didSet {
self.segmentedView.selectItemAt(index: self.myDefaultNavItemIndex)
}
}
var arrItemTitles: [String] = []
var arrItemVCs : [YHHKClassListViewController] = []
var segmentedView : JXSegmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 55))
lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.titles = arrItemTitles
dataSource.titleNormalFont = UIFont.PFSC_R(ofSize: 14)
dataSource.titleSelectedColor = UIColor.labelTextColor2
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 14)
dataSource.titleSelectedColor = UIColor.white
dataSource.isTitleMaskEnabled = true
dataSource.isItemSpacingAverageEnabled = false
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 24
return dataSource
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self, type: .collectionView)
}()
override func viewDidLoad() {
super.viewDidLoad()
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
view.addSubview(segmentedView)
segmentedView.listContainer = listContainerView
view.addSubview(listContainerView)
//分类Title
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorBackgroundView()
indicator.indicatorColor = UIColor.brandMainColor
indicator.indicatorHeight = 32
segmentedView.indicators = [indicator]
segmentedView.defaultSelectedIndex = self.myDefaultNavItemIndex
getData()
}
func getData() {
homeViewModel.getHomeClassify{[weak self] success, error in
guard let self = self, let classify = self.homeViewModel.classify else { return }
for item in classify {
let model = item as YHHomeClassifyModel
if model.id == self.classID {
self.items = model.children
self.arrItemTitles.removeAll()
for item in model.children {
self.arrItemTitles.append(item.name)
let vc = YHHKClassListViewController()
vc.classId = item.id
arrItemVCs.append(vc)
}
}
self.segmentedDataSource.titles = arrItemTitles
self.segmentedView.dataSource = segmentedDataSource
self.segmentedView.reloadData()
}
}
}
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: 55)
listContainerView.frame = CGRect(x: 0, y: 55, width: view.bounds.size.width, height: view.bounds.size.height - 55)
segmentedView.backgroundColor = .white
}
}
extension YHHKControllerHoldViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewDidEndDragging0"), object: nil)
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewDidToTop"), object: nil)
}
/// 正在滚动中的回调
///
/// - Parameters:
/// - segmentedView: JXSegmentedView
/// - leftIndex: 正在滚动中,相对位置处于左边的index
/// - rightIndex: 正在滚动中,相对位置处于右边的index
/// - percent: 从左往右计算的百分比
func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewWillBeginDragging0"), object: nil)
}
}
extension YHHKControllerHoldViewController: 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 arrItemVCs[index] as JXSegmentedListContainerViewListDelegate
}
}
//
// YHHKIdentityCardViewController.swift
// galaxy
//
// Created by EDY on 2024/6/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHKIdentityCardViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var tableHeadView: YHServerTableHeadView!
var orderId : Int?
var canScroll : Bool = true
var myCellHeight : CGFloat {
get {
return view.bounds.size.height
}
}
var myDefaultIndex : Int = 0 {
didSet {
DispatchQueue.global().asyncAfter(wallDeadline: .now() ) {[weak self] in
DispatchQueue.main.async {
self?.cellView.myDefaultNavItemIndex = self?.myDefaultIndex ?? 0
}
}
}
}
lazy var cellView: YHHKControllerHoldViewController = {
let ttt = YHHKControllerHoldViewController()
ttt.classID = 1
return ttt
}()
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
return tableView
}()
var myHeadView : UIView = {
let view = UIView(frame: CGRect(x: kMargin, y: 0, width: KScreenWidth, height: 365))
view.backgroundColor = .white
return view
}()
//头像
private lazy var headImagV : UIImageView = {
let imageV = UIImageView(image: UIImage(named: "mine_head_default"))
imageV.contentMode = .scaleAspectFill
imageV.layer.cornerRadius = 26.5
imageV.clipsToBounds = true
imageV.layer.borderWidth = 2
imageV.layer.borderColor = UIColor.white.cgColor
return imageV
}()
//姓名
private lazy var nameLable : UILabel = {
let lable0 = UILabel(text: "")
lable0.textColor = UIColor.mainTextColor
lable0.font = UIFont.PFSC_M(ofSize: 19)
return lable0
}()
//电话号码
private lazy var phoneLable : UILabel = {
let lable0 = UILabel(text: "")
lable0.textColor = UIColor.labelTextColor2
lable0.font = UIFont.PFSC_R(ofSize: 14)
return lable0
}()
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(leaveTopOp), name:Notification.Name(rawValue: "leaveTop0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(beginDragging), name:Notification.Name(rawValue: "scrollViewWillBeginDragging0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(endDragging), name:Notification.Name(rawValue: "scrollViewDidEndDragging0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(scrDragging), name:Notification.Name(rawValue: "scrollViewDidToTop"), object: nil)
//1.UI
initView()
//2.网络请求
loadData()
updateDefaultSearchKeyWord()
}
func updateDefaultSearchKeyWord() {
var placeHolder = "香港身份"
if isHaveLocalSearchRecords() {
let latestValidSearchWord = getLatestValidSearchWord()
if !latestValidSearchWord.isEmpty {
placeHolder = latestValidSearchWord
}
}
tableHeadView.searchPlaceHolder = placeHolder
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
cellView.view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: myCellHeight)
}
}
// MARK: - 私有方法
extension YHHKIdentityCardViewController {
func loadData() {
self.tableHeadView.bannarView.dataArr = [YHBannerModel.localDefaultItem()]
homeViewModel.getHomeBanner(1){[weak self] success, error in
guard let self = self else { return }
self.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? [YHBannerModel.localDefaultItem()]
}
}
private func initView() {
gk_navigationBar.isHidden = true
homeTableView.delegate = self
homeTableView.dataSource = self
view.addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.right.bottom.equalToSuperview()
}
tableHeadView = YHServerTableHeadView()
tableHeadView.titleLabel.text = "香港身份攻略"
tableHeadView.frame = CGRect(x: 0, y: -365 - 48, width: KScreenWidth, height: 365)
homeTableView.tableHeaderView = tableHeadView
}
}
// MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHHKIdentityCardViewController : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.001
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 0.001))
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.001
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 0.001))
return view
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return myCellHeight
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cellView.view.frame = CGRect(x: 0, y: 0, width: cell.contentView.bounds.size.width, height: myCellHeight)
cell.contentView.addSubview(cellView.view)
cellView.view.snp.makeConstraints { make in
make.edges.equalTo(0)
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
}
extension YHHKIdentityCardViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let bottomCellOffset: CGFloat = homeTableView.rect(forSection: 0).origin.y
if (scrollView.contentOffset.y >= bottomCellOffset) {
scrollView.contentOffset = CGPointMake(0, bottomCellOffset)
if canScroll == true {
canScroll = false
//传递参数到 子VC
cellView.canScroll = true
}
canScroll = false
//传递参数到 子VC
cellView.canScroll = true
}else{
if canScroll == false {
scrollView.contentOffset = CGPoint(x: 0, y: bottomCellOffset)
}
}
self.homeTableView.showsVerticalScrollIndicator = false
}
}
extension YHHKIdentityCardViewController {
@objc func leaveTopOp() {
canScroll = true
}
@objc func beginDragging() {
homeTableView.isScrollEnabled = false
canScroll = false
}
@objc func endDragging() {
homeTableView.isScrollEnabled = true
canScroll = true
}
@objc func scrDragging() {
homeTableView.setContentOffset(CGPoint(x: 0, y: 365), animated: true)
}
}
extension YHHKIdentityCardViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
//
// YHHKLifeViewController.swift
// galaxy
//
// Created by EDY on 2024/6/12.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHHKLifeViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var tableHeadView: YHServerTableHeadView!
var orderId : Int?
var canScroll : Bool = true
var myCellHeight : CGFloat {
get {
return view.bounds.size.height
}
}
var myDefaultIndex : Int = 0 {
didSet {
DispatchQueue.global().asyncAfter(wallDeadline: .now() ) {[weak self] in
DispatchQueue.main.async {
self?.cellView.myDefaultNavItemIndex = self?.myDefaultIndex ?? 0
}
}
}
}
lazy var cellView: YHHKControllerHoldViewController = {
let ttt = YHHKControllerHoldViewController()
ttt.classID = 2
return ttt
}()
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
return tableView
}()
var myHeadView : UIView = {
let view = UIView(frame: CGRect(x: kMargin, y: 0, width: KScreenWidth, height: 365))
view.backgroundColor = .white
return view
}()
//头像
private lazy var headImagV : UIImageView = {
let imageV = UIImageView(image: UIImage(named: "mine_head_default"))
imageV.contentMode = .scaleAspectFill
imageV.layer.cornerRadius = 26.5
imageV.clipsToBounds = true
imageV.layer.borderWidth = 2
imageV.layer.borderColor = UIColor.white.cgColor
return imageV
}()
//姓名
private lazy var nameLable : UILabel = {
let lable0 = UILabel(text: "")
lable0.textColor = UIColor.mainTextColor
lable0.font = UIFont.PFSC_M(ofSize: 19)
return lable0
}()
//电话号码
private lazy var phoneLable : UILabel = {
let lable0 = UILabel(text: "")
lable0.textColor = UIColor.labelTextColor2
lable0.font = UIFont.PFSC_R(ofSize: 14)
return lable0
}()
// MARK: - 生命周期方法
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(leaveTopOp), name:Notification.Name(rawValue: "leaveTop0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(beginDragging), name:Notification.Name(rawValue: "scrollViewWillBeginDragging0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(endDragging), name:Notification.Name(rawValue: "scrollViewDidEndDragging0"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(scrDragging), name:Notification.Name(rawValue: "scrollViewDidToTop"), object: nil)
//1.UI
initView()
//2.网络请求
loadData()
updateDefaultSearchKeyWord()
}
func updateDefaultSearchKeyWord() {
var placeHolder = "香港身份"
if isHaveLocalSearchRecords() {
let latestValidSearchWord = getLatestValidSearchWord()
if !latestValidSearchWord.isEmpty {
placeHolder = latestValidSearchWord
}
}
tableHeadView.searchPlaceHolder = placeHolder
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
cellView.view.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: myCellHeight)
}
}
// MARK: - 私有方法
extension YHHKLifeViewController {
func loadData() {
self.tableHeadView.bannarView.dataArr = [YHBannerModel.localDefaultItem()]
homeViewModel.getHomeBanner(1){[weak self] success, error in
guard let self = self else { return }
self.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? [YHBannerModel.localDefaultItem()]
}
}
private func initView() {
gk_navigationBar.isHidden = true
homeTableView.delegate = self
homeTableView.dataSource = self
view.addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.right.bottom.equalToSuperview()
}
tableHeadView = YHServerTableHeadView()
tableHeadView.titleLabel.text = "香港身份攻略"
tableHeadView.frame = CGRect(x: 0, y: -365 - 48, width: KScreenWidth, height: 365)
homeTableView.tableHeaderView = tableHeadView
}
}
// MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHHKLifeViewController : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.001
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 0.001))
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.001
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 0.001))
return view
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return myCellHeight
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cellView.view.frame = CGRect(x: 0, y: 0, width: cell.contentView.bounds.size.width, height: myCellHeight)
cell.contentView.addSubview(cellView.view)
cellView.view.snp.makeConstraints { make in
make.edges.equalTo(0)
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
}
extension YHHKLifeViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let bottomCellOffset: CGFloat = homeTableView.rect(forSection: 0).origin.y
if (scrollView.contentOffset.y >= bottomCellOffset) {
scrollView.contentOffset = CGPointMake(0, bottomCellOffset)
if canScroll == true {
canScroll = false
//传递参数到 子VC
cellView.canScroll = true
}
canScroll = false
//传递参数到 子VC
cellView.canScroll = true
}else{
if canScroll == false {
scrollView.contentOffset = CGPoint(x: 0, y: bottomCellOffset)
}
}
self.homeTableView.showsVerticalScrollIndicator = false
}
}
extension YHHKLifeViewController {
@objc func leaveTopOp() {
canScroll = true
}
@objc func beginDragging() {
homeTableView.isScrollEnabled = false
canScroll = false
}
@objc func endDragging() {
homeTableView.isScrollEnabled = true
canScroll = true
}
@objc func scrDragging() {
homeTableView.setContentOffset(CGPoint(x: 0, y: 365), animated: true)
}
}
extension YHHKLifeViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
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