Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xx messenger iOS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
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
mobile
iOS
xx messenger iOS
Commits
dfeffa09
Commit
dfeffa09
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Remove broken IndexedListCollator
parent
0b7f47e3
No related branches found
No related tags found
1 merge request
!93
Fix connections list index
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/ContactListFeature/Helpers/IndexedListCollator.swift
+0
-53
0 additions, 53 deletions
Sources/ContactListFeature/Helpers/IndexedListCollator.swift
with
0 additions
and
53 deletions
Sources/ContactListFeature/Helpers/IndexedListCollator.swift
deleted
100644 → 0
+
0
−
53
View file @
0b7f47e3
import
UIKit
import
XXModels
public
protocol
IndexableItem
{
var
indexedOn
:
NSString
{
get
}
}
class
IndexedListCollator
<
Item
:
IndexableItem
>
{
private
final
class
CollationWrapper
:
NSObject
{
let
value
:
Any
@objc
let
indexedOn
:
NSString
init
(
value
:
Any
,
indexedOn
:
NSString
)
{
self
.
value
=
value
self
.
indexedOn
=
indexedOn
}
func
unwrappedValue
<
UnwrappedType
>
()
->
UnwrappedType
{
return
value
as!
UnwrappedType
}
}
public
init
()
{}
public
func
sectioned
(
items
:
[
Item
])
->
(
sections
:
[[
Item
]],
collation
:
UILocalizedIndexedCollation
)
{
let
collation
=
UILocalizedIndexedCollation
.
current
()
let
selector
=
#selector
(
getter
:
CollationWrapper
.
indexedOn
)
let
wrappedItems
=
items
.
map
{
item
in
CollationWrapper
(
value
:
item
,
indexedOn
:
item
.
indexedOn
)
}
let
sortedObjects
=
collation
.
sortedArray
(
from
:
wrappedItems
,
collationStringSelector
:
selector
)
as!
[
CollationWrapper
]
var
sections
=
collation
.
sectionIndexTitles
.
map
{
_
in
[
Item
]()
}
sortedObjects
.
forEach
{
item
in
let
sectionNumber
=
collation
.
section
(
for
:
item
,
collationStringSelector
:
selector
)
sections
[
sectionNumber
]
.
append
(
item
.
unwrappedValue
())
}
return
(
sections
:
sections
.
filter
{
!
$0
.
isEmpty
},
collation
:
collation
)
}
}
extension
Contact
:
IndexableItem
{
public
var
indexedOn
:
NSString
{
guard
let
nickname
=
nickname
else
{
return
"
\(
username
!.
first
!
)
"
as
NSString
}
return
"
\(
nickname
.
first
!
)
"
as
NSString
}
}
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