Remove in-app sponsor
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
|
||||
import StoreKit
|
||||
import SwiftUI
|
||||
|
||||
public struct SettingView: View {
|
||||
@@ -12,7 +11,7 @@ public struct SettingView: View {
|
||||
case app
|
||||
#endif
|
||||
|
||||
case core, packetTunnel, profileOverride, sponsor
|
||||
case core, packetTunnel, profileOverride, sponsors
|
||||
|
||||
var label: some View {
|
||||
Label(title, systemImage: iconImage)
|
||||
@@ -30,8 +29,8 @@ public struct SettingView: View {
|
||||
return NSLocalizedString("Packet Tunnel", comment: "")
|
||||
case .profileOverride:
|
||||
return NSLocalizedString("Profile Override", comment: "")
|
||||
case .sponsor:
|
||||
return NSLocalizedString("Sponsor", comment: "")
|
||||
case .sponsors:
|
||||
return NSLocalizedString("Sponsors", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ public struct SettingView: View {
|
||||
return "aspectratio.fill"
|
||||
case .profileOverride:
|
||||
return "square.dashed.inset.filled"
|
||||
case .sponsor:
|
||||
case .sponsors:
|
||||
return "heart.fill"
|
||||
}
|
||||
}
|
||||
@@ -66,8 +65,8 @@ public struct SettingView: View {
|
||||
PacketTunnelView()
|
||||
case .profileOverride:
|
||||
ProfileOverrideView()
|
||||
case .sponsor:
|
||||
SponsorView()
|
||||
case .sponsors:
|
||||
SponsorsView()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
||||
@@ -109,7 +108,7 @@ public struct SettingView: View {
|
||||
Label("Rate on the App Store", systemImage: "text.bubble.fill")
|
||||
}
|
||||
#endif
|
||||
Tabs.sponsor.navigationLink
|
||||
Tabs.sponsors.navigationLink
|
||||
}
|
||||
Section("Debug") {
|
||||
NavigationLink {
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import Foundation
|
||||
import StoreKit
|
||||
import SwiftUI
|
||||
|
||||
public struct SponsorView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
|
||||
@State private var isLoading = true
|
||||
@State private var products: [Product] = []
|
||||
@State private var subscriptionError: Error?
|
||||
@State private var isPurchasing = false
|
||||
@State private var alert: Alert?
|
||||
|
||||
public init() {}
|
||||
public var body: some View {
|
||||
FormView {
|
||||
Section {
|
||||
EmptyView()
|
||||
} footer: {
|
||||
Text("**If I’ve defended your modern life, please consider sponsoring me.**")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
Section("Without commission") {
|
||||
FormButton("GitHub Sponsor (recommended)") {
|
||||
openURL(URL(string: "https://github.com/sponsors/nekohasekai")!)
|
||||
}
|
||||
FormButton("Other methods") {
|
||||
openURL(URL(string: "https://sekai.icu/sponsor/")!)
|
||||
}
|
||||
}
|
||||
Section("Via App Store") {
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
.onAppear {
|
||||
Task.detached {
|
||||
await loadProducts()
|
||||
}
|
||||
}
|
||||
} else if let subscriptionError {
|
||||
Text("Sponsor via App Store not available: \(subscriptionError.localizedDescription)")
|
||||
} else {
|
||||
ForEach(products, id: \.id) { it in
|
||||
FormButton(it.displayName) {
|
||||
isPurchasing = true
|
||||
Task.detached {
|
||||
do {
|
||||
let result = try await it.purchase()
|
||||
switch result {
|
||||
case .success:
|
||||
alert = Alert(title: Text("Success"), message: Text("Thank u."))
|
||||
case .pending:
|
||||
break
|
||||
case .userCancelled:
|
||||
break
|
||||
}
|
||||
} catch {
|
||||
alert = Alert(error)
|
||||
}
|
||||
isPurchasing = false
|
||||
}
|
||||
}
|
||||
.disabled(isPurchasing)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.alertBinding($alert)
|
||||
.navigationTitle("Sponsor")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
}
|
||||
|
||||
private func loadProducts() async {
|
||||
defer {
|
||||
isLoading = false
|
||||
}
|
||||
do {
|
||||
let productIds = ["sponsor_1_1", "sponsor_10", "sponsor_100"]
|
||||
products = try await Product.products(for: productIds)
|
||||
} catch {
|
||||
subscriptionError = error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
public struct SponsorsView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
|
||||
public init() {}
|
||||
public var body: some View {
|
||||
FormView {
|
||||
Section {
|
||||
EmptyView()
|
||||
} footer: {
|
||||
Text(
|
||||
"""
|
||||
**If I’ve defended your modern life, please consider sponsoring me.**
|
||||
|
||||
_sing-box is completely free and open source, sponsorships to the developer are voluntary and you will not receive any digital content or services._
|
||||
""")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
FormButton("GitHub Sponsor (recommended)") {
|
||||
openURL(URL(string: "https://github.com/sponsors/nekohasekai")!)
|
||||
}
|
||||
FormButton("Other methods") {
|
||||
openURL(URL(string: "https://sekai.icu/sponsors/")!)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Sponsors")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@
|
||||
3A76504C2A4F08BA003945C5 /* Libbox.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AEC20DB2A4599D000A63465 /* Libbox.xcframework */; };
|
||||
3A7701702A4E6B34008F031F /* IntentsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A77016F2A4E6B34008F031F /* IntentsExtension.swift */; };
|
||||
3A7701722A4E6B34008F031F /* Intents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7701712A4E6B34008F031F /* Intents.swift */; };
|
||||
3A7904502B6E7BAC006C08D5 /* SponsorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A79044F2B6E7BAC006C08D5 /* SponsorView.swift */; };
|
||||
3A7904502B6E7BAC006C08D5 /* SponsorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A79044F2B6E7BAC006C08D5 /* SponsorsView.swift */; };
|
||||
3A7E90352A46756300D53052 /* SharedPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7E90342A46756300D53052 /* SharedPreferences.swift */; };
|
||||
3A7E90382A46778E00D53052 /* BinaryCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 3A7E90372A46778E00D53052 /* BinaryCodable */; };
|
||||
3A8655142A4FA26600B7181F /* IntentsExtension.appex in Embed ExtensionKit Extensions */ = {isa = PBXBuildFile; fileRef = 3A77016D2A4E6B34008F031F /* IntentsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -149,10 +149,6 @@
|
||||
3AF342A02A4A9916002B34AC /* ExtensionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AF3429F2A4A9916002B34AC /* ExtensionProfile.swift */; };
|
||||
3AF3A3D22B2207F3001FD7C1 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF3A3D12B2207E1001FD7C1 /* libresolv.tbd */; };
|
||||
3AF5E3E72B6F90640058B9E8 /* ProfileOverrideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AF5E3E62B6F90640058B9E8 /* ProfileOverrideView.swift */; };
|
||||
3AF5E3E92B6F9CFB0058B9E8 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF5E3E82B6F9CFB0058B9E8 /* StoreKit.framework */; };
|
||||
3AF5E3EB2B6F9D020058B9E8 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF5E3EA2B6F9D020058B9E8 /* StoreKit.framework */; };
|
||||
3AF5E3EC2B6F9D070058B9E8 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF5E3EA2B6F9D020058B9E8 /* StoreKit.framework */; };
|
||||
3AF5E3EE2B6F9D0F0058B9E8 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF5E3ED2B6F9D0F0058B9E8 /* StoreKit.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -487,7 +483,7 @@
|
||||
3A7701712A4E6B34008F031F /* Intents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Intents.swift; sourceTree = "<group>"; };
|
||||
3A7701732A4E6B34008F031F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
3A7701802A4E71F5008F031F /* IntentsExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = IntentsExtension.entitlements; sourceTree = "<group>"; };
|
||||
3A79044F2B6E7BAC006C08D5 /* SponsorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SponsorView.swift; sourceTree = "<group>"; };
|
||||
3A79044F2B6E7BAC006C08D5 /* SponsorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SponsorsView.swift; sourceTree = "<group>"; };
|
||||
3A7E90302A46745A00D53052 /* ViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewBuilder.swift; sourceTree = "<group>"; };
|
||||
3A7E90342A46756300D53052 /* SharedPreferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedPreferences.swift; sourceTree = "<group>"; };
|
||||
3A9144D82A46AE370036E9AD /* ShadredPreferences+Database.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ShadredPreferences+Database.swift"; sourceTree = "<group>"; };
|
||||
@@ -570,9 +566,6 @@
|
||||
3AF342D32A4AADB2002B34AC /* FormItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormItem.swift; sourceTree = "<group>"; };
|
||||
3AF3A3D12B2207E1001FD7C1 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS17.0.sdk/usr/lib/libresolv.tbd; sourceTree = DEVELOPER_DIR; };
|
||||
3AF5E3E62B6F90640058B9E8 /* ProfileOverrideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileOverrideView.swift; sourceTree = "<group>"; };
|
||||
3AF5E3E82B6F9CFB0058B9E8 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/System/Library/Frameworks/StoreKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||
3AF5E3EA2B6F9D020058B9E8 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
|
||||
3AF5E3ED2B6F9D0F0058B9E8 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS17.2.sdk/System/Library/Frameworks/StoreKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -608,7 +601,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3AF5E3EE2B6F9D0F0058B9E8 /* StoreKit.framework in Frameworks */,
|
||||
3A4FB1572A73467F007012B9 /* Library.framework in Frameworks */,
|
||||
3A4FB15C2A73468C007012B9 /* ApplicationLibrary.framework in Frameworks */,
|
||||
);
|
||||
@@ -627,7 +619,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3AF5E3E92B6F9CFB0058B9E8 /* StoreKit.framework in Frameworks */,
|
||||
3A9759202A4EB69C00E4404B /* Library.framework in Frameworks */,
|
||||
3A4EAD372A4FEC20005435B3 /* ApplicationLibrary.framework in Frameworks */,
|
||||
);
|
||||
@@ -640,7 +631,6 @@
|
||||
3A5F26C82A503D4A00C27EDF /* Library.framework in Frameworks */,
|
||||
3AEECC352A6DFDAD006A0E0C /* MacLibrary.framework in Frameworks */,
|
||||
3AEECC412A6DFE29006A0E0C /* MacLibrary.framework in Frameworks */,
|
||||
3AF5E3EB2B6F9D020058B9E8 /* StoreKit.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -668,7 +658,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3AF5E3EC2B6F9D070058B9E8 /* StoreKit.framework in Frameworks */,
|
||||
3AEECC1D2A6DFA79006A0E0C /* Library.framework in Frameworks */,
|
||||
3AEECC3A2A6DFDC5006A0E0C /* MacLibrary.framework in Frameworks */,
|
||||
);
|
||||
@@ -759,7 +748,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3AAB5E732A4BF90B009757F1 /* ServiceLogView.swift */,
|
||||
3A79044F2B6E7BAC006C08D5 /* SponsorView.swift */,
|
||||
3A79044F2B6E7BAC006C08D5 /* SponsorsView.swift */,
|
||||
3AF5E3E62B6F90640058B9E8 /* ProfileOverrideView.swift */,
|
||||
3A60CC262B70880100D2D682 /* PacketTunnelView.swift */,
|
||||
3A60CC2A2B70AD6700D2D682 /* SettingView.swift */,
|
||||
@@ -868,9 +857,6 @@
|
||||
3AEC21012A459AE300A63465 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3AF5E3ED2B6F9D0F0058B9E8 /* StoreKit.framework */,
|
||||
3AF5E3EA2B6F9D020058B9E8 /* StoreKit.framework */,
|
||||
3AF5E3E82B6F9CFB0058B9E8 /* StoreKit.framework */,
|
||||
3AF3A3D12B2207E1001FD7C1 /* libresolv.tbd */,
|
||||
3A3DEBE62A4FFA6000373BF4 /* AppIntents.framework */,
|
||||
3A3DEBE12A4FFA1A00373BF4 /* ExtensionFoundation.framework */,
|
||||
@@ -1507,7 +1493,7 @@
|
||||
3A4EAD362A4FEB9C005435B3 /* ProfileUpdateTask.swift in Sources */,
|
||||
3A1CF2F62A50EE9C000A8289 /* GroupView.swift in Sources */,
|
||||
3A4EAD212A4FEB3C005435B3 /* ApplicationLibrary.swift in Sources */,
|
||||
3A7904502B6E7BAC006C08D5 /* SponsorView.swift in Sources */,
|
||||
3A7904502B6E7BAC006C08D5 /* SponsorsView.swift in Sources */,
|
||||
3A1CF2F22A50E613000A8289 /* OutboundGroup.swift in Sources */,
|
||||
3A1CF2FA2A50F0BD000A8289 /* OutboundGroupItem.swift in Sources */,
|
||||
3A99B42E2A752ABB0010D4B0 /* NavigationDestinationCompat.swift in Sources */,
|
||||
@@ -2016,7 +2002,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.9.0;
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||
PRODUCT_NAME = "sing-box";
|
||||
SDKROOT = appletvos;
|
||||
@@ -2050,7 +2036,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.9.0;
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||
PRODUCT_NAME = "sing-box";
|
||||
SDKROOT = appletvos;
|
||||
@@ -2288,7 +2274,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.9.0;
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
OTHER_CODE_SIGN_FLAGS = "--deep";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||
PRODUCT_NAME = "sing-box";
|
||||
@@ -2328,7 +2314,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.9.0;
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
OTHER_CODE_SIGN_FLAGS = "--deep";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||
PRODUCT_NAME = "sing-box";
|
||||
@@ -2367,7 +2353,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 1.9.0;
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
OTHER_CODE_SIGN_FLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||
PRODUCT_NAME = "sing-box";
|
||||
@@ -2405,7 +2391,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 1.9.0;
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
OTHER_CODE_SIGN_FLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa;
|
||||
PRODUCT_NAME = "sing-box";
|
||||
@@ -2547,7 +2533,7 @@
|
||||
"@executable_path/../../../../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = "1.9.0-alpha.8";
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
||||
PRODUCT_NAME = "$(inherited)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -2583,7 +2569,7 @@
|
||||
"@executable_path/../../../../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = "1.9.0-alpha.8";
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
||||
PRODUCT_NAME = "$(inherited)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -2623,7 +2609,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = "1.9.0-alpha.8";
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
||||
PRODUCT_NAME = SFM;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -2662,7 +2648,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = "1.9.0-alpha.8";
|
||||
MARKETING_VERSION = 1.8.6;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
||||
PRODUCT_NAME = SFM;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
||||
Reference in New Issue
Block a user