Skip to content

Commit fbdb5b4

Browse files
committed
Rewrite Haptic feedback; Supported Swift 6
1 parent 67d5503 commit fbdb5b4

File tree

26 files changed

+514
-387
lines changed

26 files changed

+514
-387
lines changed

.DS_Store

10 KB
Binary file not shown.

.github/.DS_Store

6 KB
Binary file not shown.

.github/workflows/.DS_Store

6 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG
22

3+
## [0.2.1] - 2025-01-06
4+
5+
### Added
6+
- Support Swift 6.0
7+
8+
### Changed
9+
- Rewrite Haptic Feedback from UIFeedbackGenerator to CoreHaptic
10+
311
## [0.2.0] - 2024-04-06
412

513
### Added

RKSlider/.DS_Store

10 KB
Binary file not shown.

Slider.xcodeproj/project.pbxproj

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 63;
6+
objectVersion = 77;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -23,8 +23,10 @@
2323
4B8DAEA12BA6A5E9005CFA82 /* CodeViewController+UIColorPickerViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8DAEA02BA6A5E9005CFA82 /* CodeViewController+UIColorPickerViewControllerDelegate.swift */; };
2424
4B8DAEA42BA6AE54005CFA82 /* ThumbLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8DAEA22BA6ACFF005CFA82 /* ThumbLayer.swift */; };
2525
4B8DAEA62BA6B445005CFA82 /* TextLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8DAEA52BA6B445005CFA82 /* TextLayer.swift */; };
26+
4BB580D52D2BDB97009BFA02 /* HapticManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB580D42D2BDB93009BFA02 /* HapticManager.swift */; };
27+
4BB580D72D2BDD2B009BFA02 /* LoggerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB580D62D2BDD27009BFA02 /* LoggerManager.swift */; };
28+
4BB580D92D2BDFDF009BFA02 /* HapticConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB580D82D2BDFDA009BFA02 /* HapticConfiguration.swift */; };
2629
4BC808B92BC1A005001F31C8 /* Documentation.docc in Sources */ = {isa = PBXBuildFile; fileRef = 4BC808B82BC1A005001F31C8 /* Documentation.docc */; };
27-
4BF628A12BA2B38D0093637E /* HapticConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF628922BA2B38D0093637E /* HapticConfiguration.swift */; };
2830
4BF628A32BA2B38D0093637E /* Slider+UITouch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF628962BA2B38D0093637E /* Slider+UITouch.swift */; };
2931
4BF628A42BA2B38D0093637E /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF628972BA2B38D0093637E /* String.swift */; };
3032
4BF628A52BA2B38D0093637E /* SliderDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BF628992BA2B38D0093637E /* SliderDelegate.swift */; };
@@ -75,8 +77,10 @@
7577
4B8DAEA02BA6A5E9005CFA82 /* CodeViewController+UIColorPickerViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CodeViewController+UIColorPickerViewControllerDelegate.swift"; sourceTree = "<group>"; };
7678
4B8DAEA22BA6ACFF005CFA82 /* ThumbLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbLayer.swift; sourceTree = "<group>"; };
7779
4B8DAEA52BA6B445005CFA82 /* TextLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextLayer.swift; sourceTree = "<group>"; };
80+
4BB580D42D2BDB93009BFA02 /* HapticManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticManager.swift; sourceTree = "<group>"; };
81+
4BB580D62D2BDD27009BFA02 /* LoggerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerManager.swift; sourceTree = "<group>"; };
82+
4BB580D82D2BDFDA009BFA02 /* HapticConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticConfiguration.swift; sourceTree = "<group>"; };
7883
4BC808B82BC1A005001F31C8 /* Documentation.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = Documentation.docc; sourceTree = "<group>"; };
79-
4BF628922BA2B38D0093637E /* HapticConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HapticConfiguration.swift; sourceTree = "<group>"; };
8084
4BF628962BA2B38D0093637E /* Slider+UITouch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Slider+UITouch.swift"; sourceTree = "<group>"; };
8185
4BF628972BA2B38D0093637E /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
8286
4BF628992BA2B38D0093637E /* SliderDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderDelegate.swift; sourceTree = "<group>"; };
@@ -212,10 +216,19 @@
212216
path = Manager;
213217
sourceTree = "<group>";
214218
};
219+
4BB580D32D2BDB8D009BFA02 /* Managers */ = {
220+
isa = PBXGroup;
221+
children = (
222+
4BB580D62D2BDD27009BFA02 /* LoggerManager.swift */,
223+
4BB580D42D2BDB93009BFA02 /* HapticManager.swift */,
224+
);
225+
path = Managers;
226+
sourceTree = "<group>";
227+
};
215228
4BF628932BA2B38D0093637E /* Configurations */ = {
216229
isa = PBXGroup;
217230
children = (
218-
4BF628922BA2B38D0093637E /* HapticConfiguration.swift */,
231+
4BB580D82D2BDFDA009BFA02 /* HapticConfiguration.swift */,
219232
4B8DAE972BA6956B005CFA82 /* TrackConfiguration.swift */,
220233
4B8DAE992BA696A8005CFA82 /* ThumbConfiguration.swift */,
221234
4B8DAE9B2BA69A69005CFA82 /* RangeEndpointsConfiguration.swift */,
@@ -243,6 +256,7 @@
243256
4BF628A02BA2B38D0093637E /* Sources */ = {
244257
isa = PBXGroup;
245258
children = (
259+
4BB580D32D2BDB8D009BFA02 /* Managers */,
246260
4BF628932BA2B38D0093637E /* Configurations */,
247261
4BF628982BA2B38D0093637E /* Extensions */,
248262
4BF6289A2BA2B38D0093637E /* Protocols */,
@@ -318,7 +332,7 @@
318332
attributes = {
319333
BuildIndependentTargetsInParallel = YES;
320334
LastSwiftUpdateCheck = 1130;
321-
LastUpgradeCheck = 1530;
335+
LastUpgradeCheck = 1610;
322336
ORGANIZATIONNAME = "Ramiz Kichibekov";
323337
TargetAttributes = {
324338
4B2EB6C123C1E11E00FB91AD = {
@@ -331,16 +345,17 @@
331345
};
332346
};
333347
buildConfigurationList = 4B2EB6BC23C1E11E00FB91AD /* Build configuration list for PBXProject "Slider" */;
334-
compatibilityVersion = "Xcode 15.3";
335348
developmentRegion = en;
336349
hasScannedForEncodings = 0;
337350
knownRegions = (
338351
en,
339352
Base,
340353
);
341354
mainGroup = 4B2EB6B823C1E11E00FB91AD;
355+
minimizedProjectReferenceProxies = 1;
342356
packageReferences = (
343357
);
358+
preferredProjectObjectVersion = 77;
344359
productRefGroup = 4B2EB6C323C1E11F00FB91AD /* Products */;
345360
projectDirPath = "";
346361
projectRoot = "";
@@ -376,18 +391,20 @@
376391
isa = PBXSourcesBuildPhase;
377392
buildActionMask = 2147483647;
378393
files = (
394+
4BB580D52D2BDB97009BFA02 /* HapticManager.swift in Sources */,
379395
4BF628A52BA2B38D0093637E /* SliderDelegate.swift in Sources */,
380396
4BF628A32BA2B38D0093637E /* Slider+UITouch.swift in Sources */,
397+
4BB580D72D2BDD2B009BFA02 /* LoggerManager.swift in Sources */,
381398
4B8DAE9C2BA69A69005CFA82 /* RangeEndpointsConfiguration.swift in Sources */,
382399
4BF628A42BA2B38D0093637E /* String.swift in Sources */,
383400
4B8DAE9A2BA696A8005CFA82 /* ThumbConfiguration.swift in Sources */,
401+
4BB580D92D2BDFDF009BFA02 /* HapticConfiguration.swift in Sources */,
384402
4BF628A82BA2B38D0093637E /* Slider.swift in Sources */,
385403
4B8DAEA62BA6B445005CFA82 /* TextLayer.swift in Sources */,
386404
4BC808B92BC1A005001F31C8 /* Documentation.docc in Sources */,
387405
4BF628AA2BA2B38D0093637E /* SliderTrackLayer.swift in Sources */,
388406
4B8DAE982BA6956B005CFA82 /* TrackConfiguration.swift in Sources */,
389407
4B8DAEA42BA6AE54005CFA82 /* ThumbLayer.swift in Sources */,
390-
4BF628A12BA2B38D0093637E /* HapticConfiguration.swift in Sources */,
391408
);
392409
runOnlyForDeploymentPostprocessing = 0;
393410
};
@@ -495,6 +512,7 @@
495512
SDKROOT = iphoneos;
496513
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
497514
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
515+
SWIFT_VERSION = 6.0;
498516
VERSIONING_SYSTEM = "apple-generic";
499517
VERSION_INFO_PREFIX = "";
500518
};
@@ -554,6 +572,7 @@
554572
SDKROOT = iphoneos;
555573
SWIFT_COMPILATION_MODE = wholemodule;
556574
SWIFT_OPTIMIZATION_LEVEL = "-O";
575+
SWIFT_VERSION = 6.0;
557576
VALIDATE_PRODUCT = YES;
558577
VERSIONING_SYSTEM = "apple-generic";
559578
VERSION_INFO_PREFIX = "";
@@ -585,7 +604,7 @@
585604
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
586605
SKIP_INSTALL = YES;
587606
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
588-
SWIFT_VERSION = 5.0;
607+
SWIFT_VERSION = 6.0;
589608
TARGETED_DEVICE_FAMILY = "1,2";
590609
};
591610
name = Debug;
@@ -614,15 +633,14 @@
614633
PRODUCT_BUNDLE_IDENTIFIER = "Ramiz-Kichibekov.Slider";
615634
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
616635
SKIP_INSTALL = YES;
617-
SWIFT_VERSION = 5.0;
636+
SWIFT_VERSION = 6.0;
618637
TARGETED_DEVICE_FAMILY = "1,2";
619638
};
620639
name = Release;
621640
};
622641
4B2EB6F423C1E5AA00FB91AD /* Debug */ = {
623642
isa = XCBuildConfiguration;
624643
buildSettings = {
625-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
626644
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
627645
CODE_SIGN_STYLE = Automatic;
628646
DEVELOPMENT_TEAM = 8AD8N54BY6;
@@ -634,15 +652,14 @@
634652
);
635653
PRODUCT_BUNDLE_IDENTIFIER = "Ramiz-Kichibekov.Slider-Example";
636654
PRODUCT_NAME = "$(TARGET_NAME)";
637-
SWIFT_VERSION = 5.0;
655+
SWIFT_VERSION = 6.0;
638656
TARGETED_DEVICE_FAMILY = "1,2";
639657
};
640658
name = Debug;
641659
};
642660
4B2EB6F523C1E5AA00FB91AD /* Release */ = {
643661
isa = XCBuildConfiguration;
644662
buildSettings = {
645-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
646663
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
647664
CODE_SIGN_STYLE = Automatic;
648665
DEVELOPMENT_TEAM = 8AD8N54BY6;
@@ -654,7 +671,7 @@
654671
);
655672
PRODUCT_BUNDLE_IDENTIFIER = "Ramiz-Kichibekov.Slider-Example";
656673
PRODUCT_NAME = "$(TARGET_NAME)";
657-
SWIFT_VERSION = 5.0;
674+
SWIFT_VERSION = 6.0;
658675
TARGETED_DEVICE_FAMILY = "1,2";
659676
};
660677
name = Release;

