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
7cfb06d0
Commit
7cfb06d0
authored
Jun 26, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 兴趣话题
parent
327469b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
16 deletions
+57
-16
YHInterestTopicLayout.swift
...asses/Modules/Community(社区)/V/YHInterestTopicLayout.swift
+43
-1
YHMyInterestTopicCell.swift
...asses/Modules/Community(社区)/V/YHMyInterestTopicCell.swift
+14
-15
No files found.
galaxy/galaxy/Classes/Modules/Community(社区)/V/YHInterestTopicLayout.swift
View file @
7cfb06d0
...
...
@@ -9,7 +9,9 @@
import
UIKit
class
YHInterestTopicLayout
:
UICollectionViewFlowLayout
{
var
dataSource
:[
String
]
=
[]
weak
var
layoutDelegate
:
UICollectionViewDelegateFlowLayout
?
=
nil
var
interItemSpacing
:
CGFloat
=
12.0
// 相邻单元格之间的水平间距
override
func
prepare
()
{
super
.
prepare
()
...
...
@@ -48,4 +50,44 @@ class YHInterestTopicLayout: UICollectionViewFlowLayout {
}
return
arrCell
}
override
var
collectionViewContentSize
:
CGSize
{
get
{
let
width
=
self
.
collectionView
?
.
width
??
0.0
let
height
=
self
.
calculateHeight
()
return
CGSize
(
width
:
width
,
height
:
height
)
}
}
func
calculateHeight
()
->
CGFloat
{
if
self
.
dataSource
.
count
<=
0
{
return
0.0
}
guard
let
delegate
=
self
.
layoutDelegate
else
{
return
0.0
}
let
itemHeight
=
24.0
var
currentX
=
0.0
var
height
=
itemHeight
for
(
index
,
_
)
in
self
.
dataSource
.
enumerated
()
{
if
delegate
.
responds
(
to
:
#selector(
UICollectionViewDelegateFlowLayout.collectionView(_:layout:sizeForItemAt:)
)
)
{
let
size
=
delegate
.
collectionView
!
(
self
.
collectionView
!
,
layout
:
self
,
sizeForItemAt
:
IndexPath
(
item
:
index
,
section
:
0
))
if
index
==
0
{
currentX
=
size
.
width
height
=
itemHeight
}
else
{
let
targetX
=
currentX
+
self
.
minimumInteritemSpacing
+
size
.
width
if
targetX
<=
self
.
collectionView
!.
width
{
currentX
=
targetX
}
else
{
currentX
=
0
height
+=
self
.
minimumLineSpacing
+
itemHeight
}
}
}
}
return
height
}
}
galaxy/galaxy/Classes/Modules/Community(社区)/V/YHMyInterestTopicCell.swift
View file @
7cfb06d0
...
...
@@ -49,7 +49,6 @@ class YHMyInterestTopicCell: UITableViewCell {
typealias
EditBlock
=
()
->
()
var
editBlock
:
EditBlock
?
static
let
cellReuseIdentifier
=
"YHMyInterestTopicCell"
weak
var
tableView
:
UITableView
?
var
topicArr
:[
String
]
=
[]
var
userModel
:
YHUserNameCardInfo
=
YHUserNameCardInfo
()
{
didSet
{
...
...
@@ -71,23 +70,21 @@ class YHMyInterestTopicCell: UITableViewCell {
if
self
.
userModel
.
topics
.
count
>
0
{
self
.
topicArr
.
append
(
contentsOf
:
self
.
userModel
.
topics
)
}
self
.
layout
.
dataSource
=
self
.
topicArr
self
.
collectionView
.
reloadData
{
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.5
,
execute
:
{
let
height
=
self
.
collectionView
.
contentSize
.
height
self
.
collectionView
.
snp
.
remakeConstraints
{
make
in
make
.
height
.
equalTo
(
height
)
make
.
left
.
equalTo
(
16
)
make
.
right
.
equalTo
(
-
16
)
make
.
bottom
.
equalTo
(
-
16
)
make
.
top
.
equalTo
(
self
.
titleLabel
.
snp
.
bottom
)
.
offset
(
12
)
}
self
.
detailLabel
.
snp
.
removeConstraints
()
self
.
superview
?
.
setNeedsLayout
()
self
.
superview
?
.
layoutIfNeeded
()
})
let
height
=
self
.
layout
.
collectionViewContentSize
.
height
printLog
(
"ABC:
\(
height
)
"
)
self
.
collectionView
.
snp
.
remakeConstraints
{
make
in
make
.
height
.
equalTo
(
height
)
make
.
left
.
equalTo
(
16
)
make
.
right
.
equalTo
(
-
16
)
make
.
bottom
.
equalTo
(
-
16
)
make
.
top
.
equalTo
(
self
.
titleLabel
.
snp
.
bottom
)
.
offset
(
12
)
}
}
self
.
detailLabel
.
snp
.
removeConstraints
()
}
else
{
self
.
detailLabel
.
snp
.
remakeConstraints
{
make
in
...
...
@@ -131,6 +128,8 @@ class YHMyInterestTopicCell: UITableViewCell {
lazy
var
layout
:
YHInterestTopicLayout
=
{
let
layout
=
YHInterestTopicLayout
()
layout
.
scrollDirection
=
.
vertical
layout
.
dataSource
=
self
.
topicArr
layout
.
layoutDelegate
=
self
return
layout
}()
...
...
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