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
25b0487d
Commit
25b0487d
authored
Jan 02, 2025
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
无状态UI
parent
acbc09fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
22 deletions
+46
-22
YHLifeViewController.swift
...es/Modules/Home(首页)/Life(生活)/C/YHLifeViewController.swift
+46
-22
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/Life(生活)/C/YHLifeViewController.swift
View file @
25b0487d
...
@@ -32,6 +32,7 @@ class YHLifeViewController: YHBaseViewController {
...
@@ -32,6 +32,7 @@ class YHLifeViewController: YHBaseViewController {
collectinoView
.
backgroundColor
=
.
white
collectinoView
.
backgroundColor
=
.
white
// collectinoView.contentInset = UIEdgeInsets(top: 16, left: 20, bottom: 0, right: 20)
// collectinoView.contentInset = UIEdgeInsets(top: 16, left: 20, bottom: 0, right: 20)
collectinoView
.
register
(
YHLookCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
YHLookCollectionViewCell
.
cellReuseIdentifier
)
collectinoView
.
register
(
YHLookCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
YHLookCollectionViewCell
.
cellReuseIdentifier
)
collectinoView
.
register
(
YHLookNodataCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
YHLookNodataCollectionViewCell
.
cellReuseIdentifier
)
collectinoView
.
register
(
YHlifeCollectionReusableView
.
self
,
forSupplementaryViewOfKind
:
UICollectionView
.
elementKindSectionFooter
,
withReuseIdentifier
:
YHlifeCollectionReusableView
.
reuseIdentifier
)
collectinoView
.
register
(
YHlifeCollectionReusableView
.
self
,
forSupplementaryViewOfKind
:
UICollectionView
.
elementKindSectionFooter
,
withReuseIdentifier
:
YHlifeCollectionReusableView
.
reuseIdentifier
)
collectinoView
.
delegate
=
self
collectinoView
.
delegate
=
self
collectinoView
.
dataSource
=
self
collectinoView
.
dataSource
=
self
...
@@ -42,12 +43,6 @@ class YHLifeViewController: YHBaseViewController {
...
@@ -42,12 +43,6 @@ class YHLifeViewController: YHBaseViewController {
return
collectinoView
return
collectinoView
}()
}()
lazy
var
noDataView
:
YHEmptyDataView
=
{
let
view
=
YHEmptyDataView
.
createView
(
"暂无直播"
,
kEmptyCommonBgName
)
view
.
isHidden
=
true
return
view
}()
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
...
@@ -89,13 +84,6 @@ extension YHLifeViewController {
...
@@ -89,13 +84,6 @@ extension YHLifeViewController {
self
.
viewModel
.
getLiveList
{[
weak
self
]
success
,
error
in
self
.
viewModel
.
getLiveList
{[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
myCollectView
.
reloadData
()
self
.
myCollectView
.
reloadData
()
if
hideFlag
{
if
self
.
viewModel
.
liveArr
.
count
==
0
{
noDataView
.
isHidden
=
false
}
else
{
noDataView
.
isHidden
=
true
}
}
}
}
self
.
viewModel
.
getSchedulLiveList
{[
weak
self
]
success
,
error
in
self
.
viewModel
.
getSchedulLiveList
{[
weak
self
]
success
,
error
in
...
@@ -200,21 +188,12 @@ extension YHLifeViewController {
...
@@ -200,21 +188,12 @@ extension YHLifeViewController {
make
.
right
.
equalToSuperview
()
.
offset
(
-
20
)
make
.
right
.
equalToSuperview
()
.
offset
(
-
20
)
}
}
view
.
addSubview
(
noDataView
)
noDataView
.
snp
.
makeConstraints
{
make
in
make
.
centerX
.
equalToSuperview
()
make
.
centerY
.
equalToSuperview
()
make
.
width
.
equalTo
(
KScreenWidth
)
make
.
height
.
equalTo
(
150
)
}
myCollectView
.
es
.
addYHPullToRefresh
{
myCollectView
.
es
.
addYHPullToRefresh
{
self
.
loadData
()
self
.
loadData
()
self
.
myCollectView
.
es
.
stopPullToRefresh
()
self
.
myCollectView
.
es
.
stopPullToRefresh
()
}
}
myCollectView
.
isHidden
=
!
hideFlag
myCollectView
.
isHidden
=
!
hideFlag
noDataView
.
isHidden
=
!
hideFlag
}
}
func
checkLogin
()
->
Bool
{
func
checkLogin
()
->
Bool
{
...
@@ -280,10 +259,17 @@ extension YHLifeViewController: JXSegmentedListContainerViewListDelegate {
...
@@ -280,10 +259,17 @@ extension YHLifeViewController: JXSegmentedListContainerViewListDelegate {
extension
YHLifeViewController
:
UICollectionViewDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegateFlowLayout
{
extension
YHLifeViewController
:
UICollectionViewDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegateFlowLayout
{
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
if
self
.
viewModel
.
liveArr
.
count
==
0
{
return
1
}
return
self
.
viewModel
.
liveArr
.
count
return
self
.
viewModel
.
liveArr
.
count
}
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
if
self
.
viewModel
.
liveArr
.
count
==
0
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
YHLookNodataCollectionViewCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHLookNodataCollectionViewCell
return
cell
}
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
YHLookCollectionViewCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHLookCollectionViewCell
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
YHLookCollectionViewCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHLookCollectionViewCell
cell
.
dataSource
=
self
.
viewModel
.
liveArr
[
indexPath
.
row
]
cell
.
dataSource
=
self
.
viewModel
.
liveArr
[
indexPath
.
row
]
...
@@ -321,6 +307,13 @@ extension YHLifeViewController: UICollectionViewDelegate, UICollectionViewDataSo
...
@@ -321,6 +307,13 @@ extension YHLifeViewController: UICollectionViewDelegate, UICollectionViewDataSo
}
}
return
CGSize
(
width
:
KScreenWidth
,
height
:
0
)
// 根据需要设置高度
return
CGSize
(
width
:
KScreenWidth
,
height
:
0
)
// 根据需要设置高度
}
}
func
collectionView
(
_
collectionView
:
UICollectionView
,
layout
collectionViewLayout
:
UICollectionViewLayout
,
sizeForItemAt
indexPath
:
IndexPath
)
->
CGSize
{
if
self
.
viewModel
.
liveArr
.
count
==
0
{
return
CGSize
(
width
:
KScreenWidth
-
40
,
height
:
250
)
}
return
CGSize
(
width
:
(
KScreenWidth
-
52
)
/
2
,
height
:
222
)
}
}
}
class
YHLookCollectionViewCell
:
UICollectionViewCell
{
class
YHLookCollectionViewCell
:
UICollectionViewCell
{
...
@@ -425,3 +418,34 @@ class YHLookCollectionViewCell: UICollectionViewCell {
...
@@ -425,3 +418,34 @@ class YHLookCollectionViewCell: UICollectionViewCell {
}
}
}
}
class
YHLookNodataCollectionViewCell
:
UICollectionViewCell
{
static
let
cellReuseIdentifier
=
"YHLookNodataCollectionViewCell"
lazy
var
noDataView
:
YHEmptyDataView
=
{
let
view
=
YHEmptyDataView
.
createView
(
"暂无直播"
,
kEmptyCommonBgName
)
return
view
}()
required
init
?(
coder
:
NSCoder
)
{
super
.
init
(
coder
:
coder
)
}
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
setupUI
()
}
private
func
setupUI
()
{
contentView
.
addSubview
(
noDataView
)
noDataView
.
snp
.
makeConstraints
{
make
in
make
.
centerX
.
equalToSuperview
()
make
.
centerY
.
equalToSuperview
()
make
.
width
.
equalToSuperview
()
make
.
height
.
equalTo
(
150
)
}
}
}
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