Slider.xcodeproj/xcshareddata/xcschemes/Slider.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1530"
3+
LastUpgradeVersion = "1610"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

Slider.xcodeproj/xcshareddata/xcschemes/Slider_Example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1530"
3+
LastUpgradeVersion = "1610"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Slider_Example/.DS_Store

6 KB
Binary file not shown.

Slider_Example/Application/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424

2525
import UIKit
2626

27-
@UIApplicationMain
27+
@main
2828
final class AppDelegate: UIResponder, UIApplicationDelegate {
2929

3030
func application(_ application: UIApplication,
3131
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
32-
return true
32+
true
3333
}
3434

3535
// MARK: UISceneSession Lifecycle
3636

3737
func application(_ application: UIApplication,
3838
configurationForConnecting connectingSceneSession: UISceneSession,
3939
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
40-
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
40+
UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
4141
}
4242

4343
func application(_ application: UIApplication,

Slider_Example/Flows/.DS_Store

6 KB
Binary file not shown.

Slider_Example/Flows/Main/.DS_Store

6 KB
Binary file not shown.

Slider_Example/Flows/Main/Controllers/CodeViewController.swift

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ final class CodeViewController: UIViewController {
115115
slider.minimum = .zero
116116
slider.value = .zero
117117
slider.animationStyle = .default
118+
118119
view.addSubview(slider)
119120
slider.translatesAutoresizingMaskIntoConstraints = false
120121
let layoutMarginsGuide = view.layoutMarginsGuide
@@ -132,23 +133,26 @@ final class CodeViewController: UIViewController {
132133
}
133134

134135
private func configureHaptic() {
135-
slider.hapticConfiguration = .init(reachLimitValueHapticEnabled: preference.hapticPreference.reachMinMaxValues,
136-
changeValueHapticEnabled: preference.hapticPreference.valueChanges,
137-
changeDirectionHapticEnabled: preference.hapticPreference.directionChanges,
138-
reachImpactGeneratorStyle: .medium,
139-
changeValueImpactGeneratorStyle: .light)
136+
var kind: HapticConfiguration.Kind = [.transient, .continuous]
137+
if preference.hapticPreference.transient {
138+
kind.insert(.transient)
139+
} else {
140+
kind.remove(.transient)
141+
}
142+
if preference.hapticPreference.continuous {
143+
kind.insert(.continuous)
144+
} else {
145+
kind.remove(.continuous)
146+
}
147+
slider.hapticConfiguration = HapticConfiguration(kind: kind)
140148
configurePreferenceMenu()
141149
}
142150

143151
private func resetSlider() {
144-
slider.hapticConfiguration = .init(reachLimitValueHapticEnabled: preference.hapticPreference.reachMinMaxValues,
145-
changeValueHapticEnabled: preference.hapticPreference.valueChanges,
146-
changeDirectionHapticEnabled: preference.hapticPreference.directionChanges,
147-
reachImpactGeneratorStyle: .medium,
148-
changeValueImpactGeneratorStyle: .light)
149-
slider.thumbConfiguration = .init()
150-
slider.maximumEndpointConfiguration = .init()
151-
slider.minimumEndpointConfiguration = .init()
152+
slider.hapticConfiguration = HapticConfiguration()
153+
slider.thumbConfiguration = ThumbConfiguration()
154+
slider.maximumEndpointConfiguration = RangeEndpointsConfiguration()
155+
slider.minimumEndpointConfiguration = RangeEndpointsConfiguration()
152156
}
153157

154158
private func configurePreferenceMenu() {
@@ -224,25 +228,20 @@ final class CodeViewController: UIViewController {
224228

225229
private func configureHapticMenu() -> UIMenu {
226230
let hapticPreference = preference.hapticPreference
227-
let reachAction = UIAction(title: "Reach Min/Max values",
228-
state: hapticPreference.reachMinMaxValues ? .on : .off) { [unowned self] _ in
229-
hapticPreference.reachMinMaxValues.toggle()
231+
let transientAction = UIAction(title: "Transient",
232+
state: hapticPreference.transient ? .on : .off) { [unowned self] _ in
233+
hapticPreference.transient.toggle()
230234
self.configureHaptic()
231235
}
232-
let valueChangeAction = UIAction(title: "Value changes",
233-
state: hapticPreference.valueChanges ? .on : .off) { [unowned self] _ in
234-
hapticPreference.valueChanges.toggle()
236+
let continuousAction = UIAction(title: "Continuous",
237+
state: hapticPreference.continuous ? .on : .off) { [unowned self] _ in
238+
hapticPreference.continuous.toggle()
235239
self.configureHaptic()
236240
}
237-
let directionChangeAction = UIAction(title: "Direction changes",
238-
state: hapticPreference.directionChanges ? .on : .off) { [unowned self] _ in
239-
hapticPreference.directionChanges.toggle()
240-
self.configureHaptic()
241-
}
242-
241+
243242
return UIMenu(title: "Haptic",
244243
image: UIImage(systemName: "iphone.gen3.radiowaves.left.and.right"),
245-
children: [reachAction, valueChangeAction, directionChangeAction])
244+
children: [transientAction, continuousAction])
246245
}
247246

248247
private func configureEndpointMenu() -> UIMenu {
@@ -296,7 +295,7 @@ final class CodeViewController: UIViewController {
296295
}
297296
}
298297

299-
extension CATextLayerAlignmentMode: CaseIterable {
298+
extension CATextLayerAlignmentMode: @retroactive CaseIterable {
300299
public static var allCases: [CATextLayerAlignmentMode] {
301300
[.left, .natural, .center, .right, .justified]
302301
}

0 commit comments

Comments
 (0)