Commit 95b1055d authored by Steven杜宇's avatar Steven杜宇

// plan

parent 203cd5b0
......@@ -1251,6 +1251,7 @@
04D8FFAC2D97C80000703C75 /* YHMakePlanCusttomHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D8FFA32D97C80000703C75 /* YHMakePlanCusttomHeadView.swift */; };
04D8FFAD2D97C80000703C75 /* YHMakePlanStateHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D8FFA52D97C80000703C75 /* YHMakePlanStateHeadView.swift */; };
04D8FFAE2D97C80000703C75 /* YHMakePlanHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D8FFA42D97C80000703C75 /* YHMakePlanHeadView.swift */; };
04D8FFB02D9A3CF200703C75 /* YHPlanShareImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D8FFAF2D9A3CF200703C75 /* YHPlanShareImageCell.swift */; };
04E4CF3E2D5C6D32004D4013 /* YHCountryMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E4CF3D2D5C6D32004D4013 /* YHCountryMessageView.swift */; };
04E4CF402D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E4CF3F2D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift */; };
04E507D62D6EE856005F758B /* YHUserLevelAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E507D52D6EE856005F758B /* YHUserLevelAlertView.swift */; };
......@@ -2541,6 +2542,7 @@
04D8FFA32D97C80000703C75 /* YHMakePlanCusttomHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMakePlanCusttomHeadView.swift; sourceTree = "<group>"; };
04D8FFA42D97C80000703C75 /* YHMakePlanHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMakePlanHeadView.swift; sourceTree = "<group>"; };
04D8FFA52D97C80000703C75 /* YHMakePlanStateHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMakePlanStateHeadView.swift; sourceTree = "<group>"; };
04D8FFAF2D9A3CF200703C75 /* YHPlanShareImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPlanShareImageCell.swift; sourceTree = "<group>"; };
04E4CF3D2D5C6D32004D4013 /* YHCountryMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCountryMessageView.swift; sourceTree = "<group>"; };
04E4CF3F2D5C83AE004D4013 /* YHSelectPhoneCountryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHSelectPhoneCountryViewController.swift; sourceTree = "<group>"; };
04E507D52D6EE856005F758B /* YHUserLevelAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHUserLevelAlertView.swift; sourceTree = "<group>"; };
......@@ -6715,6 +6717,7 @@
04D8FF722D96759400703C75 /* YHPlanScoreLevelTextView.swift */,
04D8FF742D978CF000703C75 /* YHPlanLinkShareView.swift */,
04D8FF7A2D97C29E00703C75 /* YHPlanShareView.swift */,
04D8FFAF2D9A3CF200703C75 /* YHPlanShareImageCell.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -7255,6 +7258,7 @@
0411CEEB2D1512AF00644D35 /* YHGCWorkItemListViewModel.swift in Sources */,
045C10392D12CA5F00BD2DC0 /* YHHKMemberModel.swift in Sources */,
045C103A2D12CA5F00BD2DC0 /* YHCertificateUploadContentListVC.swift in Sources */,
04D8FFB02D9A3CF200703C75 /* YHPlanShareImageCell.swift in Sources */,
045C103B2D12CA5F00BD2DC0 /* YHOtherYesOrNoItemView.swift in Sources */,
045C103C2D12CA5F00BD2DC0 /* YhConstant.swift in Sources */,
045C103D2D12CA5F00BD2DC0 /* YHAdopterTravelItemTableViewCell.swift in Sources */,
......
......@@ -8,13 +8,45 @@
import UIKit
class YHPlanPolicyImageInfo {
var url: String = ""
var imgView: UIImageView = UIImageView()
let height: CGFloat = 520.0
var width: CGFloat = 520.0
}
class YHPlanPolicyDetailViewController: YHBaseViewController {
var urls: [String] = []
var urls: [String] = [] {
didSet {
imgs.removeAll()
for url in urls {
let model = YHPlanPolicyImageInfo()
model.url = url
imgs.append(model)
}
}
}
lazy var scrollView: UIScrollView = {
let v = UIScrollView(frame: .zero)
return v
var imgs: [YHPlanPolicyImageInfo] = []
// lazy var scrollView: UIScrollView = {
// let v = UIScrollView(frame: .zero)
// return v
// }()
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.minimumInteritemSpacing = 0.0
layout.minimumLineSpacing = 0.0
layout.scrollDirection = .horizontal
let collectView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectView.backgroundColor = .clear
collectView.delegate = self
collectView.dataSource = self
collectView.register(YHPlanShareImageCell.self, forCellWithReuseIdentifier: YHPlanShareImageCell.cellReuseIdentifier)
collectView.isPagingEnabled = true
return collectView
}()
lazy var shareBtn: UIButton = {
......@@ -32,13 +64,13 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
super.viewDidLoad()
gk_backImage = UIImage(named: "nav_back_white")
gk_navTitle = "1/24"
gk_navTitle = "1/\(urls.count)"
gk_navTitleColor = .white
view.backgroundColor = .init(hex: 0x000000, alpha: 1.0)
view.addSubview(scrollView)
view.addSubview(collectionView)
view.addSubview(shareBtn)
scrollView.snp.makeConstraints { make in
collectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(k_Height_NavigationtBarAndStatuBar+24.0)
make.height.equalTo(520)
......@@ -48,8 +80,77 @@ class YHPlanPolicyDetailViewController: YHBaseViewController {
make.left.equalTo(20)
make.right.equalTo(-20)
make.height.equalTo(46)
make.top.equalTo(scrollView.snp.bottom).offset(32)
make.top.equalTo(collectionView.snp.bottom).offset(32)
}
urls = ["https://img0.baidu.com/it/u=10464961,1462197942&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667",
"https://pic1.zhimg.com/v2-66b17db60d1c7c66096eaed9fe2bdb28_r.jpg",
"https://pics3.baidu.com/feed/2cf5e0fe9925bc3174f9833affbb97bcca137059.jpeg@f_auto?token=566818d4692ffdcc23b25f6391dbd061"
]
loadImgs()
}
func loadImgs() {
let ossGroup = DispatchGroup()
for item in imgs {
ossGroup.enter()
item.imgView.kf.setImage(with: URL(string: item.url)) { result in
switch result {
case let .success(value):
let size = value.image.size
let scale = size.height > 0 ? Double(size.width / size.height) : 1.0
if scale > 0 {
item.width = scale * item.height
}
case let .failure(error):
print("Job failed: \(error.localizedDescription)")
}
ossGroup.leave()
}
}
ossGroup.notify(queue: .main) {
self.collectionView.reloadData()
}
}
}
extension YHPlanPolicyDetailViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
// 返回单元格数量
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return imgs.count
}
// 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: KScreenWidth, height: collectionView.height)
}
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHPlanShareImageCell.cellReuseIdentifier, for: indexPath) as? YHPlanShareImageCell else {
return UICollectionViewCell()
}
if 0 <= indexPath.item && indexPath.item < imgs.count {
let model = imgs[indexPath.item]
cell.model = model
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < imgs.count {
// let text = topicArr[indexPath.item]
}
}
}
extension YHPlanPolicyDetailViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let currentIndex = Int(scrollView.contentOffset.x/KScreenWidth)
gk_navTitle = "\(currentIndex+1)/\(urls.count)"
}
}
......@@ -61,7 +61,8 @@ class YHPlanViewController: YHBaseViewController {
}()
@objc func didShareBtnClicked() {
let vc = YHPlanShareViewController()
// let vc = YHPlanShareViewController()
let vc = YHPlanPolicyDetailViewController()
self.navigationController?.pushViewController(vc)
}
......
//
// YHPlanShareImageCellCollectionViewCell.swift
// galaxy
//
// Created by Dufet on 2025/3/31.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHPlanShareImageCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHPlanShareImageCell"
var model: YHPlanPolicyImageInfo = YHPlanPolicyImageInfo() {
didSet {
if let url = URL(string: model.url) {
imgView.kf.setImage(with: url, placeholder: UIImage(named: "global_default_image"))
} else {
imgView.image = UIImage(named: "global_default_image")
}
imgView.snp.remakeConstraints { make in
make.top.bottom.equalToSuperview()
make.centerX.equalToSuperview()
make.width.equalTo(imgView.snp.height).multipliedBy(model.width/model.height)
}
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var imgContentView: UIView = {
let v = UIView()
v.backgroundColor = .clear
v.clipsToBounds = true
return v
}()
lazy var imgView: UIImageView = {
let v = UIImageView()
v.contentMode = .center
return v
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
contentView.addSubview(imgContentView)
imgContentView.addSubview(imgView)
imgContentView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.bottom.equalToSuperview()
}
imgView.snp.makeConstraints { make in
make.top.bottom.equalToSuperview()
make.centerX.equalToSuperview()
make.width.equalTo(imgView.snp.height).multipliedBy(1.0)
}
}
}
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