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
1e7f9245
Commit
1e7f9245
authored
Aug 22, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加时间段选择器
parent
0b730193
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
315 additions
and
0 deletions
+315
-0
Podfile
galaxy/Podfile
+3
-0
project.pbxproj
galaxy/galaxy.xcodeproj/project.pbxproj
+16
-0
YHRangeDatePickerCell.swift
...Classes/Tools/RangeDatePicker/YHRangeDatePickerCell.swift
+53
-0
YHRangeDatePickerView.swift
...Classes/Tools/RangeDatePicker/YHRangeDatePickerView.swift
+243
-0
No files found.
galaxy/Podfile
View file @
1e7f9245
...
@@ -5,6 +5,9 @@ platform :ios, '13.0'
...
@@ -5,6 +5,9 @@ platform :ios, '13.0'
target
'galaxy'
do
target
'galaxy'
do
use_frameworks!
use_frameworks!
#日历 多时间选择
pod
'FSCalendar'
,
"2.8.4"
#图片预览
#图片预览
pod
'JXPhotoBrowser'
,
"3.1.4"
pod
'JXPhotoBrowser'
,
"3.1.4"
pod
'SDWebImage'
,
'5.18.10'
pod
'SDWebImage'
,
'5.18.10'
...
...
galaxy/galaxy.xcodeproj/project.pbxproj
View file @
1e7f9245
...
@@ -588,6 +588,8 @@
...
@@ -588,6 +588,8 @@
A567E5B72BD7643D00D5D5A0
/* YHHkLifeAndIdItemView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A567E5902BD7643D00D5D5A0
/* YHHkLifeAndIdItemView.swift */
;
};
A567E5B72BD7643D00D5D5A0
/* YHHkLifeAndIdItemView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A567E5902BD7643D00D5D5A0
/* YHHkLifeAndIdItemView.swift */
;
};
A567E5B82BD7643D00D5D5A0
/* YHSearchItemLayout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A567E5912BD7643D00D5D5A0
/* YHSearchItemLayout.swift */
;
};
A567E5B82BD7643D00D5D5A0
/* YHSearchItemLayout.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A567E5912BD7643D00D5D5A0
/* YHSearchItemLayout.swift */
;
};
A56D2D612B62020C009C83A8
/* YHContractMainItemStatusCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A56D2D602B62020C009C83A8
/* YHContractMainItemStatusCell.swift */
;
};
A56D2D612B62020C009C83A8
/* YHContractMainItemStatusCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A56D2D602B62020C009C83A8
/* YHContractMainItemStatusCell.swift */
;
};
A5765B262C771F86002CD3C1
/* YHRangeDatePickerView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A5765B252C771F86002CD3C1
/* YHRangeDatePickerView.swift */
;
};
A5765B282C772185002CD3C1
/* YHRangeDatePickerCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A5765B272C772185002CD3C1
/* YHRangeDatePickerCell.swift */
;
};
A580371E2BAD784B0031C312
/* YHMySchemeViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A580371D2BAD784B0031C312
/* YHMySchemeViewModel.swift */
;
};
A580371E2BAD784B0031C312
/* YHMySchemeViewModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A580371D2BAD784B0031C312
/* YHMySchemeViewModel.swift */
;
};
A58037212BAD7B2A0031C312
/* YHMySchemeModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A58037202BAD7B2A0031C312
/* YHMySchemeModel.swift */
;
};
A58037212BAD7B2A0031C312
/* YHMySchemeModel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A58037202BAD7B2A0031C312
/* YHMySchemeModel.swift */
;
};
A582B23D2BB944ED009D098C
/* YHHKPlanDoctumentVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A582B23C2BB944ED009D098C
/* YHHKPlanDoctumentVC.swift */
;
};
A582B23D2BB944ED009D098C
/* YHHKPlanDoctumentVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A582B23C2BB944ED009D098C
/* YHHKPlanDoctumentVC.swift */
;
};
...
@@ -1335,6 +1337,8 @@
...
@@ -1335,6 +1337,8 @@
A567E5902BD7643D00D5D5A0
/* YHHkLifeAndIdItemView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHHkLifeAndIdItemView.swift
;
sourceTree
=
"<group>"
;
};
A567E5902BD7643D00D5D5A0
/* YHHkLifeAndIdItemView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHHkLifeAndIdItemView.swift
;
sourceTree
=
"<group>"
;
};
A567E5912BD7643D00D5D5A0
/* YHSearchItemLayout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSearchItemLayout.swift
;
sourceTree
=
"<group>"
;
};
A567E5912BD7643D00D5D5A0
/* YHSearchItemLayout.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHSearchItemLayout.swift
;
sourceTree
=
"<group>"
;
};
A56D2D602B62020C009C83A8
/* YHContractMainItemStatusCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHContractMainItemStatusCell.swift
;
sourceTree
=
"<group>"
;
};
A56D2D602B62020C009C83A8
/* YHContractMainItemStatusCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHContractMainItemStatusCell.swift
;
sourceTree
=
"<group>"
;
};
A5765B252C771F86002CD3C1
/* YHRangeDatePickerView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHRangeDatePickerView.swift
;
sourceTree
=
"<group>"
;
};
A5765B272C772185002CD3C1
/* YHRangeDatePickerCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHRangeDatePickerCell.swift
;
sourceTree
=
"<group>"
;
};
A580371D2BAD784B0031C312
/* YHMySchemeViewModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMySchemeViewModel.swift
;
sourceTree
=
"<group>"
;
};
A580371D2BAD784B0031C312
/* YHMySchemeViewModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMySchemeViewModel.swift
;
sourceTree
=
"<group>"
;
};
A58037202BAD7B2A0031C312
/* YHMySchemeModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMySchemeModel.swift
;
sourceTree
=
"<group>"
;
};
A58037202BAD7B2A0031C312
/* YHMySchemeModel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHMySchemeModel.swift
;
sourceTree
=
"<group>"
;
};
A582B23C2BB944ED009D098C
/* YHHKPlanDoctumentVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHHKPlanDoctumentVC.swift
;
sourceTree
=
"<group>"
;
};
A582B23C2BB944ED009D098C
/* YHHKPlanDoctumentVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
YHHKPlanDoctumentVC.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -3337,6 +3341,15 @@
...
@@ -3337,6 +3341,15 @@
path
=
V
;
path
=
V
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
A5765B242C771F51002CD3C1
/* RangeDatePicker */
=
{
isa
=
PBXGroup
;
children
=
(
A5765B252C771F86002CD3C1
/* YHRangeDatePickerView.swift */
,
A5765B272C772185002CD3C1
/* YHRangeDatePickerCell.swift */
,
);
path
=
RangeDatePicker
;
sourceTree
=
"<group>"
;
};
A580371C2BAD77DB0031C312
/* VM */
=
{
A580371C2BAD77DB0031C312
/* VM */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -3477,6 +3490,7 @@
...
@@ -3477,6 +3490,7 @@
A5ACE8EE2B4564F7002C94D2
/* Tools */
=
{
A5ACE8EE2B4564F7002C94D2
/* Tools */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
A5765B242C771F51002CD3C1
/* RangeDatePicker */
,
049663B62BF60BB7003C8295
/* CustomRefreshHeader */
,
049663B62BF60BB7003C8295
/* CustomRefreshHeader */
,
0488518B2BF5FAA800C4E32D
/* Upload */
,
0488518B2BF5FAA800C4E32D
/* Upload */
,
04AF514C2BEB57FC00009E3A
/* VideoPlay */
,
04AF514C2BEB57FC00009E3A
/* VideoPlay */
,
...
@@ -4168,6 +4182,7 @@
...
@@ -4168,6 +4182,7 @@
045EEE8D2B9F171A0022A143
/* YHPreviewInfoCell.swift in Sources */
,
045EEE8D2B9F171A0022A143
/* YHPreviewInfoCell.swift in Sources */
,
047AA3E22C4A66CE009C4554
/* YHLifeItemTableViewCell.swift in Sources */
,
047AA3E22C4A66CE009C4554
/* YHLifeItemTableViewCell.swift in Sources */
,
0430E6782C74A53F000511E2
/* YHAdopterMarryCardTableViewCell.swift in Sources */
,
0430E6782C74A53F000511E2
/* YHAdopterMarryCardTableViewCell.swift in Sources */
,
A5765B262C771F86002CD3C1
/* YHRangeDatePickerView.swift in Sources */
,
048FA0362BFDE04000AD3BA9
/* YHSubmitAllInfoSuccessAlertView.swift in Sources */
,
048FA0362BFDE04000AD3BA9
/* YHSubmitAllInfoSuccessAlertView.swift in Sources */
,
04B360ED2C61F157001EB053
/* YHPrincipleEnvelopeCell.swift in Sources */
,
04B360ED2C61F157001EB053
/* YHPrincipleEnvelopeCell.swift in Sources */
,
04B9EE5B2C06CC3100A4018D
/* YHOtherLoginViewController.swift in Sources */
,
04B9EE5B2C06CC3100A4018D
/* YHOtherLoginViewController.swift in Sources */
,
...
@@ -4305,6 +4320,7 @@
...
@@ -4305,6 +4320,7 @@
045EEED92B9F171A0022A143
/* YHEducationDetailVC.swift in Sources */
,
045EEED92B9F171A0022A143
/* YHEducationDetailVC.swift in Sources */
,
045EEF1A2B9F171A0022A143
/* YHAddressViewController.swift in Sources */
,
045EEF1A2B9F171A0022A143
/* YHAddressViewController.swift in Sources */
,
A5C382CA2B5E1F4C00C5E65C
/* YHLoginTipsView.swift in Sources */
,
A5C382CA2B5E1F4C00C5E65C
/* YHLoginTipsView.swift in Sources */
,
A5765B282C772185002CD3C1
/* YHRangeDatePickerCell.swift in Sources */
,
04FB01D02C23FA420040115D
/* YHMatchUserInfo.swift in Sources */
,
04FB01D02C23FA420040115D
/* YHMatchUserInfo.swift in Sources */
,
045EEEE92B9F171A0022A143
/* YHFamilyRequestViewModel.swift in Sources */
,
045EEEE92B9F171A0022A143
/* YHFamilyRequestViewModel.swift in Sources */
,
04B360E72C60CD37001EB053
/* YHPrincipleUploadFileCell.swift in Sources */
,
04B360E72C60CD37001EB053
/* YHPrincipleUploadFileCell.swift in Sources */
,
...
...
galaxy/galaxy/Classes/Tools/RangeDatePicker/YHRangeDatePickerCell.swift
0 → 100644
View file @
1e7f9245
//
// YHRangeDatePickerCell.swift
// galaxy
//
// Created by davidhuangA on 2024/8/22.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
import
FSCalendar
class
YHRangeDatePickerCell
:
FSCalendarCell
{
static
let
cellReuseIdentifier
=
"YHRangeDatePickerCell"
public
var
middleLayer
:
CALayer
=
CALayer
();
public
var
selectionLayer
:
CALayer
=
CALayer
();
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
let
selectionLayer
=
CALayer
()
selectionLayer
.
cornerRadius
=
3
selectionLayer
.
backgroundColor
=
UIColor
(
red
:
0
,
green
:
0.275
,
blue
:
0.706
,
alpha
:
1
)
.
cgColor
selectionLayer
.
actions
=
[
"hidden"
:
NSNull
()]
contentView
.
layer
.
insertSublayer
(
selectionLayer
,
below
:
titleLabel
?
.
layer
)
self
.
selectionLayer
=
selectionLayer
let
middleLayer
=
CALayer
()
middleLayer
.
backgroundColor
=
UIColor
(
red
:
0
,
green
:
0.275
,
blue
:
0.706
,
alpha
:
0.08
)
.
cgColor
middleLayer
.
actions
=
[
"hidden"
:
NSNull
()]
contentView
.
layer
.
insertSublayer
(
middleLayer
,
below
:
titleLabel
?
.
layer
)
self
.
middleLayer
=
middleLayer
shapeLayer
.
isHidden
=
true
}
required
init
!
(
coder
aDecoder
:
NSCoder
!
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
titleLabel
?
.
frame
=
contentView
.
bounds
}
override
func
layoutSublayers
(
of
layer
:
CALayer
)
{
super
.
layoutSublayers
(
of
:
layer
)
middleLayer
.
frame
=
contentView
.
bounds
selectionLayer
.
frame
=
contentView
.
bounds
}
}
galaxy/galaxy/Classes/Tools/RangeDatePicker/YHRangeDatePickerView.swift
0 → 100644
View file @
1e7f9245
//
// YHRangeDatePickerView.swift
// galaxy
//
// Created by davidhuangA on 2024/8/22.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import
UIKit
import
FSCalendar
class
YHRangeDatePickerView
:
UIView
,
FSCalendarDataSource
,
FSCalendarDelegate
,
FSCalendarDelegateAppearance
{
static
let
viewH
:
CGFloat
=
508.0
lazy
var
calendar
:
FSCalendar
=
{
// let calendar = FSCalendar(frame: CGRect(x: 0, y: (navigationController?.navigationBar.frame.maxY)! + 30, width: view.frame.size.width, height: 510))
let
calendar
=
FSCalendar
()
calendar
.
locale
=
NSLocale
(
localeIdentifier
:
"zh-CN"
)
as
Locale
calendar
.
dataSource
=
self
calendar
.
delegate
=
self
calendar
.
pagingEnabled
=
false
calendar
.
allowsMultipleSelection
=
true
calendar
.
rowHeight
=
60
calendar
.
weekdayHeight
=
40
calendar
.
locale
=
Locale
(
identifier
:
"zh-CN"
)
calendar
.
scope
=
.
month
calendar
.
appearance
.
headerDateFormat
=
"yyyy年MM月"
//隐藏 当日的 图片
calendar
.
today
=
nil
calendar
.
register
(
YHRangeDatePickerCell
.
self
,
forCellReuseIdentifier
:
YHRangeDatePickerCell
.
cellReuseIdentifier
)
self
.
calendar
=
calendar
//副标偏移量
calendar
.
appearance
.
subtitleOffset
=
CGPoint
(
x
:
0
,
y
:
16
)
//头部日期 字体
calendar
.
appearance
.
headerTitleFont
=
UIFont
(
name
:
"PingFangSC-Medium"
,
size
:
15
)
//头部日期 颜色
calendar
.
appearance
.
headerTitleColor
=
UIColor
(
red
:
0.071
,
green
:
0.102
,
blue
:
0.149
,
alpha
:
1
)
//头部week 字体
calendar
.
appearance
.
weekdayFont
=
UIFont
(
name
:
"PingFangSC-Regular"
,
size
:
13
)
//头部week 颜色
calendar
.
appearance
.
weekdayTextColor
=
UIColor
(
red
:
0.071
,
green
:
0.102
,
blue
:
0.149
,
alpha
:
1
)
//日历内容 默认颜色
calendar
.
appearance
.
titleDefaultColor
=
UIColor
(
red
:
0.071
,
green
:
0.102
,
blue
:
0.149
,
alpha
:
1
)
//日历内容 字体
calendar
.
appearance
.
titleFont
=
UIFont
(
name
:
"PingFangSC-Medium"
,
size
:
16
)
calendar
.
appearance
.
subtitleFont
=
UIFont
(
name
:
"PingFangSC-Medium"
,
size
:
9
)
//日历内容 选择时 颜色
calendar
.
appearance
.
titleSelectionColor
=
.
white
calendar
.
appearance
.
subtitleSelectionColor
=
.
white
//非当月日期 颜色
calendar
.
appearance
.
titlePlaceholderColor
=
UIColor
(
red
:
0.071
,
green
:
0.102
,
blue
:
0.149
,
alpha
:
0.7
)
//日期 横线
calendar
.
appearance
.
separators
=
.
none
return
calendar
}()
lazy
var
gregorian
:
Calendar
=
{
let
gregorian
=
Calendar
(
identifier
:
.
chinese
)
return
gregorian
}()
lazy
var
dateFormatter
:
DateFormatter
=
{
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd"
return
dateFormatter
}()
// The start date of the range
var
startDate
:
Date
?
// The end date of the range
var
endDate
:
Date
?
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
.
zero
)
setupUI
()
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
}
// MARK: - FSCalendarDataSource
extension
YHRangeDatePickerView
{
func
calendar
(
_
calendar
:
FSCalendar
,
subtitleFor
date
:
Date
)
->
String
?
{
if
let
start
=
startDate
{
if
self
.
gregorian
.
compare
(
start
,
to
:
date
,
toGranularity
:
.
day
)
.
rawValue
==
0
{
return
"开始"
}
}
if
let
end
=
endDate
{
if
self
.
gregorian
.
compare
(
end
,
to
:
date
,
toGranularity
:
.
day
)
.
rawValue
==
0
{
return
"结束"
}
}
return
nil
}
func
minimumDate
(
for
calendar
:
FSCalendar
)
->
Date
{
return
(
dateFormatter
.
date
(
from
:
"2023-07-01"
))
!
}
func
maximumDate
(
for
calendar
:
FSCalendar
)
->
Date
{
return
(
dateFormatter
.
date
(
from
:
"2025-07-01"
))
!
}
func
calendar
(
_
calendar
:
FSCalendar
,
cellFor
date
:
Date
,
at
monthPosition
:
FSCalendarMonthPosition
)
->
FSCalendarCell
{
let
cell
:
YHRangeDatePickerCell
=
calendar
.
dequeueReusableCell
(
withIdentifier
:
YHRangeDatePickerCell
.
cellReuseIdentifier
,
for
:
date
,
at
:
monthPosition
)
as!
YHRangeDatePickerCell
return
cell
}
func
calendar
(
_
calendar
:
FSCalendar
,
willDisplay
cell
:
FSCalendarCell
,
for
date
:
Date
,
at
monthPosition
:
FSCalendarMonthPosition
)
{
configureCell
(
cell
,
for
:
date
,
at
:
monthPosition
)
}
// MARK: - FSCalendarDelegate
func
calendar
(
_
calendar
:
FSCalendar
,
shouldSelect
date
:
Date
,
at
monthPosition
:
FSCalendarMonthPosition
)
->
Bool
{
// return monthPosition == .current
return
true
}
func
calendar
(
_
calendar
:
FSCalendar
,
shouldDeselect
date
:
Date
,
at
monthPosition
:
FSCalendarMonthPosition
)
->
Bool
{
return
false
}
func
calendar
(
_
calendar
:
FSCalendar
,
didSelect
date
:
Date
,
at
monthPosition
:
FSCalendarMonthPosition
)
{
if
monthPosition
==
.
next
||
monthPosition
==
.
previous
{
calendar
.
setCurrentPage
(
date
,
animated
:
true
)
tapOneDate
(
date
)
}
else
{
tapOneDate
(
date
)
}
configureVisibleCells
()
calendar
.
reloadData
()
//for test hjl
}
func
calendar
(
_
calendar
:
FSCalendar
,
didDeselect
date
:
Date
,
at
monthPosition
:
FSCalendarMonthPosition
)
{
let
aDate
=
date
print
(
"did deselect date
\(
String
(
describing
:
dateFormatter
.
string
(
from
:
aDate
))
)
"
)
configureVisibleCells
()
}
// func calendar(_ calendar: FSCalendar, appearance: FSCalendarAppearance, eventDefaultColorsFor date: Date) -> [UIColor]? {
// if (gregorian.isDateInToday(date)) {
// return [UIColor.orange]
// }
// return [appearance.eventDefaultColor]
// }
}
// MARK: - Private methods
private
extension
YHRangeDatePickerView
{
func
setupUI
()
{
addSubview
(
calendar
)
calendar
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
.
offset
(
-
1
)
make
.
left
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
510
)
}
}
func
tapOneDate
(
_
date
:
Date
)
{
if
startDate
==
nil
{
startDate
=
date
}
else
if
endDate
==
nil
{
// 比较结果
let
comparisonResult
=
gregorian
.
compare
(
startDate
!
,
to
:
date
,
toGranularity
:
.
day
)
switch
comparisonResult
{
case
.
orderedAscending
:
print
(
"第一个日期在第二个日期之前"
)
endDate
=
date
case
.
orderedDescending
:
print
(
"第一个日期在第二个日期之后"
)
endDate
=
startDate
startDate
=
date
case
.
orderedSame
:
print
(
"两个日期是同一天"
)
}
}
else
{
calendar
.
deselect
(
startDate
!
)
calendar
.
deselect
(
endDate
!
)
startDate
=
date
endDate
=
nil
}
}
func
configureVisibleCells
()
{
for
obj
in
(
calendar
.
visibleCells
())
{
let
date
:
Date
?
=
self
.
calendar
.
date
(
for
:
obj
)
let
position
:
FSCalendarMonthPosition
=
self
.
calendar
.
monthPosition
(
for
:
obj
)
self
.
configureCell
(
obj
,
for
:
date
!
,
at
:
position
)
}
}
func
configureCell
(
_
cell
:
FSCalendarCell
,
for
date
:
Date
,
at
position
:
FSCalendarMonthPosition
)
{
let
rangeCell
=
cell
as?
YHRangeDatePickerCell
if
position
!=
.
current
{
rangeCell
?
.
middleLayer
.
isHidden
=
true
rangeCell
?
.
selectionLayer
.
isHidden
=
true
return
}
if
(
startDate
!=
nil
)
&&
(
endDate
!=
nil
)
{
// The date is in the middle of the range
let
isMiddle
:
Bool
=
date
.
compare
(
startDate
!
)
!=
date
.
compare
(
endDate
!
)
rangeCell
?
.
middleLayer
.
isHidden
=
!
isMiddle
}
else
{
rangeCell
?
.
middleLayer
.
isHidden
=
true
}
var
isSelected
=
false
let
aDate
=
date
isSelected
=
(
startDate
!=
nil
)
&&
(
gregorian
.
isDate
(
aDate
,
inSameDayAs
:
startDate
!
))
||
(
endDate
!=
nil
)
&&
(
gregorian
.
isDate
(
aDate
,
inSameDayAs
:
endDate
!
))
rangeCell
?
.
selectionLayer
.
isHidden
=
!
isSelected
}
}
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