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
352fd929
Commit
352fd929
authored
Jul 08, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整代码结构
parent
6a7036d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
275 additions
and
17 deletions
+275
-17
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+1
-1
YHHomeHoldViewPageViewController.swift
...Modules/Home(首页)/C/YHHomeHoldViewPageViewController.swift
+261
-9
YHHomePageViewController.swift
...Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
+13
-7
No files found.
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
352fd929
...
@@ -2519,12 +2519,12 @@
...
@@ -2519,12 +2519,12 @@
A567E5742BD7643D00D5D5A0
/* YHSearchInfomationVC.swift */
,
A567E5742BD7643D00D5D5A0
/* YHSearchInfomationVC.swift */
,
04F5F86B2C1A9B52004A463C
/* YHOtherServiceListViewController.swift */
,
04F5F86B2C1A9B52004A463C
/* YHOtherServiceListViewController.swift */
,
04F5F8692C1A95BB004A463C
/* YHOtherServiceViewController.swift */
,
04F5F8692C1A95BB004A463C
/* YHOtherServiceViewController.swift */
,
A567E5762BD7643D00D5D5A0
/* YHHomePageViewController.swift */
,
A567E5772BD7643D00D5D5A0
/* YHStartPageViewController.swift */
,
A567E5772BD7643D00D5D5A0
/* YHStartPageViewController.swift */
,
A567E5782BD7643D00D5D5A0
/* YHHomeWebViewController.swift */
,
A567E5782BD7643D00D5D5A0
/* YHHomeWebViewController.swift */
,
04F5F86D2C1AC351004A463C
/* YHHKEventCenterViewController.swift */
,
04F5F86D2C1AC351004A463C
/* YHHKEventCenterViewController.swift */
,
04F5F86F2C1AC4C2004A463C
/* YHHKEventWebViewController.swift */
,
04F5F86F2C1AC4C2004A463C
/* YHHKEventWebViewController.swift */
,
A567E57A2BD7643D00D5D5A0
/* YHConfigManager.swift */
,
A567E57A2BD7643D00D5D5A0
/* YHConfigManager.swift */
,
A567E5762BD7643D00D5D5A0
/* YHHomePageViewController.swift */
,
A5000F502C3BC28B00843452
/* YHHomeHoldViewPageViewController.swift */
,
A5000F502C3BC28B00843452
/* YHHomeHoldViewPageViewController.swift */
,
);
);
path
=
C
;
path
=
C
;
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeHoldViewPageViewController.swift
View file @
352fd929
...
@@ -7,24 +7,276 @@
...
@@ -7,24 +7,276 @@
//
//
import
UIKit
import
UIKit
import
JXSegmentedView
class
YHHomeHoldViewPageViewController
:
YHBaseViewController
{
class
YHHomeHoldViewPageViewController
:
YHBaseViewController
{
var
defaltIndex
:
Int
=
0
let
friendViewModel
=
YHMatchUserViewModel
()
let
arrItemTitles
=
[
"推荐"
,
"身份"
,
"生活"
]
var
arrItemVCs
:
[
YHBaseViewController
]
=
[]
lazy
var
segmentedView
:
JXSegmentedView
=
{
let
view
=
JXSegmentedView
(
frame
:
CGRect
(
x
:
0
,
y
:
k_Height_safeAreaInsetsTop
(),
width
:
KScreenWidth
,
height
:
48
))
view
.
backgroundColor
=
.
clear
return
view
}()
lazy
var
segmentedDataSource
:
JXSegmentedTitleDataSource
=
{
let
dataSource
=
JXSegmentedTitleDataSource
()
dataSource
.
isTitleColorGradientEnabled
=
true
dataSource
.
titles
=
arrItemTitles
dataSource
.
titleNormalFont
=
UIFont
.
PFSC_M
(
ofSize
:
15
)
dataSource
.
titleNormalColor
=
UIColor
.
yhGreyColor
dataSource
.
titleSelectedFont
=
UIFont
.
PFSC_M
(
ofSize
:
21
)
dataSource
.
titleSelectedColor
=
.
mainTextColor
dataSource
.
isItemSpacingAverageEnabled
=
false
dataSource
.
itemWidth
=
JXSegmentedViewAutomaticDimension
dataSource
.
itemSpacing
=
28.0
return
dataSource
}()
lazy
var
bgImgV
:
UIImageView
=
{
let
bg
=
UIImageView
(
image
:
UIImage
(
named
:
"people_match_bg"
))
return
bg
}()
//分类title 所对应的VC
lazy
var
listContainerView
:
JXSegmentedListContainerView
!
=
{
let
view
=
JXSegmentedListContainerView
(
dataSource
:
self
,
type
:
.
scrollView
)
view
.
backgroundColor
=
.
clear
return
view
}()
lazy
var
friendsBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setImage
(
UIImage
(
named
:
"people_friends_btn"
),
for
:
.
normal
)
btn
.
setTitle
(
"好友"
,
for
:
.
normal
)
btn
.
setTitleColor
(
UIColor
.
white
,
for
:
.
normal
)
btn
.
iconInLeft
(
spacing
:
4.0
)
btn
.
titleLabel
?
.
font
=
UIFont
.
PFSC_R
(
ofSize
:
15
)
btn
.
YH_clickEdgeInsets
=
UIEdgeInsets
(
top
:
20
,
left
:
20
,
bottom
:
20
,
right
:
20
)
btn
.
addTarget
(
self
,
action
:
#selector(
didFriendsBtnClicked
)
,
for
:
.
touchUpInside
)
return
btn
}()
let
unreadHeight
=
16.0
lazy
var
unreadLabel
:
UILabel
=
{
let
label
=
UILabel
()
label
.
textColor
=
.
white
label
.
textAlignment
=
.
center
label
.
backgroundColor
=
.
failColor
label
.
font
=
.
PFSC_M
(
ofSize
:
10
)
label
.
layer
.
cornerRadius
=
unreadHeight
/
2.0
label
.
clipsToBounds
=
true
label
.
isHidden
=
true
return
label
}()
var
unreadCount
:
Int
=
0
{
didSet
{
self
.
updateUnreadCount
(
self
.
unreadCount
)
}
}
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
setupUI
()
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
requestFriendRequest
()
//处于第一个item的时候,才允许屏幕边缘手势返回
navigationController
?
.
interactivePopGestureRecognizer
?
.
isEnabled
=
(
segmentedView
.
selectedIndex
==
0
)
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
// Do any additional setup after loading the view.
//离开页面的时候,需要恢复屏幕边缘手势,不能影响其他页面
navigationController
?
.
interactivePopGestureRecognizer
?
.
isEnabled
=
true
}
}
override
func
viewDidLayoutSubviews
()
{
super
.
viewDidLayoutSubviews
()
/*
segmentedView
.
frame
=
CGRect
(
x
:
0
,
y
:
k_Height_safeAreaInsetsTop
(),
width
:
view
.
bounds
.
size
.
width
,
height
:
48
)
// MARK: - Navigation
listContainerView
.
frame
=
CGRect
(
x
:
0
,
y
:
k_Height_safeAreaInsetsTop
()
+
48
,
width
:
view
.
bounds
.
size
.
width
,
height
:
view
.
bounds
.
size
.
height
-
48
-
k_Height_safeAreaInsetsTop
())
}
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
//内部函数
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
extension
YHHomeHoldViewPageViewController
{
// Get the new view controller using segue.destination.
func
updateUnreadCount
(
_
count
:
Int
)
{
// Pass the selected object to the new view controller.
self
.
unreadLabel
.
isHidden
=
(
count
<=
0
)
if
0
<
count
&&
count
<
100
{
self
.
unreadLabel
.
text
=
"
\(
count
)
"
}
else
if
count
>=
100
{
self
.
unreadLabel
.
text
=
"99+"
}
var
width
=
unreadHeight
var
leftMargin
=
-
8
if
10
<=
count
&&
count
<
100
{
width
=
22.0
}
else
if
count
>=
100
{
width
=
30.0
leftMargin
=
-
14
}
self
.
unreadLabel
.
snp
.
updateConstraints
{
make
in
make
.
width
.
equalTo
(
width
)
make
.
left
.
equalTo
(
self
.
friendsBtn
.
snp
.
right
)
.
offset
(
leftMargin
)
}
}
}
*/
@objc
func
didBackBtnClicked
()
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
@objc
func
didFriendsBtnClicked
()
{
if
!
YHLoginManager
.
shared
.
isLogin
()
{
YHOneKeyLoginManager
.
shared
.
oneKeyLogin
()
return
}
let
vc
=
YHMyGoodFriendsVC
()
self
.
navigationController
?
.
pushViewController
(
vc
)
}
func
setupUI
()
{
gk_navBarAlpha
=
0
gk_navigationBar
.
isHidden
=
true
self
.
view
.
backgroundColor
=
.
white
self
.
view
.
addSubview
(
bgImgV
)
self
.
bgImgV
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
}
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
goActivityVC
)
,
name
:
YhConstant
.
YhNotification
.
goActivityVCNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
goConnectionVC
)
,
name
:
YhConstant
.
YhNotification
.
goConnectionVCNotifiction
,
object
:
nil
)
for
i
in
0
..<
arrItemTitles
.
count
{
if
i
!=
0
{
let
vc
=
YHActivityListViewController
()
arrItemVCs
.
append
(
vc
)
}
else
{
let
vc
=
YHMatchUserViewController
()
arrItemVCs
.
append
(
vc
)
}
}
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView
.
dataSource
=
segmentedDataSource
view
.
addSubview
(
segmentedView
)
segmentedView
.
listContainer
=
listContainerView
view
.
addSubview
(
listContainerView
)
//分类Title
segmentedView
.
dataSource
=
segmentedDataSource
segmentedView
.
delegate
=
self
//配置指示器
let
indicator
=
JXSegmentedIndicatorLineView
()
indicator
.
indicatorWidth
=
16
indicator
.
indicatorHeight
=
2
indicator
.
indicatorCornerRadius
=
0.0
indicator
.
indicatorColor
=
UIColor
.
white
segmentedView
.
indicators
=
[
indicator
]
segmentedView
.
defaultSelectedIndex
=
defaltIndex
self
.
view
.
addSubview
(
friendsBtn
)
friendsBtn
.
snp
.
makeConstraints
{
make
in
make
.
width
.
equalTo
(
54.0
)
make
.
height
.
equalTo
(
21
)
make
.
right
.
equalTo
(
-
20
)
make
.
top
.
equalTo
(
12
+
k_Height_safeAreaInsetsTop
())
}
self
.
friendsBtn
.
addSubview
(
self
.
unreadLabel
)
self
.
unreadLabel
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
unreadHeight
)
make
.
left
.
equalTo
(
self
.
friendsBtn
.
snp
.
right
)
.
offset
(
-
8
)
make
.
top
.
equalTo
(
self
.
friendsBtn
.
snp
.
top
)
.
offset
(
-
8
)
}
}
func
requestFriendRequest
()
{
if
YHLoginManager
.
shared
.
isLogin
()
{
self
.
friendViewModel
.
getMyFriendList
{
success
,
error
in
let
unreadCount
=
self
.
friendViewModel
.
friendListModel
.
applyFriends
.
count
self
.
unreadCount
=
unreadCount
self
.
friendsBtn
.
isHidden
=
self
.
segmentedView
.
selectedIndex
!=
0
}
}
else
{
self
.
unreadCount
=
0
}
}
@objc
func
goActivityVC
()
{
segmentedView
.
selectItemAt
(
index
:
1
)
}
@objc
func
goConnectionVC
()
{
segmentedView
.
selectItemAt
(
index
:
0
)
}
func
jumpToItemIndex
(
itemIndex
:
Int
)
{
self
.
segmentedView
.
selectItemAt
(
index
:
itemIndex
)
}
}
//JXSegmentedViewDelegate
extension
YHHomeHoldViewPageViewController
:
JXSegmentedViewDelegate
{
func
segmentedView
(
_
segmentedView
:
JXSegmentedView
,
didSelectedItemAt
index
:
Int
)
{
navigationController
?
.
interactivePopGestureRecognizer
?
.
isEnabled
=
(
segmentedView
.
selectedIndex
==
0
)
// if segmentedView.selectedIndex == 0 {
// bgImgV.isHidden = false
// friendsBtn.isHidden = false
// segmentedDataSource.titleNormalColor = UIColor(hex: 0xFFFFFF, alpha: 0.6)
// segmentedDataSource.titleSelectedColor = .white
// let indicator = JXSegmentedIndicatorLineView()
// indicator.indicatorWidth = 16
// indicator.indicatorHeight = 2
// indicator.indicatorCornerRadius = 0.0
// indicator.indicatorColor = UIColor.white
// segmentedView.indicators = [indicator]
// } else {
// bgImgV.isHidden = true
// friendsBtn.isHidden = true
// segmentedDataSource.titleNormalColor = UIColor.yhGreyColor
// segmentedDataSource.titleSelectedColor = UIColor.mainTextColor
// let indicator = JXSegmentedIndicatorLineView()
// indicator.indicatorWidth = 16
// indicator.indicatorHeight = 2
// indicator.indicatorCornerRadius = 0.0
// indicator.indicatorColor = UIColor.brandMainColor
// segmentedView.indicators = [indicator]
// }
// segmentedView.dataSource = segmentedDataSource
self
.
segmentedView
.
reloadDataWithoutListContainer
()
}
}
//JXSegmentedListContainerViewDataSource
extension
YHHomeHoldViewPageViewController
:
JXSegmentedListContainerViewDataSource
{
func
numberOfLists
(
in
listContainerView
:
JXSegmentedListContainerView
)
->
Int
{
if
let
titleDataSource
=
segmentedView
.
dataSource
as?
JXSegmentedBaseDataSource
{
return
titleDataSource
.
dataSource
.
count
}
return
0
}
func
listContainerView
(
_
listContainerView
:
JXSegmentedListContainerView
,
initListAt
index
:
Int
)
->
JXSegmentedListContainerViewListDelegate
{
return
arrItemVCs
[
index
]
as!
JXSegmentedListContainerViewListDelegate
}
}
}
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomePageViewController.swift
View file @
352fd929
...
@@ -45,15 +45,12 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -45,15 +45,12 @@ class YHHomePageViewController: YHBaseViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
setupUI
()
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
clickMsgitem
)
,
name
:
YhConstant
.
YhNotification
.
clickHomeMsgNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didRefreshMessageCount
)
,
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgTotalCountNotification
,
object
:
nil
)
//0、
setupUI
()
//1、加载默认数据
//1、加载默认数据
homeHeaderView
.
homeBannerView
.
dataArr
=
getCacheDataForBanner
()
addDefaultData
()
getCacheDataForHomeNewsData
()
//2、请求新的数据
//2、请求新的数据
getData
()
getData
()
...
@@ -178,11 +175,15 @@ class YHHomePageViewController: YHBaseViewController {
...
@@ -178,11 +175,15 @@ class YHHomePageViewController: YHBaseViewController {
}
}
private
extension
YHHomePageViewController
{
private
extension
YHHomePageViewController
{
func
addDefaultData
()
{
homeHeaderView
.
homeBannerView
.
dataArr
=
getCacheDataForBanner
()
getCacheDataForHomeNewsData
()
}
@objc
func
clickMsgitem
()
{
@objc
func
clickMsgitem
()
{
needReloadDataFlag
=
true
needReloadDataFlag
=
true
}
}
@objc
func
didSearchBarClicked
()
{
@objc
func
didSearchBarClicked
()
{
let
vc
=
YHSearchInfomationVC
()
let
vc
=
YHSearchInfomationVC
()
vc
.
searchPlaceHolder
=
searchView
.
placeHolder
vc
.
searchPlaceHolder
=
searchView
.
placeHolder
...
@@ -323,6 +324,11 @@ private extension YHHomePageViewController {
...
@@ -323,6 +324,11 @@ private extension YHHomePageViewController {
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
clearUnreadBadge
)
,
name
:
YhConstant
.
YhNotification
.
didMarkAllMessagesReadedNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
clearUnreadBadge
)
,
name
:
YhConstant
.
YhNotification
.
didMarkAllMessagesReadedNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
clickMsgitem
)
,
name
:
YhConstant
.
YhNotification
.
clickHomeMsgNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didRefreshMessageCount
)
,
name
:
YhConstant
.
YhNotification
.
didRequestUnreadMsgTotalCountNotification
,
object
:
nil
)
view
.
addSubview
(
searchView
)
view
.
addSubview
(
searchView
)
searchView
.
snp
.
makeConstraints
{
make
in
searchView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
k_Height_safeAreaInsetsTop
()
+
6
)
make
.
top
.
equalTo
(
k_Height_safeAreaInsetsTop
()
+
6
)
...
...
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