Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
2c3be5a2
Commit
2c3be5a2
authored
4 years ago
by
cruxfilm
Browse files
Options
Downloads
Patches
Plain Diff
Simplified code for SearchType and related Picker significantly, keeping functionality identical.
parent
7b4bd92e
No related branches found
No related tags found
1 merge request
!76
Resolve "InboxView & MailListView improvements"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enzevalos_iphone/SwiftUI/Inbox/MailListView.swift
+5
-4
5 additions, 4 deletions
enzevalos_iphone/SwiftUI/Inbox/MailListView.swift
enzevalos_iphone/SwiftUI/SupportingViews/SearchView.swift
+27
-51
27 additions, 51 deletions
enzevalos_iphone/SwiftUI/SupportingViews/SearchView.swift
with
32 additions
and
55 deletions
enzevalos_iphone/SwiftUI/Inbox/MailListView.swift
+
5
−
4
View file @
2c3be5a2
...
@@ -22,8 +22,8 @@ struct MailListView: View {
...
@@ -22,8 +22,8 @@ struct MailListView: View {
@State
var
updating
=
false
@State
var
updating
=
false
@State
var
showUser
=
false
@State
var
showUser
=
false
@State
var
searchText
=
""
@State
var
searchText
=
""
@State
var
searchField
=
0
@State
var
searchField
=
SearchType
.
All
@State
var
searchNow
=
false
//
@State var searchNow = false
@State
var
composeMail
=
false
@State
var
composeMail
=
false
init
(
folderpath
:
String
,
name
:
String
)
{
init
(
folderpath
:
String
,
name
:
String
)
{
...
@@ -44,7 +44,7 @@ struct MailListView: View {
...
@@ -44,7 +44,7 @@ struct MailListView: View {
private
var
mainView
:
some
View
{
private
var
mainView
:
some
View
{
VStack
(
alignment
:
.
leading
){
VStack
(
alignment
:
.
leading
){
SearchView
(
searchText
:
$searchText
,
search
Field
:
$searchField
,
searchNow
:
$searchNow
)
SearchView
(
searchText
:
$searchText
,
search
Type
:
$searchField
)
.
padding
(
6
)
.
padding
(
6
)
mailList
mailList
.
padding
(
-
12
)
.
padding
(
-
12
)
...
@@ -113,7 +113,8 @@ struct MailListView: View {
...
@@ -113,7 +113,8 @@ struct MailListView: View {
}
}
func
filterKeyRecord
(
keyRecord
:
MailRecord
)
->
Bool
{
func
filterKeyRecord
(
keyRecord
:
MailRecord
)
->
Bool
{
let
searchType
=
SearchType
.
findType
(
i
:
searchField
)
// let searchType = SearchType.findType(i: searchField)
let
searchType
=
searchField
if
self
.
searchText
.
isEmpty
if
self
.
searchText
.
isEmpty
||
self
.
searchText
==
NSLocalizedString
(
"Searchbar.Title"
,
comment
:
"Search"
)
{
||
self
.
searchText
==
NSLocalizedString
(
"Searchbar.Title"
,
comment
:
"Search"
)
{
return
true
return
true
...
...
This diff is collapsed.
Click to expand it.
enzevalos_iphone/SwiftUI/SupportingViews/SearchView.swift
+
27
−
51
View file @
2c3be5a2
...
@@ -12,30 +12,11 @@ import Combine
...
@@ -12,30 +12,11 @@ import Combine
/**
/**
Where are we looking for? Used in the search footer.
Where are we looking for? Used in the search footer.
*/
*/
enum
SearchType
:
CaseIterable
{
enum
SearchType
:
LocalizedStringKey
,
CaseIterable
{
case
Sender
,
Subject
,
Body
,
All
case
All
=
"All"
var
text
:
String
{
case
Sender
=
"Sender"
get
{
case
Subject
=
"Subject"
switch
self
{
case
Body
=
"Body"
case
.
Sender
:
return
NSLocalizedString
(
"Sender"
,
comment
:
""
)
case
.
Subject
:
return
NSLocalizedString
(
"Subject"
,
comment
:
""
)
case
.
Body
:
return
NSLocalizedString
(
"Body"
,
comment
:
""
)
case
.
All
:
return
NSLocalizedString
(
"All"
,
comment
:
""
)
}
}
}
static
func
findType
(
i
:
Int
)
->
SearchType
{
if
i
<
SearchType
.
allCases
.
count
{
return
SearchType
.
allCases
[
i
]
}
else
{
return
SearchType
.
All
}
}
}
}
/**
/**
A SearchView for mails with a search segmented Picker to choose the search area.
A SearchView for mails with a search segmented Picker to choose the search area.
...
@@ -43,29 +24,26 @@ enum SearchType: CaseIterable {
...
@@ -43,29 +24,26 @@ enum SearchType: CaseIterable {
*/
*/
struct
SearchView
:
View
{
struct
SearchView
:
View
{
@Binding
var
searchText
:
String
@Binding
var
searchText
:
String
@Binding
var
searchField
:
Int
@Binding
var
searchType
:
SearchType
@Binding
var
searchNow
:
Bool
@State
private
var
showCancelButton
:
Bool
=
false
@State
private
var
showCancelButton
:
Bool
=
false
var
body
:
some
View
{
var
body
:
some
View
{
VStack
{
VStack
{
HStack
{
HStack
{
searchFieldView
searchFieldView
if
showCancelButton
{
if
showCancelButton
{
Button
(
"Cancel"
)
{
Button
(
"Cancel"
)
{
UIApplication
.
shared
.
endEditing
(
true
)
UIApplication
.
shared
.
endEditing
(
true
)
self
.
searchText
=
""
self
.
searchText
=
""
self
.
showCancelButton
=
false
self
.
showCancelButton
=
false
self
.
searchNow
=
false
}
}
.
foregroundColor
(
Color
(
.
systemBlue
))
.
foregroundColor
(
Color
(
.
systemBlue
))
}
}
}
}
if
showCancelButton
{
searchSegment
if
showCancelButton
{
searchTypePicker
}
}
}
}
.
padding
(
.
horizontal
)
.
padding
(
.
horizontal
)
...
@@ -74,16 +52,17 @@ struct SearchView: View {
...
@@ -74,16 +52,17 @@ struct SearchView: View {
var
searchFieldView
:
some
View
{
var
searchFieldView
:
some
View
{
HStack
{
HStack
{
Image
(
systemName
:
"magnifyingglass"
)
Image
(
systemName
:
"magnifyingglass"
)
TextField
(
NSLocalizedString
(
"Searchbar.Title"
,
comment
:
"Search"
),
text
:
$searchText
,
onEditingChanged
:
{
isEditing
in
TextField
(
NSLocalizedString
(
"Searchbar.Title"
,
comment
:
"Search"
),
text
:
$searchText
)
{
_
in
self
.
showCancelButton
=
true
self
.
showCancelButton
=
true
},
onCommit
:
{
}
self
.
searchNow
=
true
.
foregroundColor
(
.
primary
)
})
.
foregroundColor
(
.
primary
)
Button
{
Button
(
action
:
{
self
.
searchText
=
""
self
.
searchText
=
""
})
{
}
label
:
{
Image
(
systemName
:
"xmark.circle.fill"
)
.
opacity
(
searchText
==
""
?
0
:
1
)
Image
(
systemName
:
"xmark.circle.fill"
)
.
opacity
(
searchText
==
""
?
0
:
1
)
}
}
}
}
.
padding
(
EdgeInsets
(
top
:
8
,
leading
:
6
,
bottom
:
8
,
trailing
:
6
))
.
padding
(
EdgeInsets
(
top
:
8
,
leading
:
6
,
bottom
:
8
,
trailing
:
6
))
...
@@ -92,13 +71,10 @@ struct SearchView: View {
...
@@ -92,13 +71,10 @@ struct SearchView: View {
.
cornerRadius
(
10.0
)
.
cornerRadius
(
10.0
)
}
}
var
searchSegment
:
some
View
{
var
searchTypePicker
:
some
View
{
Picker
(
selection
:
$searchField
,
label
:
EmptyView
())
{
Picker
(
"Hellooo"
,
selection
:
$searchType
)
{
ForEach
(
0
..<
SearchType
.
allCases
.
count
)
{
index
in
ForEach
(
SearchType
.
allCases
,
id
:
\
.
self
)
{
searchType
in
Text
(
SearchType
.
allCases
[
index
]
.
text
)
.
tag
(
index
)
Text
(
searchType
.
rawValue
)
.
onTapGesture
{
self
.
searchField
=
index
}
}
}
}
}
.
pickerStyle
(
SegmentedPickerStyle
())
.
pickerStyle
(
SegmentedPickerStyle
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment