Commit 4ca87c64 authored by pete谢兆麟's avatar pete谢兆麟

Merge branch 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into develop

parents 9a21550c 18f40d48
This diff is collapsed.
//
// YHFloatingWindow.swift
// galaxy
//
// Created by alexzzw on 2024/11/29.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
......@@ -42,12 +42,14 @@ enum YHPersonalModuleItemType: Int {
class PersonalModuleItem {
var icon: String?
var title: String
var desc: String
var type:YHPersonalModuleItemType = .none
var isShowRedPoint:Bool = false
init(icon: String? = nil, title: String, isShowRedPoint:Bool = false, type:YHPersonalModuleItemType) {
init(icon: String? = nil, title: String, desc: String = "", isShowRedPoint:Bool = false, type:YHPersonalModuleItemType) {
self.icon = icon
self.title = title
self.desc = desc
self.isShowRedPoint = isShowRedPoint
self.type = type
}
......
//
// YHMyFunctionGroup2Cell.swift
// galaxy
//
// Created by Dufet on 2025/2/13.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMyFunctionGroup2Cell: UITableViewCell {
static let cellReuseIdentifier = "YHMyFunctionGroup2Cell"
static let itemHeight = 74.0
func updateGroup(_ group: YHFunctionGroupInfo) {
groupArr = group.arr
}
var groupArr: [PersonalModuleItem] = [] {
didSet {
let countPerRow = 2
let rowHeight = Self.itemHeight
var listHeight = rowHeight
if groupArr.count%countPerRow == 0 {
listHeight = rowHeight * Double(groupArr.count/countPerRow)
} else {
listHeight = rowHeight * Double(groupArr.count/countPerRow + 1)
}
collectionView.snp.updateConstraints { make in
make.height.equalTo(listHeight)
}
collectionView.reloadData()
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var collectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout()
flowLayout.minimumInteritemSpacing = 10.0
flowLayout.minimumLineSpacing = 0.0
flowLayout.scrollDirection = .vertical
let collectView = UICollectionView(frame:.zero, collectionViewLayout: flowLayout)
collectView.backgroundColor = .clear
collectView.delegate = self
collectView.dataSource = self
collectView.register(YHMyFunctionGroupItem2Cell.self, forCellWithReuseIdentifier: YHMyFunctionGroupItem2Cell.cellReuseIdentifier)
collectView.contentInset = .zero
collectView.showsVerticalScrollIndicator = false
collectView.contentInsetAdjustmentBehavior = .never
return collectView
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupUI() {
self.selectionStyle = .none
self.backgroundColor = .clear
contentView.backgroundColor = .clear
contentView.addSubview(collectionView)
collectionView.snp.makeConstraints { make in
make.top.equalTo(16)
make.bottom.equalTo(-16)
make.left.right.equalToSuperview()
make.height.equalTo(Self.itemHeight)
}
}
}
extension YHMyFunctionGroup2Cell: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
// 返回单元格数量
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return groupArr.count
}
// 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = floor((KScreenWidth-20.0*2.0-10.0)/2.0)
return CGSize(width: width, height: Self.itemHeight)
}
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHMyFunctionGroupItem2Cell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroupItem2Cell
if 0 <= indexPath.item && indexPath.item < groupArr.count {
let item: PersonalModuleItem = groupArr[indexPath.item]
cell.updateItem(item)
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
}
}
//
// YHMyFunctionGroupItem2Cell.swift
// galaxy
//
// Created by Dufet on 2025/2/13.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMyFunctionGroupItem2Cell: UICollectionViewCell {
static let cellReuseIdentifier = "YHMyFunctionGroupItem2Cell"
func updateItem(_ item : PersonalModuleItem) {
titleLabel.text = item.title
descLabel.text = item.desc
if let icon = item.icon, !icon.isEmpty {
iconImgView.image = UIImage(named:icon)
} else {
iconImgView.image = nil
}
}
lazy var whiteView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = 4.0
view.clipsToBounds = true
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = .mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize: 14)
return label
}()
lazy var descLabel: UILabel = {
let label = UILabel()
label.textColor = .init(UIColor(hex: 0x8993A2))
label.textAlignment = .left
label.font = UIFont.PFSC_R(ofSize: 12)
return label
}()
lazy var iconImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: ""))
return v
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
func setupUI() {
self.contentView.addSubview(whiteView)
self.whiteView.addSubview(titleLabel)
self.whiteView.addSubview(descLabel)
self.whiteView.addSubview(iconImgView)
whiteView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
iconImgView.snp.makeConstraints { make in
make.left.equalTo(12)
make.width.height.equalTo(42)
make.centerY.equalToSuperview()
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(iconImgView.snp.right).offset(8)
make.right.equalTo(-8)
make.top.equalTo(iconImgView)
make.right.equalTo(-8)
make.height.equalTo(20)
}
descLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.top.equalTo(titleLabel.snp.bottom).offset(2)
make.height.equalTo(17)
make.right.equalTo(-8)
}
}
}
//
// YHMySectionGroupItemCellCollectionViewCell.swift
// galaxy
//
// Created by Dufet on 2025/2/13.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMyFunctionGroupItemCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHMyFunctionGroupItemCell"
func updateItem(_ item : PersonalModuleItem) {
titleLabel.text = item.title
if let icon = item.icon, !icon.isEmpty {
iconImgView.image = UIImage(named:icon)
} else {
iconImgView.image = nil
}
}
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = .mainTextColor
label.textAlignment = .center
label.font = UIFont.PFSC_R(ofSize: 12)
return label
}()
lazy var iconImgView: UIImageView = {
let v = UIImageView(image: UIImage(named: ""))
return v
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
func setupUI() {
self.contentView.addSubview(titleLabel)
self.contentView.addSubview(iconImgView)
iconImgView.snp.makeConstraints { make in
make.top.equalTo(20)
make.width.height.equalTo(24)
make.centerX.equalToSuperview()
}
titleLabel.snp.makeConstraints { make in
make.top.equalTo(iconImgView.snp.bottom).offset(8)
make.height.equalTo(18)
make.left.right.equalToSuperview()
}
}
}
//
// YHMySectionGroupCell.swift
// galaxy
//
// Created by Dufet on 2025/2/13.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMySectionGroupCell: UITableViewCell {
static let cellReuseIdentifier = "YHMySectionGroupCell"
func updateGroup(_ group: YHFunctionGroupInfo) {
titleLabel.text = group.title
groupArr = group.arr
}
var groupArr: [PersonalModuleItem] = [] {
didSet {
let countPerRow = 4
let rowHeight = 90.0
var listHeight = rowHeight
if groupArr.count%countPerRow == 0 {
listHeight = rowHeight * Double(groupArr.count/countPerRow)
} else {
listHeight = rowHeight * Double(groupArr.count/countPerRow + 1)
}
collectionView.snp.updateConstraints { make in
make.height.equalTo(listHeight)
}
collectionView.reloadData()
self.setNeedsLayout()
self.layoutIfNeeded()
}
}
lazy var whiteView: UIView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = 4.0
view.clipsToBounds = true
return view
}()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = .mainTextColor
label.textAlignment = .left
label.font = UIFont.PFSC_M(ofSize: 14)
return label
}()
lazy var collectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout()
flowLayout.minimumInteritemSpacing = 0.0
flowLayout.minimumLineSpacing = 0.0
flowLayout.scrollDirection = .vertical
let collectView = UICollectionView(frame:.zero, collectionViewLayout: flowLayout)
collectView.backgroundColor = .clear
collectView.delegate = self
collectView.dataSource = self
collectView.register(YHMyFunctionGroupItemCell.self, forCellWithReuseIdentifier: YHMyFunctionGroupItemCell.cellReuseIdentifier)
collectView.contentInset = .zero
collectView.showsVerticalScrollIndicator = false
collectView.contentInsetAdjustmentBehavior = .never
return collectView
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupUI() {
self.selectionStyle = .none
self.backgroundColor = .clear
contentView.backgroundColor = .clear
contentView.addSubview(whiteView)
whiteView.addSubview(titleLabel)
whiteView.addSubview(collectionView)
whiteView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalTo(-16)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(16)
make.height.equalTo(20)
}
collectionView.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(0)
make.bottom.left.right.equalToSuperview()
make.height.equalTo(90)
}
}
}
extension YHMySectionGroupCell: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
// 返回单元格数量
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return groupArr.count
}
// 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = floor((KScreenWidth-20.0*2.0)/4.0)
return CGSize(width: width, height: 90.0)
}
// 返回自定义单元格
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHMyFunctionGroupItemCell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroupItemCell
if 0 <= indexPath.item && indexPath.item < groupArr.count {
let item: PersonalModuleItem = groupArr[indexPath.item]
cell.updateItem(item)
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
}
}
//
// YHMyUserInfoView.swift
// galaxy
//
// Created by Dufet on 2025/2/13.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMyUserInfoView: UIView {
static let likeTag = 9527
static let collectTag = 9528
static let scanTag = 9529
var avatarClickBlock:(()->Void)?
var nickNameClickBlock:(()->Void)?
var likeClick:(()->Void)?
var collectClick:(()->Void)?
var recentScanClick:(()->Void)?
lazy var contentView: UIView = {
let view = UIView()
return view
}()
lazy var avarImgView:UIImageView = {
let imgView = UIImageView(image: UIImage(named: "mine_head_logout"))
imgView.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(didAvarImgViewTapped))
imgView.addGestureRecognizer(tap)
imgView.layer.cornerRadius = 27.0
imgView.contentMode = .scaleAspectFill
imgView.clipsToBounds = true
return imgView
}()
private lazy var userNameLabel:UILabel = {
let label = UILabel()
label.text = "登录/注册".local
label.textColor = .mainTextColor
label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_M(ofSize: 21)
label.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(didNickNameTapped))
label.addGestureRecognizer(tap)
return label
}()
private lazy var likeLabel:UILabel = {
let label = UILabel()
label.text = "点赞 0".local
label.textColor = UIColor.mainTextColor50
label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_R(ofSize: 13)
label.isUserInteractionEnabled = true
label.tag = Self.likeTag
let tap = UITapGestureRecognizer(target: self, action: #selector(tap(gestureRecognizer:)))
label.addGestureRecognizer(tap)
return label
}()
private lazy var collectLabel:UILabel = {
let label = UILabel()
label.text = "收藏 0".local
label.textColor = UIColor.mainTextColor50
label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_R(ofSize: 13)
label.isUserInteractionEnabled = true
label.tag = Self.collectTag
let tap = UITapGestureRecognizer(target: self, action: #selector(tap(gestureRecognizer:)))
label.addGestureRecognizer(tap)
return label
}()
private lazy var scanLabel:UILabel = {
let label = UILabel()
label.text = "最近浏览 0".local
label.textColor = UIColor.mainTextColor50
label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_R(ofSize: 13)
label.isUserInteractionEnabled = true
label.tag = Self.scanTag
let tap = UITapGestureRecognizer(target: self, action: #selector(tap(gestureRecognizer:)))
label.addGestureRecognizer(tap)
return label
}()
private lazy var line1View:UIView = {
let line = UIView()
line.backgroundColor = UIColor(hex:0x92959D, alpha: 0.2)
return line
}()
private lazy var line2View:UIView = {
let line = UIView()
line.backgroundColor = UIColor(hex:0x92959D, alpha: 0.2)
return line
}()
lazy var arrowImgView: UIImageView = {
let imgV = UIImageView()
imgV.image = UIImage(named: "form_right_arrow")
return imgV
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.clipsToBounds = true
createUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
static func createView() -> YHMyUserInfoView {
let view = YHMyUserInfoView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height:107))
return view
}
private func createUI() {
self.addSubview(contentView)
contentView.addSubview(avarImgView)
contentView.addSubview(userNameLabel)
contentView.addSubview(likeLabel)
contentView.addSubview(collectLabel)
contentView.addSubview(scanLabel)
contentView.addSubview(line1View)
contentView.addSubview(line2View)
contentView.addSubview(arrowImgView)
contentView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(54)
make.top.equalTo(21)
make.bottom.equalTo(-31)
}
avarImgView.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 55, height: 55))
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(0)
}
userNameLabel.snp.makeConstraints { make in
make.left.equalTo(avarImgView.snp.right).offset(16)
make.top.equalTo(avarImgView)
make.right.equalTo(arrowImgView.snp.left)
make.height.equalTo(29.0)
}
likeLabel.snp.makeConstraints { make in
make.left.equalTo(userNameLabel)
make.right.equalTo(line1View.snp.left).offset(-12)
make.height.equalTo(17.0)
make.top.equalTo(userNameLabel.snp.bottom).offset(6)
}
likeLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
likeLabel.setContentHuggingPriority(.required, for: .horizontal)
line1View.snp.makeConstraints { make in
make.centerY.equalTo(likeLabel)
make.size.equalTo(CGSize(width: 1, height: 12))
}
collectLabel.snp.makeConstraints { make in
make.left.equalTo(line1View.snp.right).offset(12)
make.right.equalTo(line2View.snp.left).offset(-12)
make.height.equalTo(17.0)
make.top.equalTo(likeLabel)
}
collectLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
collectLabel.setContentHuggingPriority(.required, for: .horizontal)
line2View.snp.makeConstraints { make in
make.centerY.equalTo(likeLabel)
make.size.equalTo(CGSize(width: 1, height: 12))
}
scanLabel.snp.makeConstraints { make in
make.left.equalTo(line2View.snp.right).offset(12)
make.right.equalTo(arrowImgView.snp.left)
make.height.equalTo(17.0)
make.top.equalTo(likeLabel)
}
scanLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
arrowImgView.snp.makeConstraints { make in
make.width.height.equalTo(20)
make.centerY.equalToSuperview()
make.right.equalTo(0)
}
update(count: 0, label: likeLabel)
update(count: 0, label: collectLabel)
update(count: 0, label: scanLabel)
}
func update(count: Int, label: UILabel) {
var text = ""
var count = "\(count) "
if label.tag == Self.likeTag {
text = "点赞"
} else if label.tag == Self.collectTag {
text = "收藏"
} else if label.tag == Self.scanTag {
text = "最近浏览"
}
let attrStr = NSMutableAttributedString(string: "")
let countAttrStr = NSAttributedString(
string: count,
attributes: [NSAttributedString.Key.foregroundColor: UIColor.mainTextColor,
NSAttributedString.Key.font: UIFont(name: "DINAlternate-Bold", size: 14)!])
let titleAttrStr = NSAttributedString(
string: text,
attributes: [NSAttributedString.Key.foregroundColor: UIColor.init(hex: 0x435163),
NSAttributedString.Key.font: UIFont.PFSC_R(ofSize: 12)])
attrStr.append(countAttrStr)
attrStr.append(titleAttrStr)
label.attributedText = attrStr
}
@objc func tap(gestureRecognizer:UITapGestureRecognizer) {
if let view = gestureRecognizer.view {
if view.tag == Self.likeTag {
self.likeClick?()
} else if view.tag == Self.collectTag {
self.collectClick?()
} else if view.tag == Self.scanTag {
self.recentScanClick?()
}
}
}
@objc func didAvarImgViewTapped() {
if let avatarClickBlock = avatarClickBlock {
avatarClickBlock()
}
}
@objc func didNickNameTapped() {
if let nickNameClickBlock = nickNameClickBlock {
nickNameClickBlock()
}
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "头部背景图@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "头部背景图@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 2033197226@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197226@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 2033197220@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197220@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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