Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
c2dff21e
Commit
c2dff21e
authored
Sep 30, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的资源优化
parent
55ceadf2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
86 deletions
+56
-86
YHResourceViewController.swift
...mmunity(社区)/Resource(资源)/C/YHResourceViewController.swift
+4
-5
YHResourceListModel.swift
...es/Community(社区)/Resource(资源)/M/YHResourceListModel.swift
+16
-48
YHResourceCategoryView.swift
...Community(社区)/Resource(资源)/V/YHResourceCategoryView.swift
+4
-4
YHResourceTableViewCell.swift
...ommunity(社区)/Resource(资源)/V/YHResourceTableViewCell.swift
+32
-26
YHResourceViewModel.swift
...s/Community(社区)/Resource(资源)/VM/YHResourceViewModel.swift
+0
-3
No files found.
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/C/YHResourceViewController.swift
View file @
c2dff21e
...
...
@@ -279,11 +279,6 @@ private extension YHResourceViewController {
}
if
!
result
.
isEmpty
{
// 计算每个模型的高度参数
for
item
in
result
{
item
.
calHeightParam
()
}
self
.
viewModel
.
arrResourceData
=
result
self
.
updateUI
()
}
...
...
@@ -469,7 +464,11 @@ private extension YHResourceViewController {
return
}
YHGrayCommonAlertView
.
show
(
"需联系银河管家进行发布信息"
,
"联系银河管家发布企业服务与企业需求,快来与我们联系吧~"
,
"返回"
,
"前往联系"
,
fullGuestureEnable
:
false
)
{
//
}
callBack
:
{
//
}
}
func
selectFilterType
(
_
type
:
YHResourceFilterType
)
{
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/M/YHResourceListModel.swift
View file @
c2dff21e
...
...
@@ -14,6 +14,8 @@ class YHResourceListModel: SmartCodable {
required
init
()
{}
var
needNewLine
:
Bool
?
// MARK: - 基本信息
var
id
:
String
=
""
var
title
:
String
=
""
...
...
@@ -162,54 +164,20 @@ class YHResourceListModel: SmartCodable {
}
// MARK: - 计算Cell高度方法
func
calHeightParam
()
{
let
screenWidth
=
KScreenWidth
let
cellWidth
=
(
screenWidth
-
47
)
/
2
var
totalHeight
:
CGFloat
=
60
+
20
+
44
// 基础高度
// 标题高度
if
!
title
.
isEmpty
{
let
titleFont
=
UIFont
.
PFSC_M
(
ofSize
:
16
)
??
UIFont
.
systemFont
(
ofSize
:
16
)
let
maxSize
=
CGSize
(
width
:
cellWidth
-
24
,
height
:
CGFloat
.
greatestFiniteMagnitude
)
let
titleRect
=
title
.
boundingRect
(
with
:
maxSize
,
options
:
[
.
usesLineFragmentOrigin
,
.
usesFontLeading
],
attributes
:
[
.
font
:
titleFont
],
context
:
nil
)
totalHeight
+=
ceil
(
titleRect
.
height
)
+
8
}
// 内容高度
if
!
content
.
isEmpty
{
let
contentFont
=
UIFont
.
PFSC_R
(
ofSize
:
13
)
??
UIFont
.
systemFont
(
ofSize
:
13
)
let
maxSize
=
CGSize
(
width
:
cellWidth
-
24
,
height
:
CGFloat
.
greatestFiniteMagnitude
)
let
textRect
=
content
.
boundingRect
(
with
:
maxSize
,
options
:
[
.
usesLineFragmentOrigin
,
.
usesFontLeading
],
attributes
:
[
.
font
:
contentFont
],
context
:
nil
)
totalHeight
+=
min
(
ceil
(
textRect
.
height
),
40
)
+
8
// 限制最大高度为2行
}
// 图片高度
if
!
images
.
isEmpty
{
let
imageHeight
:
CGFloat
=
100
totalHeight
+=
imageHeight
+
8
}
// 标签高度
if
!
tags
.
isEmpty
{
totalHeight
+=
20
+
8
}
// 底部信息高度
totalHeight
+=
30
self
.
cell_width
=
cellWidth
self
.
cell_height
=
max
(
totalHeight
,
160
)
// 最小高度160
func
didFinishMapping
()
{
if
needNewLine
==
nil
{
needNewLine
=
calculateNeedNewLine
()
}
}
func
calculateNeedNewLine
()
->
Bool
{
let
company
=
company_name
.
count
>
0
?
company_name
:
"-"
let
categoryName
=
category_name
.
count
>
0
?
category_name
:
"-"
let
companyWidth
=
YHResourceTableViewCell
.
getLabelWidth
(
company
)
let
categoryNameWidth
=
YHResourceTableViewCell
.
getLabelWidth
(
categoryName
)
return
companyWidth
+
categoryNameWidth
>=
KScreenWidth
-
YHResourceTableViewCell
.
logoWidth
-
YHResourceTableViewCell
.
logoToRight
-
YHResourceTableViewCell
.
arrowWidth
-
2
*
YHResourceTableViewCell
.
marginX
-
YHResourceTableViewCell
.
widthVLine
-
YHResourceTableViewCell
.
marginBetweenVLine
*
2
}
// MARK: - 便利方法
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceCategoryView.swift
View file @
c2dff21e
...
...
@@ -267,10 +267,10 @@ extension YHResourceCategoryView: UICollectionViewDataSource, UICollectionViewDe
selectedCategories
.
append
(
category
)
}
// 如果没有选中任何分类,自动选中"全部行业"
if
selectedCategories
.
isEmpty
{
selectedCategories
.
append
(
categories
.
first
!
)
}
//
// 如果没有选中任何分类,自动选中"全部行业"
//
if selectedCategories.isEmpty {
//
selectedCategories.append(categories.first!)
//
}
}
collectionView
.
reloadData
()
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/V/YHResourceTableViewCell.swift
View file @
c2dff21e
...
...
@@ -12,13 +12,13 @@ import Kingfisher
class
YHResourceTableViewCell
:
UITableViewCell
{
static
let
labelFont
=
UIFont
.
PFSC_R
(
ofSize
:
14
)
static
let
labelHeight
:
CGFloat
=
20.0
private
let
marginX
:
CGFloat
=
20.0
private
let
logoWidth
:
CGFloat
=
60.0
private
let
logoToRight
:
CGFloat
=
10.0
private
let
marginBetweenVLine
:
CGFloat
=
6.0
private
let
widthVLine
:
CGFloat
=
1
private
let
arrowWidth
:
CGFloat
=
24
private
let
arrowToLeft
:
CGFloat
=
24
static
let
marginX
:
CGFloat
=
20.0
static
let
logoWidth
:
CGFloat
=
60.0
static
let
logoToRight
:
CGFloat
=
10.0
static
let
marginBetweenVLine
:
CGFloat
=
6.0
static
let
widthVLine
:
CGFloat
=
1
static
let
arrowWidth
:
CGFloat
=
24
static
let
arrowToLeft
:
CGFloat
=
24
static
let
cellReuseIdentifier
=
"YHResourceTableViewCell"
...
...
@@ -106,9 +106,9 @@ class YHResourceTableViewCell: UITableViewCell {
}
// MARK: - 私有方法
private
extension
YHResourceTableViewCell
{
extension
YHResourceTableViewCell
{
func
setupUI
()
{
private
func
setupUI
()
{
backgroundColor
=
.
white
selectionStyle
=
.
none
...
...
@@ -124,17 +124,17 @@ private extension YHResourceTableViewCell {
setupConstraints
()
}
func
setupConstraints
()
{
private
func
setupConstraints
()
{
// LOGO约束
logoImageView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalToSuperview
()
.
offset
(
marginX
)
make
.
left
.
equalToSuperview
()
.
offset
(
YHResourceTableViewCell
.
marginX
)
make
.
top
.
equalToSuperview
()
.
offset
(
24
)
make
.
width
.
height
.
equalTo
(
logoWidth
)
make
.
width
.
height
.
equalTo
(
YHResourceTableViewCell
.
logoWidth
)
}
// 右上角标签约束
typeTagIcon
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
logoImageView
.
snp
.
right
)
.
offset
(
logoToRight
)
make
.
left
.
equalTo
(
logoImageView
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
logoToRight
)
make
.
top
.
equalTo
(
logoImageView
)
make
.
height
.
equalTo
(
16
)
make
.
width
.
equalTo
(
52
)
...
...
@@ -142,14 +142,14 @@ private extension YHResourceTableViewCell {
// 主标题约束
titleLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
logoImageView
.
snp
.
right
)
.
offset
(
logoToRight
)
make
.
left
.
equalTo
(
logoImageView
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
logoToRight
)
make
.
right
.
equalTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
typeTagIcon
.
snp
.
bottom
)
.
offset
(
4
)
}
rightArrow
.
snp
.
makeConstraints
{
make
in
make
.
right
.
equalToSuperview
()
.
offset
(
-
marginX
)
make
.
width
.
height
.
equalTo
(
arrowWidth
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
YHResourceTableViewCell
.
marginX
)
make
.
width
.
height
.
equalTo
(
YHResourceTableViewCell
.
arrowWidth
)
make
.
top
.
equalTo
(
titleLabel
)
}
...
...
@@ -160,7 +160,7 @@ private extension YHResourceTableViewCell {
}
vSeparatorLine
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
companyLabel
.
snp
.
right
)
.
offset
(
marginBetweenVLine
)
make
.
left
.
equalTo
(
companyLabel
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
centerY
.
equalTo
(
companyLabel
)
make
.
width
.
equalTo
(
1
)
make
.
height
.
equalTo
(
8
)
...
...
@@ -168,7 +168,7 @@ private extension YHResourceTableViewCell {
// 行业标签约束
industryLabel
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
marginBetweenVLine
)
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
right
.
lessThanOrEqualTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
companyLabel
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
32
)
...
...
@@ -182,13 +182,13 @@ private extension YHResourceTableViewCell {
}
}
private
func
getLabelWidth
(
_
text
:
String
)
->
CGFloat
{
static
func
getLabelWidth
(
_
text
:
String
)
->
CGFloat
{
let
attrString
=
NSAttributedString
(
string
:
text
,
attributes
:
[
.
font
:
YHResourceTableViewCell
.
labelFont
])
let
width
=
attrString
.
yh_width
(
containerHeight
:
YHResourceTableViewCell
.
labelHeight
)
return
width
}
func
updateUI
()
{
private
func
updateUI
()
{
guard
let
model
=
resourceModel
else
{
return
}
// 设置基本信息
...
...
@@ -198,16 +198,22 @@ private extension YHResourceTableViewCell {
titleLabel
.
text
=
title
companyLabel
.
text
=
company
industryLabel
.
text
=
categoryName
let
companyWidth
=
getLabelWidth
(
company
)
let
categoryNameWidth
=
getLabelWidth
(
categoryName
)
if
companyWidth
+
categoryNameWidth
<
KScreenWidth
-
logoWidth
-
logoToRight
-
arrowWidth
-
2
*
marginX
-
widthVLine
-
marginBetweenVLine
*
2
{
var
needNext
=
false
if
let
needNewLine
=
model
.
needNewLine
{
needNext
=
needNewLine
}
else
{
let
needNewLine
=
model
.
calculateNeedNewLine
()
model
.
needNewLine
=
needNewLine
needNext
=
needNewLine
}
if
!
needNext
{
companyLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
titleLabel
)
make
.
top
.
equalTo
(
titleLabel
.
snp
.
bottom
)
.
offset
(
4
)
}
vSeparatorLine
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
companyLabel
.
snp
.
right
)
.
offset
(
marginBetweenVLine
)
make
.
left
.
equalTo
(
companyLabel
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
centerY
.
equalTo
(
companyLabel
)
make
.
width
.
equalTo
(
1
)
make
.
height
.
equalTo
(
8
)
...
...
@@ -215,7 +221,7 @@ private extension YHResourceTableViewCell {
// 行业标签约束
industryLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
marginBetweenVLine
)
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
right
.
lessThanOrEqualTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
companyLabel
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
32
)
...
...
@@ -236,7 +242,7 @@ private extension YHResourceTableViewCell {
// 行业标签约束
industryLabel
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
marginBetweenVLine
)
make
.
left
.
equalTo
(
vSeparatorLine
.
snp
.
right
)
.
offset
(
YHResourceTableViewCell
.
marginBetweenVLine
)
make
.
right
.
lessThanOrEqualTo
(
rightArrow
.
snp
.
left
)
make
.
top
.
equalTo
(
companyLabel
.
snp
.
bottom
)
.
offset
(
4
)
make
.
bottom
.
equalToSuperview
()
.
offset
(
-
32
)
...
...
galaxy/galaxy/Classes/Modules/Community(社区)/Resource(资源)/VM/YHResourceViewModel.swift
View file @
c2dff21e
...
...
@@ -72,9 +72,6 @@ class YHResourceViewModel: NSObject {
self
.
arrResourceData
?
.
append
(
contentsOf
:
mockData
)
}
// 计算每个模型的高度参数
self
.
arrResourceData
?
.
forEach
{
$0
.
calHeightParam
()
}
self
.
currentPage
+=
1
self
.
hasMoreForResource
=
self
.
currentPage
<=
5
// 模拟5页数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment