Skip to content

Commit 0299f00

Browse files
committed
Added higlightStyle to SPTableViewCell.
1 parent f674b17 commit 0299f00

File tree

5 files changed

+61
-8
lines changed

5 files changed

+61
-8
lines changed

Example Apps/SparrowKit.xcodeproj/xcshareddata/xcschemes/watchOS Example.xcscheme

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,46 @@
5454
debugDocumentVersioning = "YES"
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES">
57-
<BuildableProductRunnable
58-
runnableDebuggingMode = "0">
57+
<RemoteRunnable
58+
runnableDebuggingMode = "2"
59+
BundleIdentifier = "com.apple.Carousel"
60+
RemotePath = "/(null)">
5961
<BuildableReference
6062
BuildableIdentifier = "primary"
6163
BlueprintIdentifier = "F43F8319265791A0001D9B3D"
6264
BuildableName = "watchOS Example.app"
6365
BlueprintName = "watchOS Example"
6466
ReferencedContainer = "container:SparrowKit.xcodeproj">
6567
</BuildableReference>
66-
</BuildableProductRunnable>
68+
</RemoteRunnable>
6769
</LaunchAction>
6870
<ProfileAction
6971
buildConfiguration = "Release"
7072
shouldUseLaunchSchemeArgsEnv = "YES"
7173
savedToolIdentifier = ""
7274
useCustomWorkingDirectory = "NO"
7375
debugDocumentVersioning = "YES">
74-
<BuildableProductRunnable
75-
runnableDebuggingMode = "0">
76+
<RemoteRunnable
77+
runnableDebuggingMode = "2"
78+
BundleIdentifier = "com.apple.Carousel"
79+
RemotePath = "/(null)">
7680
<BuildableReference
7781
BuildableIdentifier = "primary"
7882
BlueprintIdentifier = "F43F8319265791A0001D9B3D"
7983
BuildableName = "watchOS Example.app"
8084
BlueprintName = "watchOS Example"
8185
ReferencedContainer = "container:SparrowKit.xcodeproj">
8286
</BuildableReference>
83-
</BuildableProductRunnable>
87+
</RemoteRunnable>
88+
<MacroExpansion>
89+
<BuildableReference
90+
BuildableIdentifier = "primary"
91+
BlueprintIdentifier = "F43F8319265791A0001D9B3D"
92+
BuildableName = "watchOS Example.app"
93+
BlueprintName = "watchOS Example"
94+
ReferencedContainer = "container:SparrowKit.xcodeproj">
95+
</BuildableReference>
96+
</MacroExpansion>
8497
</ProfileAction>
8598
<AnalyzeAction
8699
buildConfiguration = "Debug">

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Once you have your Swift package set up, adding as a dependency is as easy as ad
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "https://github.com/ivanvorobei/SparrowKit", .upToNextMajor(from: "3.4.1"))
34+
.package(url: "https://github.com/ivanvorobei/SparrowKit", .upToNextMajor(from: "3.4.6"))
3535
]
3636
```
3737

Sources/SparrowKit/UIKit/Classes/Table/SPTableViewCell.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ open class SPTableViewCell: UITableViewCell {
4848
}
4949
}
5050

51+
/**
52+
SparrowKit: Next level of selection style. Manage changes when cell higlighted.
53+
54+
With it changes also changing `.selectionStyle`.
55+
*/
56+
open var higlightStyle: HiglightStyle = .none {
57+
didSet {
58+
let selectionStyle: UITableViewCell.SelectionStyle = {
59+
switch higlightStyle {
60+
case .none: return .none
61+
case .`default`: return .`default`
62+
case .content: return .none
63+
}
64+
}()
65+
self.selectionStyle = selectionStyle
66+
}
67+
}
68+
5169
// MARK: - Init
5270

5371
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
@@ -88,5 +106,27 @@ open class SPTableViewCell: UITableViewCell {
88106
#endif
89107
}
90108
}
109+
110+
// MARK: - Override
111+
112+
open override func setHighlighted(_ highlighted: Bool, animated: Bool) {
113+
super.setHighlighted(highlighted, animated: animated)
114+
let higlightContent = (higlightStyle == .content)
115+
if higlightContent {
116+
[imageView, textLabel, detailTextLabel].forEach({ $0?.alpha = highlighted ? 0.6 : 1 })
117+
}
118+
}
119+
120+
// MARK: - Models
121+
122+
/**
123+
SparrowKit: Next level of selection style. Manage changes when cell higlighted.
124+
*/
125+
public enum HiglightStyle {
126+
127+
case none
128+
case `default`
129+
case content
130+
}
91131
}
92132
#endif

SparrowKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SparrowKit'
4-
s.version = '3.4.5'
4+
s.version = '3.4.6'
55
s.summary = 'Collection of native Swift extensions to boost your development. Support tvOS and watchOS.'
66
s.homepage = 'https://github.com/ivanvorobei/SparrowKit'
77
s.source = { :git => 'https://github.com/ivanvorobei/SparrowKit.git', :tag => s.version }

0 commit comments

Comments
 (0)