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
ab09c898
Commit
ab09c898
authored
Apr 12, 2024
by
pete谢兆麟
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
9a5785db
' into xiezhaolin
parents
bee5bc29
9a5785db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
2 deletions
+57
-2
YHHomeWebViewController.swift
.../Classes/Modules/Home(首页)/C/YHHomeWebViewController.swift
+9
-1
YHSearchInfomationVC.swift
...axy/Classes/Modules/Home(首页)/C/YHSearchInfomationVC.swift
+40
-0
YHSearchInfoHistoryView.swift
.../Classes/Modules/Home(首页)/V/YHSearchInfoHistoryView.swift
+7
-1
YHSearchItemLayout.swift
...alaxy/Classes/Modules/Home(首页)/V/YHSearchItemLayout.swift
+1
-0
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeWebViewController.swift
View file @
ab09c898
...
...
@@ -108,10 +108,18 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
make
.
bottom
.
left
.
right
.
equalToSuperview
()
make
.
height
.
equalTo
(
59
+
k_Height_safeAreaInsetsBottom
())
}
getData
()
if
id
==
0
{
if
self
.
url
.
contains
(
"?id="
)
{
let
list
=
self
.
url
.
components
(
separatedBy
:
"?id="
)
if
list
.
count
==
2
{
if
let
iddd
=
list
[
1
]
.
int
{
id
=
iddd
return
}
}
}
bottomView
.
isHidden
=
true
webview
.
frame
=
CGRect
(
x
:
0
,
y
:
statusHeight
+
navHeight
!
,
width
:
self
.
view
.
frame
.
width
,
height
:
self
.
view
.
frame
.
height
-
statusHeight
-
navHeight
!
)
}
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHSearchInfomationVC.swift
View file @
ab09c898
...
...
@@ -10,6 +10,8 @@ import UIKit
class
YHSearchInfomationVC
:
YHBaseViewController
{
static
let
searchInfoHistoryKey
=
"searchInfoHistoryKey"
static
let
searchHistoryMaxCount
=
10
var
items
:[
YHHomeListModel
]
=
[]
lazy
var
viewModel
:
YHHomePageViewModel
=
{
...
...
@@ -23,12 +25,16 @@ class YHSearchInfomationVC: YHBaseViewController {
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
searchText
(
self
.
searchBar
.
textField
.
text
??
""
)
if
let
searchText
=
self
.
searchBar
.
textField
.
text
{
self
.
saveSearchHistory
(
searchText
)
}
}
bar
.
textChange
=
{
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
if
isEmptyString
(
text
)
{
searchHistoryView
.
isHidden
=
false
searchHistoryView
.
updateDataSource
(
self
.
getSearchHistoryList
())
items
.
removeAll
()
self
.
tableView
.
reloadData
()
}
...
...
@@ -57,6 +63,7 @@ class YHSearchInfomationVC: YHBaseViewController {
lazy
var
searchHistoryView
:
YHSearchInfoHistoryView
=
{
let
view
=
YHSearchInfoHistoryView
(
frame
:
CGRect
(
x
:
0
,
y
:
searchBar
.
frame
.
maxY
+
8
,
width
:
KScreenWidth
,
height
:
KScreenHeight
-
searchBar
.
frame
.
maxY
-
8
))
view
.
updateDataSource
(
self
.
getSearchHistoryList
())
view
.
selectBlock
=
{
[
weak
self
]
text
in
guard
let
self
=
self
else
{
return
}
...
...
@@ -138,6 +145,39 @@ class YHSearchInfomationVC: YHBaseViewController {
self
.
tableView
.
reloadData
()
}
}
func
getSearchHistoryList
()
->
[
String
]
{
if
let
arr
=
UserDefaults
.
standard
.
array
(
forKey
:
Self
.
searchInfoHistoryKey
)
as?
[
String
]
{
return
arr
}
return
[]
}
func
saveSearchHistory
(
_
text
:
String
)
{
var
arr
=
getSearchHistoryList
()
// 查找历史记录中是否有相同记录
var
targetIndex
=
-
1
for
(
index
,
history
)
in
arr
.
enumerated
()
{
if
history
==
text
{
targetIndex
=
index
break
}
}
// 去除相同记录
if
0
<=
targetIndex
&&
targetIndex
<
arr
.
count
{
arr
.
remove
(
at
:
targetIndex
)
}
// 将最近记录放在第一位
if
arr
.
count
<
Self
.
searchHistoryMaxCount
{
arr
.
insert
(
text
,
at
:
0
)
}
else
{
arr
.
insert
(
text
,
at
:
0
)
arr
.
removeLast
()
}
UserDefaults
.
standard
.
set
(
arr
,
forKey
:
Self
.
searchInfoHistoryKey
)
UserDefaults
.
standard
.
synchronize
()
}
}
extension
YHSearchInfomationVC
:
UITableViewDelegate
,
UITableViewDataSource
{
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHSearchInfoHistoryView.swift
View file @
ab09c898
...
...
@@ -10,7 +10,7 @@ import UIKit
class
YHSearchInfoHistoryView
:
UIView
{
var
historyItems
:[
String
]
=
[
"阿法守法发生懂法守法阿法守法发生懂法守法阿法守法发生懂法守法阿法守法发生懂法守法"
,
"几天萨法"
,
"阿德"
,
"守法"
,
"几天萨法"
,
"德"
,
"阿法守法发生懂法守法"
,
"阿德"
,
"几天"
,
"阿德"
,
"守法"
,
"几天萨法"
]
var
historyItems
:[
String
]
=
[]
// var historyItems:[String] = ["几天2345", "阿", "萨法", "阿德"]
var
selectBlock
:((
String
)
->
())?
...
...
@@ -70,6 +70,12 @@ class YHSearchInfoHistoryView: UIView {
}
}
func
updateDataSource
(
_
arr
:[
String
])
{
historyItems
.
removeAll
()
historyItems
.
append
(
contentsOf
:
arr
)
self
.
collectionView
.
reloadData
()
}
// 计算文字宽度大小
func
getwith
(
font
:
UIFont
,
height
:
CGFloat
,
string
:
String
)
->
CGSize
{
let
size
=
CGSize
.
init
(
width
:
CGFloat
(
MAXFLOAT
),
height
:
height
)
...
...
galaxy/galaxy/Classes/Modules/Home(首页)/V/YHSearchItemLayout.swift
View file @
ab09c898
...
...
@@ -20,6 +20,7 @@ class YHSearchItemLayout: UICollectionViewFlowLayout {
override
func
layoutAttributesForElements
(
in
rect
:
CGRect
)
->
[
UICollectionViewLayoutAttributes
]?
{
let
arrCell
=
super
.
layoutAttributesForElements
(
in
:
rect
)
if
arrCell
==
nil
{
return
nil
}
if
arrCell
!.
count
<=
1
{
return
arrCell
}
for
i
in
1
..<
arrCell
!.
count
{
//当前 UICollectionViewLayoutAttributes
let
currentLayout
=
arrCell
!
[
i
]
...
...
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