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
c25810c3
Commit
c25810c3
authored
Jun 03, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 删除历史搜索记录
parent
9762ec05
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
2 deletions
+69
-2
YHSearchInfomationVC.swift
...axy/Classes/Modules/Home(首页)/C/YHSearchInfomationVC.swift
+25
-0
YHSearchInfoHistoryView.swift
.../Classes/Modules/Home(首页)/V/YHSearchInfoHistoryView.swift
+22
-2
Contents.json
....xcassets/Home/home_history_delete.imageset/Contents.json
+22
-0
delete@2x.png
....xcassets/Home/home_history_delete.imageset/delete@2x.png
+0
-0
delete@3x.png
....xcassets/Home/home_history_delete.imageset/delete@3x.png
+0
-0
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHSearchInfomationVC.swift
View file @
c25810c3
...
...
@@ -129,6 +129,17 @@ class YHSearchInfomationVC: YHBaseViewController {
searchText
()
self
.
saveSearchHistory
(
text
)
}
view
.
deleteBlock
=
{
[
weak
self
]
in
guard
let
self
=
self
else
{
return
}
self
.
view
.
endEditing
(
true
)
let
arr
=
self
.
getSearchHistoryList
()
if
arr
.
count
<=
0
{
YHHUD
.
flash
(
message
:
"暂无搜索记录~"
)
return
}
self
.
showDeleteHistoryAlertView
()
}
return
view
}()
...
...
@@ -179,6 +190,15 @@ class YHSearchInfomationVC: YHBaseViewController {
}
}
func
showDeleteHistoryAlertView
()
{
YHCommonAlertView
.
show
(
""
,
"确认删除全部历史搜索记录?"
,
"取消"
,
"确认"
)
{
}
callBack
:
{
self
.
deleteAllSearchHistory
()
self
.
searchHistoryView
.
updateDataSource
([])
}
}
func
searchText
()
{
self
.
tableView
.
scrollToTop
()
YHHUD
.
show
(
.
progress
(
message
:
"搜索中..."
))
...
...
@@ -272,6 +292,11 @@ class YHSearchInfomationVC: YHBaseViewController {
return
[]
}
func
deleteAllSearchHistory
()
{
UserDefaults
.
standard
.
set
([],
forKey
:
searchInfoHistoryKey
)
UserDefaults
.
standard
.
synchronize
()
}
func
saveSearchHistory
(
_
text
:
String
)
{
if
isEmptyString
(
text
)
{
return
}
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHSearchInfoHistoryView.swift
View file @
c25810c3
...
...
@@ -14,19 +14,27 @@ class YHSearchInfoHistoryView: UIView {
// var historyItems:[String] = ["几天2345", "阿", "萨法", "阿德"]
var
selectBlock
:((
String
)
->
())?
var
deleteBlock
:(()
->
())?
let
interItemSpacing
:
CGFloat
=
12.0
// 相邻单元格之间的水平间距
let
gap
:
CGFloat
=
12.0
let
cellHeight
:
CGFloat
=
30.0
// 单元格的固定高度
lazy
var
titleLabel
:
UILabel
=
{
var
label
=
UILabel
()
let
label
=
UILabel
()
label
.
font
=
.
PFSC_R
(
ofSize
:
14
)
label
.
textColor
=
UIColor
(
hex
:
0x94A3B8
)
label
.
text
=
"历史搜索"
return
label
}()
lazy
var
deleteAllBtn
:
UIButton
=
{
let
btn
=
UIButton
()
btn
.
setImage
(
UIImage
(
named
:
"home_history_delete"
),
for
:
.
normal
)
btn
.
addTarget
(
self
,
action
:
#selector(
didDeleteAllBtnClicked
)
,
for
:
.
touchUpInside
)
btn
.
YH_clickEdgeInsets
=
UIEdgeInsets
(
top
:
20
,
left
:
20
,
bottom
:
20
,
right
:
20
)
return
btn
}()
lazy
var
collectionView
:
UICollectionView
=
{
// 创建集合视图布局
let
layout
=
YHSearchItemLayout
()
...
...
@@ -54,6 +62,7 @@ class YHSearchInfoHistoryView: UIView {
func
setupUI
()
{
self
.
addSubview
(
titleLabel
)
self
.
addSubview
(
deleteAllBtn
)
self
.
addSubview
(
collectionView
)
titleLabel
.
snp
.
makeConstraints
{
make
in
...
...
@@ -63,6 +72,12 @@ class YHSearchInfoHistoryView: UIView {
make
.
height
.
equalTo
(
20.0
)
}
deleteAllBtn
.
snp
.
makeConstraints
{
make
in
make
.
width
.
height
.
equalTo
(
16
)
make
.
right
.
equalTo
(
-
20
)
make
.
centerY
.
equalTo
(
titleLabel
)
}
collectionView
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalTo
(
titleLabel
.
snp
.
bottom
)
.
offset
(
15.0
)
make
.
left
.
right
.
equalTo
(
titleLabel
)
...
...
@@ -75,6 +90,11 @@ class YHSearchInfoHistoryView: UIView {
historyItems
.
append
(
contentsOf
:
arr
)
self
.
collectionView
.
reloadData
()
titleLabel
.
isHidden
=
arr
.
count
<=
0
deleteAllBtn
.
isHidden
=
arr
.
count
<=
0
}
@objc
func
didDeleteAllBtnClicked
()
{
deleteBlock
?()
}
// 计算文字宽度大小
...
...
galaxy/galaxy/Res/Assets.xcassets/Home/home_history_delete.imageset/Contents.json
0 → 100644
View file @
c25810c3
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"delete@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"delete@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
galaxy/galaxy/Res/Assets.xcassets/Home/home_history_delete.imageset/delete@2x.png
0 → 100644
View file @
c25810c3
521 Bytes
galaxy/galaxy/Res/Assets.xcassets/Home/home_history_delete.imageset/delete@3x.png
0 → 100644
View file @
c25810c3
656 Bytes
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