From 344806779c2030323a6f88269adee12622274d78 Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Fri, 8 Jun 2018 09:22:49 +0200 Subject: [PATCH 1/8] Added Unit Tests --- Tests/WhatsNewViewControllerTests.swift | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Tests/WhatsNewViewControllerTests.swift b/Tests/WhatsNewViewControllerTests.swift index e962b75..9cdfeb1 100644 --- a/Tests/WhatsNewViewControllerTests.swift +++ b/Tests/WhatsNewViewControllerTests.swift @@ -25,8 +25,52 @@ class WhatsNewViewControllerTests: BaseTests { XCTAssert(versionStore.has(version: self.randomWhatsNew.version)) } + func testWhatsNewPassedToControllerEquatable() { + let whatsNewViewController = WhatsNewViewController(whatsNew: self.randomWhatsNew) + XCTAssertEqual(self.randomWhatsNew, whatsNewViewController.whatsNew) + } + func testCoderInitializer() { XCTAssertNil(WhatsNewViewController(coder: .init())) } + func testPresent() { + let whatsNewViewController = WhatsNewViewController(whatsNew: self.randomWhatsNew) + class FakeViewController: UIViewController { + var viewControllerToPresent: UIViewController? + var shouldAnimate: Bool? + override func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { + self.viewControllerToPresent = viewControllerToPresent + self.shouldAnimate = flag + completion?() + } + } + let fakeViewViewController = FakeViewController() + let animated = true + self.performTest(execution: { expectation in + whatsNewViewController.present(on: fakeViewViewController, animated: animated, completion: { + XCTAssert(fakeViewViewController.viewControllerToPresent === whatsNewViewController) + XCTAssertEqual(fakeViewViewController.shouldAnimate, true) + expectation.fulfill() + }) + }) + } + + func testPush() { + let whatsNewViewController = WhatsNewViewController(whatsNew: self.randomWhatsNew) + class FakeNavigationController: UINavigationController { + var pushedViewController: UIViewController? + var shouldAnimate: Bool? + override func pushViewController(_ viewController: UIViewController, animated: Bool) { + self.pushedViewController = viewController + self.shouldAnimate = animated + } + } + let fakeNavigationController = FakeNavigationController() + let animated = true + whatsNewViewController.push(on: fakeNavigationController, animated: animated) + XCTAssert(fakeNavigationController.pushedViewController === whatsNewViewController) + XCTAssertEqual(fakeNavigationController.shouldAnimate, animated) + } + } From c4c7dd4668bd2450c205eb453dddae9ff5870aed Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Sat, 9 Jun 2018 11:32:58 +0200 Subject: [PATCH 2/8] Added ImpactFeedbackStyle --- ...WhatsNewViewController+HapticFeedback.swift | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/Configuration/WhatsNewViewController+HapticFeedback.swift b/Sources/Configuration/WhatsNewViewController+HapticFeedback.swift index 8ff00b0..72ab27b 100644 --- a/Sources/Configuration/WhatsNewViewController+HapticFeedback.swift +++ b/Sources/Configuration/WhatsNewViewController+HapticFeedback.swift @@ -12,29 +12,29 @@ public extension WhatsNewViewController { /// The HapticFeedback Enumeration enum HapticFeedback: Equatable { - /// ImpactFeedback - case impact + /// ImpactFeedback with FeedbackStyle + case impact(UIImpactFeedbackStyle) /// SelectionFeedback case selection /// NotificationFeedback with FeedbackType case notification(UINotificationFeedbackType) - /// Execute Feedback + /// Execute HapticFeedback func execute() { // Switch on self switch self { - case .impact: - // UIImpactFeedbackGenerator - let impactFeedbackGenerator = UIImpactFeedbackGenerator() - impactFeedbackGenerator.impactOccurred() + case .impact(let style): + // UIFeedbackGenerator + let feedbackGenerator = UIImpactFeedbackGenerator(style: style) + feedbackGenerator.impactOccurred() case .selection: // UISelectionFeedbackGenerator let selectionFeedbackGenerator = UISelectionFeedbackGenerator() selectionFeedbackGenerator.selectionChanged() - case .notification(let feedbackType): + case .notification(let type): // UINotificationFeedbackGenerator let notificationFeedbackGenerator = UINotificationFeedbackGenerator() - notificationFeedbackGenerator.notificationOccurred(feedbackType) + notificationFeedbackGenerator.notificationOccurred(type) } } From ac8425386b18f534a35a47be71cf4bd7662e8374 Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Sat, 9 Jun 2018 11:33:58 +0200 Subject: [PATCH 3/8] Updated ReadMe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90131d2..d44fa8d 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ You can enable on both `DetailButton` and `CompletionButton` haptic feedback whe ```swift // Impact Feedback -button.hapticFeedback = .impact +button.hapticFeedback = .impact(.medium) // Selection Feedback button.hapticFeedback = .selection From 280d7cd37e2e813779293282852726242e575633 Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Sat, 9 Jun 2018 11:38:39 +0200 Subject: [PATCH 4/8] Updated Bundle Identifier and Version --- Configs/WhatsNewKit.plist | 2 +- Example/Supporting Files/Info.plist | 2 +- WhatsNewKit.xcodeproj/project.pbxproj | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Configs/WhatsNewKit.plist b/Configs/WhatsNewKit.plist index e9c0236..8d0c088 100644 --- a/Configs/WhatsNewKit.plist +++ b/Configs/WhatsNewKit.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 1.1.0 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index d81eabf..db032f4 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1.0 CFBundleVersion 1 LSRequiresIPhoneOS diff --git a/WhatsNewKit.xcodeproj/project.pbxproj b/WhatsNewKit.xcodeproj/project.pbxproj index c138fd8..3147da2 100644 --- a/WhatsNewKit.xcodeproj/project.pbxproj +++ b/WhatsNewKit.xcodeproj/project.pbxproj @@ -633,7 +633,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = de.tiigi.Example; + PRODUCT_BUNDLE_IDENTIFIER = de.tiigi.WhatsNewKit.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_VERSION = 4.0; @@ -662,7 +662,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = de.tiigi.Example; + PRODUCT_BUNDLE_IDENTIFIER = de.tiigi.WhatsNewKit.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; @@ -801,7 +801,7 @@ ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ""; OTHER_SWIFT_FLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = "com.WhatsNewKit.WhatsNewKit-iOS"; + PRODUCT_BUNDLE_IDENTIFIER = "de.tiigi.WhatsNewKit.WhatsNewKit-iOS"; PRODUCT_NAME = WhatsNewKit; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -828,7 +828,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; OTHER_LDFLAGS = ""; OTHER_SWIFT_FLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = "com.WhatsNewKit.WhatsNewKit-iOS"; + PRODUCT_BUNDLE_IDENTIFIER = "de.tiigi.WhatsNewKit.WhatsNewKit-iOS"; PRODUCT_NAME = WhatsNewKit; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; From 3f805548b07ca7493e39b4571e314a0058d86942 Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Sat, 9 Jun 2018 11:43:40 +0200 Subject: [PATCH 5/8] Added increment version number to fastfile --- fastlane/Fastfile | 1 + 1 file changed, 1 insertion(+) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 8ff344e..3084593 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -10,6 +10,7 @@ platform :ios do ensure_git_branch(branch: 'master') test version = version_bump_podspec(path: "WhatsNewKit.podspec", version_number: options[:version]) + increment_version_number(version_number: version) git_commit( path: ["WhatsNewKit.podspec"], message: "[WhatsNewKit Release 🚀] Bump to #{version}" From a25d80733f683ae7be91b9b4cac130e0b0440dcf Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Mon, 11 Jun 2018 23:25:06 +0200 Subject: [PATCH 6/8] Refactored set and has to store String representation instead of Version struct --- Sources/Store/KeyValueWhatsNewVersionStore.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Store/KeyValueWhatsNewVersionStore.swift b/Sources/Store/KeyValueWhatsNewVersionStore.swift index 98bf68b..268d952 100644 --- a/Sources/Store/KeyValueWhatsNewVersionStore.swift +++ b/Sources/Store/KeyValueWhatsNewVersionStore.swift @@ -85,7 +85,7 @@ extension KeyValueWhatsNewVersionStore: WriteableWhatsNewVersionStore { /// - Parameter version: The Version public func set(version: WhatsNew.Version) { // Set Version - self.keyValueable.set(version, forKey: self.key(forVersion: version)) + self.keyValueable.set(version.description, forKey: self.key(forVersion: version)) } } @@ -100,7 +100,7 @@ extension KeyValueWhatsNewVersionStore: ReadableWhatsNewVersionStore { /// - Returns: Bool if Version has been presented public func has(version: WhatsNew.Version) -> Bool { // Retrieve object for key and return comparison result with the WhatsNew.Version - return self.keyValueable.object(forKey: self.key(forVersion: version)) as? WhatsNew.Version == version + return self.keyValueable.object(forKey: self.key(forVersion: version)) as? String == version.description } } From 75077eb14cf1d815501aa496440bccec173dc605 Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Mon, 11 Jun 2018 23:26:07 +0200 Subject: [PATCH 7/8] Updated Version Number --- Configs/WhatsNewKit.plist | 2 +- Example/Supporting Files/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Configs/WhatsNewKit.plist b/Configs/WhatsNewKit.plist index 8d0c088..bfa51cb 100644 --- a/Configs/WhatsNewKit.plist +++ b/Configs/WhatsNewKit.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.0 + 1.1.1 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index db032f4..63f7dad 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1.0 + 1.1.1 CFBundleVersion 1 LSRequiresIPhoneOS From 6457ccc0eba097b003f085b7295986d123a8b6f5 Mon Sep 17 00:00:00 2001 From: Sven Tiigi Date: Mon, 11 Jun 2018 23:26:57 +0200 Subject: [PATCH 8/8] Updated Unit Tests --- Tests/Stores/KeyValueWhatsNewVersionStoreTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Stores/KeyValueWhatsNewVersionStoreTests.swift b/Tests/Stores/KeyValueWhatsNewVersionStoreTests.swift index 415f50b..812f114 100644 --- a/Tests/Stores/KeyValueWhatsNewVersionStoreTests.swift +++ b/Tests/Stores/KeyValueWhatsNewVersionStoreTests.swift @@ -26,7 +26,7 @@ class KeyValueWhatsNewVersionStoreTests: BaseTests { let randomWhatsNewVersion = self.randomWhatsNew.version keyValueWhatsNewVersionStore.set(version: randomWhatsNewVersion) - XCTAssertEqual(randomWhatsNewVersion, fakeKeyValueable.objects[randomWhatsNewVersion.description] as? WhatsNew.Version) + XCTAssertEqual(randomWhatsNewVersion.description, fakeKeyValueable.objects[randomWhatsNewVersion.description] as? String) XCTAssert(keyValueWhatsNewVersionStore.has(version: randomWhatsNewVersion)) XCTAssertFalse(keyValueWhatsNewVersionStore.has(version: self.generateRandomWhatsNew().version)) }