feat: conditional buy me a coffee
This commit is contained in:
28
Gaze/Services/AppStoreDetector.swift
Normal file
28
Gaze/Services/AppStoreDetector.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// AppStoreDetector.swift
|
||||
// Gaze
|
||||
//
|
||||
// Created by Mike Freno on 1/10/26.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum AppStoreDetector {
|
||||
/// Returns true if the app was downloaded from the Mac App Store
|
||||
static var isAppStoreVersion: Bool {
|
||||
#if DEBUG
|
||||
return false
|
||||
#else
|
||||
guard let receiptURL = Bundle.main.appStoreReceiptURL else {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if receipt exists and is in the expected App Store location
|
||||
let fileManager = FileManager.default
|
||||
let receiptExists = fileManager.fileExists(atPath: receiptURL.path)
|
||||
let isInMASReceipt = receiptURL.path.contains("_MASReceipt")
|
||||
|
||||
return receiptExists && isInMASReceipt
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -101,13 +101,15 @@ struct BlinkSetupView: View {
|
||||
Button(action: {
|
||||
showPreviewWindow()
|
||||
}) {
|
||||
HStack {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "eye")
|
||||
.foregroundColor(.accentColor)
|
||||
.foregroundColor(.white)
|
||||
Text("Preview Reminder")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 44, alignment: .center)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 10)
|
||||
}
|
||||
.glassEffect(.regular.tint(.accentColor).interactive(), in: .rect(cornerRadius: 10))
|
||||
}
|
||||
|
||||
@@ -122,13 +122,15 @@ struct LookAwaySetupView: View {
|
||||
Button(action: {
|
||||
showPreviewWindow()
|
||||
}) {
|
||||
HStack {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "eye")
|
||||
.foregroundColor(.accentColor)
|
||||
.foregroundColor(.white)
|
||||
Text("Preview Reminder")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 44, alignment: .center)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 10)
|
||||
}
|
||||
.glassEffect(.regular.tint(.accentColor).interactive(), in: .rect(cornerRadius: 10))
|
||||
}
|
||||
|
||||
@@ -101,13 +101,15 @@ struct PostureSetupView: View {
|
||||
Button(action: {
|
||||
showPreviewWindow()
|
||||
}) {
|
||||
HStack {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "eye")
|
||||
.foregroundColor(.accentColor)
|
||||
.foregroundColor(.white)
|
||||
Text("Preview Reminder")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: 44, alignment: .center)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 10)
|
||||
}
|
||||
.glassEffect(.regular.tint(.accentColor).interactive(), in: .rect(cornerRadius: 10))
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ struct SettingsOnboardingView: View {
|
||||
.buttonStyle(.plain)
|
||||
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 10))
|
||||
|
||||
// Buy Me a Coffee
|
||||
if !AppStoreDetector.isAppStoreVersion {
|
||||
Button(action: {
|
||||
if let url = URL(string: "https://buymeacoffee.com/placeholder") {
|
||||
NSWorkspace.shared.open(url)
|
||||
@@ -163,6 +163,7 @@ struct SettingsOnboardingView: View {
|
||||
.glassEffect(
|
||||
.regular.tint(.orange).interactive(), in: .rect(cornerRadius: 10))
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
17
GazeTests/Services/AppStoreDetectorTests.swift
Normal file
17
GazeTests/Services/AppStoreDetectorTests.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// AppStoreDetectorTests.swift
|
||||
// GazeTests
|
||||
//
|
||||
// Created by Mike Freno on 1/10/26.
|
||||
//
|
||||
|
||||
@testable import Gaze
|
||||
import Testing
|
||||
|
||||
struct AppStoreDetectorTests {
|
||||
|
||||
@Test func isAppStoreVersionReturnsFalseInDebug() {
|
||||
// In test/debug builds, should always return false
|
||||
#expect(AppStoreDetector.isAppStoreVersion == false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user