From 9487907f8330732d1c208fb36b138fee5213a363 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 6 Feb 2021 19:12:04 -0600 Subject: [PATCH] Revamp Rating View!! --- Clocker/AppDelegate.swift | 4 ++-- Clocker/Clocker.xcodeproj/project.pbxproj | 8 ++++---- .../xcdebugger/Breakpoints_v2.xcbkptlist | 16 ++++++++++++++++ Clocker/Panel/PanelController.swift | 2 +- Clocker/Panel/ParentPanelController.swift | 8 ++++---- ...teController.swift => ReviewController.swift} | 11 +++++++++-- 6 files changed, 36 insertions(+), 13 deletions(-) rename Clocker/Panel/Rate Controller/{RateController.swift => ReviewController.swift} (91%) diff --git a/Clocker/AppDelegate.swift b/Clocker/AppDelegate.swift index 5a850ae..b0c3b60 100644 --- a/Clocker/AppDelegate.swift +++ b/Clocker/AppDelegate.swift @@ -58,7 +58,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate { showOnboardingFlowIfEligible() // Ratings Controller initialization - RateController.applicationDidLaunch(UserDefaults.standard) + ReviewController.applicationDidLaunch(UserDefaults.standard) #if RELEASE Fabric.with([Crashlytics.self]) @@ -140,7 +140,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate { statusBarHandler = StatusItemHandler() if ProcessInfo.processInfo.arguments.contains(CLUITestingLaunchArgument) { - RateController.setPreviewMode(true) + ReviewController.setPreviewMode(true) } UserDefaults.standard.register(defaults: ["NSApplicationCrashOnExceptions": true]) diff --git a/Clocker/Clocker.xcodeproj/project.pbxproj b/Clocker/Clocker.xcodeproj/project.pbxproj index c436ae0..5ca28ad 100755 --- a/Clocker/Clocker.xcodeproj/project.pbxproj +++ b/Clocker/Clocker.xcodeproj/project.pbxproj @@ -66,7 +66,7 @@ 35C36F612259DE67002FA5C6 /* NotesPopover.xib in Resources */ = {isa = PBXBuildFile; fileRef = 35C36F5F2259DE67002FA5C6 /* NotesPopover.xib */; }; 35C36F622259DE67002FA5C6 /* NotesPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F602259DE67002FA5C6 /* NotesPopover.swift */; }; 35C36F662259DF4C002FA5C6 /* ReviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F642259DF4C002FA5C6 /* ReviewView.swift */; }; - 35C36F672259DF4C002FA5C6 /* RateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F652259DF4C002FA5C6 /* RateController.swift */; }; + 35C36F672259DF4C002FA5C6 /* ReviewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F652259DF4C002FA5C6 /* ReviewController.swift */; }; 35C36F692259DF55002FA5C6 /* TextViewWithPlaceholder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F682259DF55002FA5C6 /* TextViewWithPlaceholder.swift */; }; 35C36F6B2259E0E1002FA5C6 /* FloatingWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 35C36F6A2259E0E1002FA5C6 /* FloatingWindow.xib */; }; 35C36F6F2259E185002FA5C6 /* CustomSliderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F6C2259E185002FA5C6 /* CustomSliderCell.swift */; }; @@ -287,7 +287,7 @@ 35C36F5F2259DE67002FA5C6 /* NotesPopover.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NotesPopover.xib; sourceTree = ""; }; 35C36F602259DE67002FA5C6 /* NotesPopover.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotesPopover.swift; sourceTree = ""; }; 35C36F642259DF4C002FA5C6 /* ReviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReviewView.swift; sourceTree = ""; }; - 35C36F652259DF4C002FA5C6 /* RateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RateController.swift; sourceTree = ""; }; + 35C36F652259DF4C002FA5C6 /* ReviewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReviewController.swift; sourceTree = ""; }; 35C36F682259DF55002FA5C6 /* TextViewWithPlaceholder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextViewWithPlaceholder.swift; sourceTree = ""; }; 35C36F6A2259E0E1002FA5C6 /* FloatingWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FloatingWindow.xib; sourceTree = ""; }; 35C36F6C2259E185002FA5C6 /* CustomSliderCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomSliderCell.swift; sourceTree = ""; }; @@ -612,7 +612,7 @@ 35C36F632259DE9D002FA5C6 /* Rate Controller */ = { isa = PBXGroup; children = ( - 35C36F652259DF4C002FA5C6 /* RateController.swift */, + 35C36F652259DF4C002FA5C6 /* ReviewController.swift */, 35C36F642259DF4C002FA5C6 /* ReviewView.swift */, ); path = "Rate Controller"; @@ -1213,7 +1213,7 @@ 35C36EF622595F14002FA5C6 /* OnboardingController.swift in Sources */, 9AB6F1622259D1B000A44663 /* PreferencesDataSource.swift in Sources */, 3508CC9A259A0001000E3530 /* StatusItemView.swift in Sources */, - 35C36F672259DF4C002FA5C6 /* RateController.swift in Sources */, + 35C36F672259DF4C002FA5C6 /* ReviewController.swift in Sources */, 35C36F472259D892002FA5C6 /* Reach.swift in Sources */, 35C36EF222595F14002FA5C6 /* OnboardingWelcomeViewController.swift in Sources */, 35C36F732259E1AA002FA5C6 /* FloatingWindowController.swift in Sources */, diff --git a/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 06cf1c8..ae6fe6b 100644 --- a/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -15,5 +15,21 @@ stopOnStyle = "0"> + + + + diff --git a/Clocker/Panel/PanelController.swift b/Clocker/Panel/PanelController.swift index d571d09..66ee0e1 100644 --- a/Clocker/Panel/PanelController.swift +++ b/Clocker/Panel/PanelController.swift @@ -91,7 +91,7 @@ class PanelController: ParentPanelController { setTimezoneDatasourceSlider(sliderValue: 0) - reviewView.isHidden = !RateController.canPrompt() + reviewView.isHidden = !ReviewController.canPrompt() reviewView.layer?.backgroundColor = NSColor.clear.cgColor diff --git a/Clocker/Panel/ParentPanelController.swift b/Clocker/Panel/ParentPanelController.swift index 6ac2db4..7e730cd 100644 --- a/Clocker/Panel/ParentPanelController.swift +++ b/Clocker/Panel/ParentPanelController.swift @@ -842,7 +842,7 @@ class ParentPanelController: NSWindowController { } else { updateReviewView() - RateController.prompted() + ReviewController.prompted() if let countryCode = Locale.autoupdatingCurrent.regionCode { Logger.log(object: ["CurrentCountry": countryCode], for: "Remind Later for Feedback") @@ -857,7 +857,7 @@ class ParentPanelController: NSWindowController { leftTitle: PanelConstants.noThanksTitle, rightTitle: "Yes") } else if sender.title == PanelConstants.yesWithQuestionMark { - RateController.prompted() + ReviewController.prompted() updateReviewView() feedbackWindow = AppFeedbackWindowController.shared() @@ -865,7 +865,7 @@ class ParentPanelController: NSWindowController { NSApp.activate(ignoringOtherApps: true) } else { updateReviewView() - RateController.prompt() + ReviewController.prompt() if let countryCode = Locale.autoupdatingCurrent.regionCode { Logger.log(object: ["CurrentCountry": countryCode], for: "Remind Later for Feedback") @@ -876,7 +876,7 @@ class ParentPanelController: NSWindowController { private func updateReviewView() { reviewView.isHidden = true showReviewCell = false - leftField.stringValue = NSLocalizedString("Enjoy using Clocker", + leftField.stringValue = NSLocalizedString("Enjoy using Clocker?", comment: "Title asking users if they like the app") let paragraphStyle = NSMutableParagraphStyle() diff --git a/Clocker/Panel/Rate Controller/RateController.swift b/Clocker/Panel/Rate Controller/ReviewController.swift similarity index 91% rename from Clocker/Panel/Rate Controller/RateController.swift rename to Clocker/Panel/Rate Controller/ReviewController.swift index 858312f..c1beea7 100644 --- a/Clocker/Panel/Rate Controller/RateController.swift +++ b/Clocker/Panel/Rate Controller/ReviewController.swift @@ -1,8 +1,9 @@ // Copyright © 2015 Abhishek Banthia import Cocoa +import StoreKit -final class RateController { +final class ReviewController { private static var storage = UserDefaults.standard private static let version: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "N/A" private static var debugging = false @@ -62,7 +63,13 @@ final class RateController { guard let ratingsURL = URL(string: AboutUsConstants.AppStoreLink) else { return } - NSWorkspace.shared.open(ratingsURL) + + if #available(OSX 10.14, *) { + SKStoreReviewController.requestReview() + } else { + NSWorkspace.shared.open(ratingsURL) + } + prompted() } }