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
91fd43f4
Commit
91fd43f4
authored
Jul 25, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 首页身份
parent
2ec621ce
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
298 additions
and
256 deletions
+298
-256
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+4
-0
YHHomeIdentityListVC.swift
...axy/Classes/Modules/Home(首页)/C/YHHomeIdentityListVC.swift
+276
-0
YHHomeIdentityViewController.swift
...ses/Modules/Home(首页)/C/YHHomeIdentityViewController.swift
+18
-243
YHHomeIdentityCell.swift
...alaxy/Classes/Modules/Home(首页)/V/YHHomeIdentityCell.swift
+0
-13
No files found.
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
91fd43f4
...
@@ -270,6 +270,7 @@
...
@@ -270,6 +270,7 @@
0468D4312B5654C100CFB916
/* libresolv.tbd in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D42C2B56549200CFB916
/* libresolv.tbd */
;
};
0468D4312B5654C100CFB916
/* libresolv.tbd in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D42C2B56549200CFB916
/* libresolv.tbd */
;
};
0468D4362B57752F00CFB916
/* YHUserModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4352B57752F00CFB916
/* YHUserModel.swift */
;
};
0468D4362B57752F00CFB916
/* YHUserModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4352B57752F00CFB916
/* YHUserModel.swift */
;
};
0468D43A2B579EAC00CFB916
/* YHLoginViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4392B579EAC00CFB916
/* YHLoginViewModel.swift */
;
};
0468D43A2B579EAC00CFB916
/* YHLoginViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0468D4392B579EAC00CFB916
/* YHLoginViewModel.swift */
;
};
0472E25C2C521E64008EAB6E
/* YHHomeIdentityListVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
0472E25B2C521E64008EAB6E
/* YHHomeIdentityListVC.swift */
;
};
04754A952B96FF3D00F8ADCA
/* UITextField+Extension.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04754A942B96FF3D00F8ADCA
/* UITextField+Extension.swift */
;
};
04754A952B96FF3D00F8ADCA
/* UITextField+Extension.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
04754A942B96FF3D00F8ADCA
/* UITextField+Extension.swift */
;
};
047619E92BA9867100F45358
/* YHCountryHotView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
047619E82BA9867100F45358
/* YHCountryHotView.swift */
;
};
047619E92BA9867100F45358
/* YHCountryHotView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
047619E82BA9867100F45358
/* YHCountryHotView.swift */
;
};
047619ED2BA9B9C900F45358
/* area.plist in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
047619EC2BA9B9C900F45358
/* area.plist */
;
};
047619ED2BA9B9C900F45358
/* area.plist in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
047619EC2BA9B9C900F45358
/* area.plist */
;
};
...
@@ -889,6 +890,7 @@
...
@@ -889,6 +890,7 @@
046AB7762BD674170086C6F1
/* galaxy.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.entitlements
;
path
=
galaxy.entitlements
;
sourceTree
=
"<group>"
;
};
046AB7762BD674170086C6F1
/* galaxy.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.entitlements
;
path
=
galaxy.entitlements
;
sourceTree
=
"<group>"
;
};
046AB7772BD674170086C6F1
/* galaxyDebug.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.entitlements
;
path
=
galaxyDebug.entitlements
;
sourceTree
=
"<group>"
;
};
046AB7772BD674170086C6F1
/* galaxyDebug.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.entitlements
;
path
=
galaxyDebug.entitlements
;
sourceTree
=
"<group>"
;
};
046AB7782BD674170086C6F1
/* galaxyTestEnv.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.entitlements
;
path
=
galaxyTestEnv.entitlements
;
sourceTree
=
"<group>"
;
};
046AB7782BD674170086C6F1
/* galaxyTestEnv.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.entitlements
;
path
=
galaxyTestEnv.entitlements
;
sourceTree
=
"<group>"
;
};
0472E25B2C521E64008EAB6E
/* YHHomeIdentityListVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHHomeIdentityListVC.swift
;
sourceTree
=
"<group>"
;
};
04754A942B96FF3D00F8ADCA
/* UITextField+Extension.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"UITextField+Extension.swift"
;
sourceTree
=
"<group>"
;
};
04754A942B96FF3D00F8ADCA
/* UITextField+Extension.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"UITextField+Extension.swift"
;
sourceTree
=
"<group>"
;
};
047619E82BA9867100F45358
/* YHCountryHotView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHCountryHotView.swift
;
sourceTree
=
"<group>"
;
};
047619E82BA9867100F45358
/* YHCountryHotView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHCountryHotView.swift
;
sourceTree
=
"<group>"
;
};
047619EC2BA9B9C900F45358
/* area.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
area.plist
;
sourceTree
=
"<group>"
;
};
047619EC2BA9B9C900F45358
/* area.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
area.plist
;
sourceTree
=
"<group>"
;
};
...
@@ -2724,6 +2726,7 @@
...
@@ -2724,6 +2726,7 @@
A567E5762BD7643D00D5D5A0
/* YHHomePageViewController.swift */
,
A567E5762BD7643D00D5D5A0
/* YHHomePageViewController.swift */
,
A5000F502C3BC28B00843452
/* YHHomeHoldViewPageViewController.swift */
,
A5000F502C3BC28B00843452
/* YHHomeHoldViewPageViewController.swift */
,
04213B242C48C15400797900
/* YHHomeIdentityViewController.swift */
,
04213B242C48C15400797900
/* YHHomeIdentityViewController.swift */
,
0472E25B2C521E64008EAB6E
/* YHHomeIdentityListVC.swift */
,
04213B282C48EF5200797900
/* YHHomeInformationViewController.swift */
,
04213B282C48EF5200797900
/* YHHomeInformationViewController.swift */
,
04213B2E2C49154900797900
/* YHHomeInfoDetailContainerViewController.swift */
,
04213B2E2C49154900797900
/* YHHomeInfoDetailContainerViewController.swift */
,
04213B302C4917BD00797900
/* YHHomeInfoDetailViewController.swift */
,
04213B302C4917BD00797900
/* YHHomeInfoDetailViewController.swift */
,
...
@@ -3431,6 +3434,7 @@
...
@@ -3431,6 +3434,7 @@
044867B82BA1C75700DFAD4A
/* YHCertificateUploadFailTipsView.swift in Sources */
,
044867B82BA1C75700DFAD4A
/* YHCertificateUploadFailTipsView.swift in Sources */
,
044D0C062C22736F00C5CF5E
/* YHSetExplainView.swift in Sources */
,
044D0C062C22736F00C5CF5E
/* YHSetExplainView.swift in Sources */
,
04213B252C48C15400797900
/* YHHomeIdentityViewController.swift in Sources */
,
04213B252C48C15400797900
/* YHHomeIdentityViewController.swift in Sources */
,
0472E25C2C521E64008EAB6E
/* YHHomeIdentityListVC.swift in Sources */
,
045EEF002B9F171A0022A143
/* YHFormItemEnterDetailCell.swift in Sources */
,
045EEF002B9F171A0022A143
/* YHFormItemEnterDetailCell.swift in Sources */
,
04213B352C4F85A900797900
/* YHHomeLifeCategoryModel.swift in Sources */
,
04213B352C4F85A900797900
/* YHHomeLifeCategoryModel.swift in Sources */
,
04FB01CE2C23DDBD0040115D
/* YHPeopleMatchNoDataView.swift in Sources */
,
04FB01CE2C23DDBD0040115D
/* YHPeopleMatchNoDataView.swift in Sources */
,
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeIdentityListVC.swift
0 → 100644
View file @
91fd43f4
//
// YHHomeIdentityListVC.swift
// galaxy
//
// Created by edy on 2024/7/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
import
JXSegmentedView
class
YHHomeIdentityItem
{
var
url
:
String
=
""
var
img
:
UIImage
?
=
nil
var
imgView
:
UIImageView
=
UIImageView
()
func
getSize
()
->
CGSize
{
if
let
img
=
self
.
img
,
img
.
size
.
width
>
0.0
,
img
.
size
.
height
>
0.0
{
return
CGSize
(
width
:
img
.
size
.
width
,
height
:
(
img
.
size
.
height
/
img
.
size
.
width
)
*
KScreenWidth
)
}
return
CGSize
(
width
:
KScreenWidth
,
height
:
KScreenWidth
)
}
init
(
url
:
String
=
""
,
img
:
UIImage
?
=
nil
)
{
self
.
url
=
url
self
.
img
=
img
}
}
class
YHHomeIdentityListVC
:
YHBaseViewController
{
var
selectSubTab
:
YHHomeLifeCategoryModel
?
=
nil
var
imgItems
:[
YHHomeIdentityItem
]
=
[]
var
scrollContentY
:
CGFloat
=
0.0
var
isShowBottomView
:
Bool
=
false
lazy
var
viewModel
:
YHHomePageViewModel
=
{
let
vm
=
YHHomePageViewModel
()
return
vm
}()
lazy
var
tableView
:
UITableView
=
{
let
tableView
=
UITableView
(
frame
:
CGRect
.
zero
,
style
:
.
grouped
)
tableView
.
contentInsetAdjustmentBehavior
=
.
never
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
backgroundColor
=
UIColor
.
white
tableView
.
separatorStyle
=
.
none
tableView
.
register
(
YHHomeIdentityCell
.
self
,
forCellReuseIdentifier
:
YHHomeIdentityCell
.
cellReuseIdentifier
)
tableView
.
delegate
=
self
tableView
.
dataSource
=
self
tableView
.
bounces
=
false
tableView
.
tableHeaderView
=
self
.
headerView
tableView
.
separatorStyle
=
.
none
return
tableView
}()
lazy
var
headerView
:
UIView
=
{
let
view
=
UIView
(
frame
:
CGRectMake
(
0
,
0
,
KScreenWidth
,
KScreenWidth
+
44.0
+
8.0
))
view
.
backgroundColor
=
.
white
view
.
addSubview
(
self
.
headImgView
)
headImgView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
top
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
headImgView
.
snp
.
width
)
}
self
.
segmentedView
.
dataSource
=
segmentedDataSource
view
.
addSubview
(
self
.
segmentedView
)
segmentedView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
0
)
make
.
right
.
equalTo
(
0
)
make
.
height
.
equalTo
(
44
)
make
.
top
.
equalTo
(
headImgView
.
snp
.
bottom
)
.
offset
(
8.0
)
}
return
view
}()
lazy
var
headImgView
:
UIImageView
=
{
let
imgView
=
UIImageView
()
imgView
.
image
=
UIImage
(
named
:
"global_default_image"
)
return
imgView
}()
lazy
var
segmentedView
:
JXSegmentedView
=
{
let
segmentedView
=
JXSegmentedView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
44
))
segmentedView
.
delegate
=
self
//配置指示器
let
indicator
=
JXSegmentedIndicatorLineView
()
indicator
.
indicatorWidth
=
16
indicator
.
indicatorHeight
=
2
indicator
.
indicatorCornerRadius
=
0.0
indicator
.
indicatorColor
=
.
brandMainColor
segmentedView
.
indicators
=
[
indicator
]
segmentedView
.
defaultSelectedIndex
=
0
return
segmentedView
}()
static
let
tabWidth
=
64.0
// 默认为4个tab
static
let
tabGap
=
(
KScreenWidth
-
20.0
*
2
-
tabWidth
*
4.0
)
/
3.0
lazy
var
segmentedDataSource
:
JXSegmentedTitleDataSource
=
{
let
dataSource
=
JXSegmentedTitleDataSource
()
dataSource
.
titleNormalFont
=
UIFont
.
PFSC_R
(
ofSize
:
16
)
dataSource
.
titleNormalColor
=
UIColor
.
init
(
hex
:
0x94A3B8
)
dataSource
.
titleSelectedFont
=
UIFont
.
PFSC_M
(
ofSize
:
16
)
dataSource
.
titleSelectedColor
=
.
mainTextColor
dataSource
.
itemWidth
=
Self
.
tabWidth
dataSource
.
itemSpacing
=
Self
.
tabGap
dataSource
.
itemWidthSelectedZoomScale
=
1.0
return
dataSource
}()
var
titles
:
[
String
]
=
[]
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
createUI
()
loadData
()
}
func
createUI
()
{
gk_navigationBar
.
isHidden
=
true
self
.
view
.
backgroundColor
=
.
white
self
.
view
.
addSubview
(
self
.
tableView
)
self
.
tableView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
.
offset
(
8.0
)
make
.
left
.
right
.
bottom
.
equalToSuperview
()
}
let
left
=
20.0
-
Self
.
tabGap
self
.
segmentedView
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
left
)
make
.
right
.
equalTo
(
-
left
)
make
.
height
.
equalTo
(
44
)
make
.
top
.
equalTo
(
headImgView
.
snp
.
bottom
)
.
offset
(
8.0
)
}
}
}
extension
YHHomeIdentityListVC
:
JXSegmentedViewDelegate
{
func
segmentedView
(
_
segmentedView
:
JXSegmentedView
,
didSelectedItemAt
index
:
Int
)
{
if
0
<=
index
,
index
<
self
.
imgItems
.
count
{
self
.
tableView
.
scrollToRow
(
at
:
IndexPath
(
row
:
index
,
section
:
0
),
at
:
.
top
,
animated
:
true
)
}
}
}
extension
YHHomeIdentityListVC
:
UITableViewDataSource
,
UITableViewDelegate
{
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHHomeIdentityCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHHomeIdentityCell
if
0
<=
indexPath
.
row
,
indexPath
.
row
<
self
.
imgItems
.
count
{
let
item
=
self
.
imgItems
[
indexPath
.
row
]
cell
.
image
=
item
.
img
}
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
0
<=
indexPath
.
row
,
indexPath
.
row
<
self
.
imgItems
.
count
{
let
item
=
self
.
imgItems
[
indexPath
.
row
]
return
item
.
getSize
()
.
height
}
return
KScreenWidth
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
self
.
imgItems
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
return
0.01
}
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
return
0.01
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
}
extension
YHHomeIdentityListVC
:
UIScrollViewDelegate
{
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
printLog
(
"offset:
\(
scrollView
.
contentOffset
.
y
)
"
)
if
scrollView
.
contentOffset
.
y
<=
self
.
headerView
.
height
{
if
self
.
segmentedView
.
selectedIndex
!=
0
{
self
.
segmentedView
.
defaultSelectedIndex
=
0
self
.
segmentedView
.
reloadDataWithoutListContainer
()
}
}
let
gap
=
10.0
if
scrollView
.
contentOffset
.
y
>
self
.
scrollContentY
+
gap
{
self
.
scrollContentY
=
scrollView
.
contentOffset
.
y
printLog
(
"ABCD:
\(
self
.
scrollContentY
)
,
\(
scrollView
.
contentOffset
.
y
)
"
)
if
!
self
.
isShowBottomView
{
self
.
isShowBottomView
=
true
printLog
(
"ABC show:
\(
self
.
scrollContentY
)
"
)
var
model
=
TabBarShareModel
()
model
.
showFlag
=
true
model
.
shareUrl
=
""
model
.
codeUrl
=
self
.
viewModel
.
detailModel
.
imageURLDefault
model
.
downloadUrl
=
self
.
viewModel
.
detailModel
.
imageURLDefaultDownload
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
changeShareViewStatusOnTabBarNotifiction
,
object
:
model
)
}
}
else
if
scrollView
.
contentOffset
.
y
<
self
.
scrollContentY
-
gap
{
printLog
(
"ABCD:
\(
self
.
scrollContentY
)
,
\(
scrollView
.
contentOffset
.
y
)
"
)
self
.
scrollContentY
=
scrollView
.
contentOffset
.
y
if
self
.
isShowBottomView
{
self
.
isShowBottomView
=
false
printLog
(
"ABC hide:
\(
self
.
scrollContentY
)
"
)
var
model
=
TabBarShareModel
()
model
.
showFlag
=
false
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
changeShareViewStatusOnTabBarNotifiction
,
object
:
model
)
}
}
}
}
extension
YHHomeIdentityListVC
{
func
loadData
()
{
if
let
selectItem
=
self
.
selectSubTab
{
let
params
:[
String
:
Any
]
=
[
"categoryId"
:
"2"
,
"levelId"
:
selectItem
.
id
]
self
.
viewModel
.
getGoodsCategoryDetail
(
params
:
params
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
self
.
titles
.
removeAll
()
self
.
imgItems
.
removeAll
()
for
product
in
self
.
viewModel
.
detailModel
.
products
{
self
.
headImgView
.
kf
.
setImage
(
with
:
URL
(
string
:
product
.
image
),
placeholder
:
UIImage
(
named
:
"global_default_image"
))
for
detail
in
product
.
details
{
let
item
=
YHHomeIdentityItem
()
item
.
url
=
detail
.
image
self
.
imgItems
.
append
(
item
)
self
.
titles
.
append
(
detail
.
name
)
}
}
self
.
segmentedDataSource
.
titles
=
self
.
titles
self
.
segmentedView
.
dataSource
=
self
.
segmentedDataSource
self
.
segmentedView
.
reloadDataWithoutListContainer
()
self
.
tableView
.
reloadData
()
requestImages
()
}
}
}
func
requestImages
()
{
let
ossGroup
=
DispatchGroup
()
for
item
in
self
.
imgItems
{
ossGroup
.
enter
()
item
.
imgView
.
kf
.
setImage
(
with
:
URL
(
string
:
item
.
url
))
{
result
in
switch
result
{
case
.
success
(
let
value
):
item
.
img
=
value
.
image
case
.
failure
(
let
error
):
print
(
"image download failed:
\(
error
.
localizedDescription
)
"
)
}
ossGroup
.
leave
()
}
}
ossGroup
.
notify
(
queue
:
.
main
)
{
self
.
tableView
.
reloadData
()
DispatchQueue
.
main
.
asyncAfter
(
deadline
:
.
now
()
+
0.2
,
execute
:
{
self
.
tableView
.
setContentOffset
(
CGPointZero
,
animated
:
false
)
})
}
}
}
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeIdentityViewController.swift
View file @
91fd43f4
...
@@ -9,124 +9,33 @@
...
@@ -9,124 +9,33 @@
import
UIKit
import
UIKit
import
JXSegmentedView
import
JXSegmentedView
class
YHHomeIdentityItem
{
var
url
:
String
=
""
var
img
:
UIImage
?
=
nil
var
imgView
:
UIImageView
=
UIImageView
()
func
getSize
()
->
CGSize
{
if
let
img
=
self
.
img
,
img
.
size
.
width
>
0.0
,
img
.
size
.
height
>
0.0
{
return
CGSize
(
width
:
img
.
size
.
width
,
height
:
(
img
.
size
.
height
/
img
.
size
.
width
)
*
KScreenWidth
)
}
return
CGSize
(
width
:
KScreenWidth
,
height
:
KScreenWidth
)
}
init
(
url
:
String
=
""
,
img
:
UIImage
?
=
nil
)
{
self
.
url
=
url
self
.
img
=
img
}
}
class
YHHomeIdentityViewController
:
YHBaseViewController
{
class
YHHomeIdentityViewController
:
YHBaseViewController
{
var
scrollContentY
:
CGFloat
=
0.0
var
isShowBottomView
:
Bool
=
false
var
subTabArr
:[
YHHomeLifeCategoryModel
]
=
[]
var
subTabArr
:[
YHHomeLifeCategoryModel
]
=
[]
var
selectSubTab
:
YHHomeLifeCategoryModel
?
=
nil
lazy
var
viewModel
:
YHHomePageViewModel
=
{
lazy
var
viewModel
:
YHHomePageViewModel
=
{
let
vm
=
YHHomePageViewModel
()
let
vm
=
YHHomePageViewModel
()
return
vm
return
vm
}()
}()
var
imgItems
:[
YHHomeIdentityItem
]
=
[]
lazy
var
subTabBar
:
YHIdentityTabBar
=
{
lazy
var
subTabBar
:
YHIdentityTabBar
=
{
let
bar
=
YHIdentityTabBar
.
tabBarForItems
([])
let
bar
=
YHIdentityTabBar
.
tabBarForItems
([])
bar
.
selectBlock
=
{
bar
.
selectBlock
=
{
[
weak
self
]
index
,
item
in
[
weak
self
]
index
,
item
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
self
.
tableView
.
setContentOffset
(
.
zero
,
animated
:
true
)
self
.
scrollView
.
setContentOffset
(
CGPointMake
(
KScreenWidth
*
Double
(
index
),
0
),
animated
:
false
)
self
.
tableView
.
reloadData
()
if
self
.
segmentedView
.
selectedIndex
!=
0
{
self
.
segmentedView
.
defaultSelectedIndex
=
0
self
.
segmentedView
.
reloadDataWithoutListContainer
()
}
self
.
selectSubTab
=
item
getDetailImages
()
}
}
return
bar
return
bar
}()
}()
lazy
var
tableView
:
UITableView
=
{
lazy
var
scrollView
:
UIScrollView
=
{
let
tableView
=
UITableView
(
frame
:
CGRect
.
zero
,
style
:
.
grouped
)
let
view
=
UIScrollView
()
tableView
.
contentInsetAdjustmentBehavior
=
.
never
view
.
isScrollEnabled
=
false
tableView
.
showsVerticalScrollIndicator
=
false
tableView
.
backgroundColor
=
UIColor
.
white
tableView
.
separatorStyle
=
.
none
tableView
.
register
(
YHHomeIdentityCell
.
self
,
forCellReuseIdentifier
:
YHHomeIdentityCell
.
cellReuseIdentifier
)
tableView
.
delegate
=
self
tableView
.
dataSource
=
self
tableView
.
bounces
=
false
tableView
.
tableHeaderView
=
self
.
headerView
return
tableView
}()
lazy
var
headerView
:
UIView
=
{
let
view
=
UIView
(
frame
:
CGRectMake
(
0
,
0
,
KScreenWidth
,
KScreenWidth
+
44.0
+
8.0
))
view
.
backgroundColor
=
.
white
view
.
addSubview
(
self
.
headImgView
)
headImgView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
top
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
headImgView
.
snp
.
width
)
}
self
.
segmentedView
.
dataSource
=
segmentedDataSource
view
.
addSubview
(
self
.
segmentedView
)
segmentedView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
equalTo
(
0
)
make
.
right
.
equalTo
(
0
)
make
.
height
.
equalTo
(
44
)
make
.
top
.
equalTo
(
headImgView
.
snp
.
bottom
)
.
offset
(
8.0
)
}
return
view
return
view
}()
}()
lazy
var
headImgView
:
UIImageView
=
{
let
imgView
=
UIImageView
()
imgView
.
image
=
UIImage
(
named
:
"global_default_image"
)
return
imgView
}()
lazy
var
segmentedView
:
JXSegmentedView
=
{
let
segmentedView
=
JXSegmentedView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
KScreenWidth
,
height
:
44
))
segmentedView
.
delegate
=
self
//配置指示器
let
indicator
=
JXSegmentedIndicatorLineView
()
indicator
.
indicatorWidth
=
16
indicator
.
indicatorHeight
=
2
indicator
.
indicatorCornerRadius
=
0.0
indicator
.
indicatorColor
=
.
brandMainColor
segmentedView
.
indicators
=
[
indicator
]
segmentedView
.
defaultSelectedIndex
=
0
return
segmentedView
}()
static
let
tabWidth
=
64.0
// 默认为4个tab
static
let
tabGap
=
(
KScreenWidth
-
20.0
*
2
-
tabWidth
*
4.0
)
/
3.0
lazy
var
segmentedDataSource
:
JXSegmentedTitleDataSource
=
{
let
dataSource
=
JXSegmentedTitleDataSource
()
dataSource
.
titleNormalFont
=
UIFont
.
PFSC_R
(
ofSize
:
16
)
dataSource
.
titleNormalColor
=
UIColor
.
init
(
hex
:
0x94A3B8
)
dataSource
.
titleSelectedFont
=
UIFont
.
PFSC_M
(
ofSize
:
16
)
dataSource
.
titleSelectedColor
=
.
mainTextColor
dataSource
.
itemWidth
=
Self
.
tabWidth
dataSource
.
itemSpacing
=
Self
.
tabGap
dataSource
.
itemWidthSelectedZoomScale
=
1.0
return
dataSource
}()
var
titles
:
[
String
]
=
[]
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
createUI
()
createUI
()
...
@@ -137,7 +46,7 @@ class YHHomeIdentityViewController: YHBaseViewController {
...
@@ -137,7 +46,7 @@ class YHHomeIdentityViewController: YHBaseViewController {
gk_navigationBar
.
isHidden
=
true
gk_navigationBar
.
isHidden
=
true
self
.
view
.
backgroundColor
=
.
white
self
.
view
.
backgroundColor
=
.
white
self
.
view
.
addSubview
(
self
.
table
View
)
self
.
view
.
addSubview
(
self
.
scroll
View
)
self
.
view
.
addSubview
(
self
.
subTabBar
)
self
.
view
.
addSubview
(
self
.
subTabBar
)
self
.
subTabBar
.
snp
.
makeConstraints
{
make
in
self
.
subTabBar
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
make
.
top
.
equalToSuperview
()
...
@@ -145,17 +54,10 @@ class YHHomeIdentityViewController: YHBaseViewController {
...
@@ -145,17 +54,10 @@ class YHHomeIdentityViewController: YHBaseViewController {
make
.
right
.
equalTo
(
-
20
)
make
.
right
.
equalTo
(
-
20
)
make
.
height
.
equalTo
(
44
)
make
.
height
.
equalTo
(
44
)
}
}
self
.
table
View
.
snp
.
makeConstraints
{
make
in
self
.
scroll
View
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
self
.
subTabBar
.
snp
.
bottom
)
.
offset
(
8.0
)
make
.
top
.
equalTo
(
self
.
subTabBar
.
snp
.
bottom
)
.
offset
(
8.0
)
make
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
left
.
right
.
bottom
.
equalToSuperview
()
}
}
let
left
=
20.0
-
Self
.
tabGap
self
.
segmentedView
.
snp
.
remakeConstraints
{
make
in
make
.
left
.
equalTo
(
left
)
make
.
right
.
equalTo
(
-
left
)
make
.
height
.
equalTo
(
44
)
make
.
top
.
equalTo
(
headImgView
.
snp
.
bottom
)
.
offset
(
8.0
)
}
}
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
...
@@ -163,25 +65,12 @@ class YHHomeIdentityViewController: YHBaseViewController {
...
@@ -163,25 +65,12 @@ class YHHomeIdentityViewController: YHBaseViewController {
hideBottomOnTabbar
()
hideBottomOnTabbar
()
}
}
func
hideBottomOnTabbar
()
{
func
hideBottomOnTabbar
()
{
//隐藏
//隐藏
var
model
=
TabBarShareModel
()
var
model
=
TabBarShareModel
()
model
.
showFlag
=
false
model
.
showFlag
=
false
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
changeShareViewStatusOnTabBarNotifiction
,
object
:
model
)
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
changeShareViewStatusOnTabBarNotifiction
,
object
:
model
)
}
}
func
updateSelectIndex
(
_
index
:
Int
)
{
self
.
subTabBar
.
selectIndex
=
index
}
}
extension
YHHomeIdentityViewController
:
JXSegmentedViewDelegate
{
func
segmentedView
(
_
segmentedView
:
JXSegmentedView
,
didSelectedItemAt
index
:
Int
)
{
if
0
<=
index
,
index
<
self
.
imgItems
.
count
{
self
.
tableView
.
scrollToRow
(
at
:
IndexPath
(
row
:
index
,
section
:
0
),
at
:
.
top
,
animated
:
true
)
}
}
}
}
extension
YHHomeIdentityViewController
:
JXSegmentedListContainerViewListDelegate
{
extension
YHHomeIdentityViewController
:
JXSegmentedListContainerViewListDelegate
{
...
@@ -190,84 +79,6 @@ extension YHHomeIdentityViewController: JXSegmentedListContainerViewListDelegate
...
@@ -190,84 +79,6 @@ extension YHHomeIdentityViewController: JXSegmentedListContainerViewListDelegate
}
}
}
}
extension
YHHomeIdentityViewController
:
UITableViewDataSource
,
UITableViewDelegate
{
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
YHHomeIdentityCell
.
cellReuseIdentifier
,
for
:
indexPath
)
as!
YHHomeIdentityCell
if
0
<=
indexPath
.
row
,
indexPath
.
row
<
self
.
imgItems
.
count
{
let
item
=
self
.
imgItems
[
indexPath
.
row
]
cell
.
image
=
item
.
img
}
return
cell
}
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
0
<=
indexPath
.
row
,
indexPath
.
row
<
self
.
imgItems
.
count
{
let
item
=
self
.
imgItems
[
indexPath
.
row
]
return
item
.
getSize
()
.
height
}
return
KScreenWidth
}
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
self
.
imgItems
.
count
}
func
tableView
(
_
tableView
:
UITableView
,
heightForHeaderInSection
section
:
Int
)
->
CGFloat
{
return
0.01
}
func
tableView
(
_
tableView
:
UITableView
,
heightForFooterInSection
section
:
Int
)
->
CGFloat
{
return
0.01
}
func
tableView
(
_
tableView
:
UITableView
,
viewForHeaderInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
func
tableView
(
_
tableView
:
UITableView
,
viewForFooterInSection
section
:
Int
)
->
UIView
?
{
return
UIView
()
}
}
extension
YHHomeIdentityViewController
:
UIScrollViewDelegate
{
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
printLog
(
"offset:
\(
scrollView
.
contentOffset
.
y
)
"
)
// if scrollView.contentOffset.y <= self.headerView.height {
// if self.segmentedView.selectedIndex != 0 {
// self.segmentedView.defaultSelectedIndex = 0
// self.segmentedView.reloadDataWithoutListContainer()
// }
// }
let
gap
=
10.0
if
scrollView
.
contentOffset
.
y
>
self
.
scrollContentY
+
gap
{
self
.
scrollContentY
=
scrollView
.
contentOffset
.
y
printLog
(
"ABCD:
\(
self
.
scrollContentY
)
,
\(
scrollView
.
contentOffset
.
y
)
"
)
if
!
self
.
isShowBottomView
{
self
.
isShowBottomView
=
true
printLog
(
"ABC show:
\(
self
.
scrollContentY
)
"
)
var
model
=
TabBarShareModel
()
model
.
showFlag
=
true
model
.
shareUrl
=
""
model
.
codeUrl
=
self
.
viewModel
.
detailModel
.
imageURLDefault
model
.
downloadUrl
=
self
.
viewModel
.
detailModel
.
imageURLDefaultDownload
NotificationCenter
.
default
.
post
(
name
:
YhConstant
.
YhNotification
.
changeShareViewStatusOnTabBarNotifiction
,
object
:
model
)
}
}
else
if
scrollView
.
contentOffset
.
y
<
self
.
scrollContentY
-
gap
{
printLog
(
"ABCD:
\(
self
.
scrollContentY
)
,
\(
scrollView
.
contentOffset
.
y
)
"
)
self
.
scrollContentY
=
scrollView
.
contentOffset
.
y
if
self
.
isShowBottomView
{
self
.
isShowBottomView
=
false
printLog
(
"ABC hide:
\(
self
.
scrollContentY
)
"
)
hideBottomOnTabbar
()
}
}
}
}
extension
YHHomeIdentityViewController
{
extension
YHHomeIdentityViewController
{
func
loadData
()
{
func
loadData
()
{
...
@@ -283,55 +94,19 @@ extension YHHomeIdentityViewController {
...
@@ -283,55 +94,19 @@ extension YHHomeIdentityViewController {
}
}
}
}
self
.
subTabBar
.
updateItems
(
subTabArr
)
self
.
subTabBar
.
updateItems
(
subTabArr
)
self
.
selectSubTab
=
self
.
subTabArr
.
first
getDetailImages
()
}
}
func
getDetailImages
()
{
if
let
selectItem
=
self
.
selectSubTab
{
let
params
:[
String
:
Any
]
=
[
"categoryId"
:
"2"
,
"levelId"
:
selectItem
.
id
]
self
.
viewModel
.
getGoodsCategoryDetail
(
params
:
params
)
{
[
weak
self
]
success
,
error
in
guard
let
self
=
self
else
{
return
}
self
.
titles
.
removeAll
()
self
.
imgItems
.
removeAll
()
for
product
in
self
.
viewModel
.
detailModel
.
products
{
self
.
headImgView
.
kf
.
setImage
(
with
:
URL
(
string
:
product
.
image
),
placeholder
:
UIImage
(
named
:
"global_default_image"
))
for
detail
in
product
.
details
{
let
item
=
YHHomeIdentityItem
()
item
.
url
=
detail
.
image
self
.
imgItems
.
append
(
item
)
self
.
titles
.
append
(
detail
.
name
)
}
}
self
.
segmentedDataSource
.
titles
=
self
.
titles
self
.
segmentedView
.
dataSource
=
self
.
segmentedDataSource
self
.
segmentedView
.
reloadDataWithoutListContainer
()
self
.
tableView
.
reloadData
()
requestImages
()
}
}
}
func
requestImages
()
{
self
.
scrollView
.
removeSubviews
()
let
ossGroup
=
DispatchGroup
()
for
(
index
,
item
)
in
subTabArr
.
enumerated
()
{
for
item
in
self
.
imgItems
{
let
vc
=
YHHomeIdentityListVC
()
ossGroup
.
enter
()
vc
.
selectSubTab
=
item
item
.
imgView
.
kf
.
setImage
(
with
:
URL
(
string
:
item
.
url
))
{
result
in
vc
.
view
.
frame
=
CGRect
(
x
:
KScreenWidth
*
Double
(
index
),
y
:
0
,
width
:
KScreenWidth
,
height
:
self
.
scrollView
.
height
)
switch
result
{
vc
.
loadData
()
case
.
success
(
let
value
):
self
.
addChild
(
vc
)
item
.
img
=
value
.
image
self
.
scrollView
.
addSubview
(
vc
.
view
)
case
.
failure
(
let
error
):
print
(
"image download failed:
\(
error
.
localizedDescription
)
"
)
}
}
self
.
tableView
.
reloadData
()
self
.
scrollView
.
contentSize
=
CGSize
(
width
:
KScreenWidth
*
Double
(
self
.
subTabArr
.
count
),
height
:
self
.
scrollView
.
height
)
ossGroup
.
leave
()
}
}
ossGroup
.
notify
(
queue
:
.
main
)
{
self
.
tableView
.
reloadData
()
}
}
}
}
}
}
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHHomeIdentityCell.swift
View file @
91fd43f4
...
@@ -15,11 +15,9 @@ class YHHomeIdentityCell: UITableViewCell {
...
@@ -15,11 +15,9 @@ class YHHomeIdentityCell: UITableViewCell {
didSet
{
didSet
{
if
let
img
=
image
{
if
let
img
=
image
{
imgView
.
image
=
img
imgView
.
image
=
img
self
.
bottomLineView
.
isHidden
=
false
}
else
{
}
else
{
imgView
.
image
=
UIImage
(
named
:
"global_default_image"
)
imgView
.
image
=
UIImage
(
named
:
"global_default_image"
)
self
.
bottomLineView
.
isHidden
=
false
}
}
}
}
}
}
...
@@ -30,12 +28,6 @@ class YHHomeIdentityCell: UITableViewCell {
...
@@ -30,12 +28,6 @@ class YHHomeIdentityCell: UITableViewCell {
return
view
return
view
}()
}()
lazy
var
bottomLineView
:
UIView
=
{
let
view
=
UIView
()
view
.
backgroundColor
=
.
separatorColor
return
view
}()
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
setupUI
()
setupUI
()
...
@@ -47,14 +39,9 @@ class YHHomeIdentityCell: UITableViewCell {
...
@@ -47,14 +39,9 @@ class YHHomeIdentityCell: UITableViewCell {
func
setupUI
()
{
func
setupUI
()
{
self
.
contentView
.
addSubview
(
self
.
imgView
)
self
.
contentView
.
addSubview
(
self
.
imgView
)
self
.
contentView
.
addSubview
(
self
.
bottomLineView
)
self
.
imgView
.
snp
.
makeConstraints
{
make
in
self
.
imgView
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
make
.
edges
.
equalToSuperview
()
}
}
self
.
bottomLineView
.
snp
.
makeConstraints
{
make
in
make
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
height
.
equalTo
(
1.0
)
}
}
}
}
}
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