Add new in-app purchases
- Rename Donation to Product accordingly - Infer product from provider name
This commit is contained in:
parent
0ed3e4a116
commit
e62aae16fc
|
@ -1,49 +0,0 @@
|
|||
//
|
||||
// Donation.swift
|
||||
// Passepartout-iOS
|
||||
//
|
||||
// Created by Davide De Rosa on 10/11/19.
|
||||
// Copyright (c) 2019 Davide De Rosa. All rights reserved.
|
||||
//
|
||||
// https://github.com/passepartoutvpn
|
||||
//
|
||||
// This file is part of Passepartout.
|
||||
//
|
||||
// Passepartout is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Passepartout is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum Donation: String {
|
||||
case tiny = "com.algoritmico.ios.Passepartout.donations.Tiny"
|
||||
|
||||
case small = "com.algoritmico.ios.Passepartout.donations.Small"
|
||||
|
||||
case medium = "com.algoritmico.ios.Passepartout.donations.Medium"
|
||||
|
||||
case big = "com.algoritmico.ios.Passepartout.donations.Big"
|
||||
|
||||
case huge = "com.algoritmico.ios.Passepartout.donations.Huge"
|
||||
|
||||
case maxi = "com.algoritmico.ios.Passepartout.donations.Maxi"
|
||||
|
||||
static let all: [Donation] = [
|
||||
.tiny,
|
||||
.small,
|
||||
.medium,
|
||||
.big,
|
||||
.huge,
|
||||
.maxi
|
||||
]
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
//
|
||||
// Product.swift
|
||||
// Passepartout-iOS
|
||||
//
|
||||
// Created by Davide De Rosa on 10/11/19.
|
||||
// Copyright (c) 2019 Davide De Rosa. All rights reserved.
|
||||
//
|
||||
// https://github.com/passepartoutvpn
|
||||
//
|
||||
// This file is part of Passepartout.
|
||||
//
|
||||
// Passepartout is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Passepartout is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import PassepartoutCore
|
||||
|
||||
enum Product: String {
|
||||
|
||||
// MARK: Donations
|
||||
|
||||
case tinyDonation = "com.algoritmico.ios.Passepartout.donations.Tiny"
|
||||
|
||||
case smallDonation = "com.algoritmico.ios.Passepartout.donations.Small"
|
||||
|
||||
case mediumDonation = "com.algoritmico.ios.Passepartout.donations.Medium"
|
||||
|
||||
case bigDonation = "com.algoritmico.ios.Passepartout.donations.Big"
|
||||
|
||||
case hugeDonation = "com.algoritmico.ios.Passepartout.donations.Huge"
|
||||
|
||||
case maxiDonation = "com.algoritmico.ios.Passepartout.donations.Maxi"
|
||||
|
||||
static let allDonations: [Product] = [
|
||||
.tinyDonation,
|
||||
.smallDonation,
|
||||
.mediumDonation,
|
||||
.bigDonation,
|
||||
.hugeDonation,
|
||||
.maxiDonation
|
||||
]
|
||||
|
||||
// MARK: Features
|
||||
|
||||
case unlimitedHosts = "com.algoritmico.ios.Passepartout.features.unlimited_hosts"
|
||||
|
||||
case trustedNetworks = "com.algoritmico.ios.Passepartout.features.trusted_networks"
|
||||
|
||||
case siriShortcuts = "com.algoritmico.ios.Passepartout.features.siri"
|
||||
|
||||
case fullVersion = "com.algoritmico.ios.Passepartout.features.full_version"
|
||||
|
||||
static let allFeatures: [Product] = [
|
||||
.unlimitedHosts,
|
||||
.trustedNetworks,
|
||||
.siriShortcuts,
|
||||
.fullVersion
|
||||
]
|
||||
|
||||
// MARK: Providers
|
||||
|
||||
case mullvad = "com.algoritmico.ios.Passepartout.providers.Mullvad"
|
||||
|
||||
case nordVPN = "com.algoritmico.ios.Passepartout.providers.NordVPN"
|
||||
|
||||
case pia = "com.algoritmico.ios.Passepartout.providers.PIA"
|
||||
|
||||
case protonVPN = "com.algoritmico.ios.Passepartout.providers.ProtonVPN"
|
||||
|
||||
case tunnelBear = "com.algoritmico.ios.Passepartout.providers.TunnelBear"
|
||||
|
||||
case vyprVPN = "com.algoritmico.ios.Passepartout.providers.VyprVPN"
|
||||
|
||||
case windscribe = "com.algoritmico.ios.Passepartout.providers.Windscribe"
|
||||
|
||||
static let allProviders: [Product] = [
|
||||
.mullvad,
|
||||
.nordVPN,
|
||||
.pia,
|
||||
.protonVPN,
|
||||
.tunnelBear,
|
||||
.vyprVPN,
|
||||
.windscribe
|
||||
]
|
||||
|
||||
// MARK: All
|
||||
|
||||
static let all: [Product] = allDonations + allFeatures + allProviders
|
||||
}
|
||||
|
||||
extension Infrastructure.Name {
|
||||
var product: Product {
|
||||
guard let product = Product(rawValue: "com.algoritmico.ios.Passepartout.providers.\(rawValue)") else {
|
||||
fatalError("Product not found for provider \(rawValue)")
|
||||
}
|
||||
return product
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import Convenience
|
|||
struct ProductManager {
|
||||
static let shared = ProductManager()
|
||||
|
||||
private let inApp: InApp<Donation>
|
||||
private let inApp: InApp<Product>
|
||||
|
||||
private init() {
|
||||
inApp = InApp()
|
||||
|
@ -41,7 +41,7 @@ struct ProductManager {
|
|||
completionHandler?(inApp.products)
|
||||
return
|
||||
}
|
||||
inApp.requestProducts(withIdentifiers: Donation.all) { _ in
|
||||
inApp.requestProducts(withIdentifiers: Product.all) { _ in
|
||||
completionHandler?(self.inApp.products)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import PassepartoutCore
|
|||
import Convenience
|
||||
|
||||
class DonationViewController: UITableViewController, StrongTableHost {
|
||||
private var donationList: [Donation] = []
|
||||
private var donationList: [Product] = []
|
||||
|
||||
private var productsByIdentifier: [String: SKProduct] = [:]
|
||||
|
||||
|
@ -62,12 +62,7 @@ class DonationViewController: UITableViewController, StrongTableHost {
|
|||
return
|
||||
}
|
||||
|
||||
for row in Donation.all {
|
||||
guard let _ = productsByIdentifier[row.rawValue] else {
|
||||
continue
|
||||
}
|
||||
donationList.append(row)
|
||||
}
|
||||
donationList.append(contentsOf: Product.allDonations.filter { productsByIdentifier[$0.rawValue] != nil })
|
||||
model.set(.donation, count: donationList.count, forSection: .oneTime)
|
||||
|
||||
if isPurchasing {
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
0E3152DB223FA05800F61841 /* ProfileKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E79D14021919F5600BB5FB2 /* ProfileKey.swift */; };
|
||||
0E3152DC223FA05800F61841 /* ProviderConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */; };
|
||||
0E3262D9235EE8DA00B5E470 /* HostImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3262D8235EE8DA00B5E470 /* HostImporter.swift */; };
|
||||
0E3419AD2350815E00419E18 /* Donation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3419AC2350815E00419E18 /* Donation.swift */; };
|
||||
0E3419AD2350815E00419E18 /* Product.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3419AC2350815E00419E18 /* Product.swift */; };
|
||||
0E3586FE225BD34800509A4D /* ActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3586FD225BD34800509A4D /* ActivityTableViewCell.swift */; };
|
||||
0E36D24D2240234B006AF062 /* ShortcutsAddViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E36D24C2240234B006AF062 /* ShortcutsAddViewController.swift */; };
|
||||
0E36D25822403469006AF062 /* Shortcuts.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0E36D25A22403469006AF062 /* Shortcuts.storyboard */; };
|
||||
|
@ -180,7 +180,7 @@
|
|||
0E31529D223F9EF500F61841 /* PassepartoutCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PassepartoutCore.h; sourceTree = "<group>"; };
|
||||
0E31529E223F9EF500F61841 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
0E3262D8235EE8DA00B5E470 /* HostImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostImporter.swift; sourceTree = "<group>"; };
|
||||
0E3419AC2350815E00419E18 /* Donation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Donation.swift; sourceTree = "<group>"; };
|
||||
0E3419AC2350815E00419E18 /* Product.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Product.swift; sourceTree = "<group>"; };
|
||||
0E3586FD225BD34800509A4D /* ActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityTableViewCell.swift; sourceTree = "<group>"; };
|
||||
0E36D24C2240234B006AF062 /* ShortcutsAddViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsAddViewController.swift; sourceTree = "<group>"; };
|
||||
0E36D25B224034AD006AF062 /* ShortcutsConnectToViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShortcutsConnectToViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -533,10 +533,10 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
0E45E6E222BD793800F19312 /* App.strings */,
|
||||
0E3419AC2350815E00419E18 /* Donation.swift */,
|
||||
0E3262D8235EE8DA00B5E470 /* HostImporter.swift */,
|
||||
0EFD943D215BE10800529B64 /* IssueReporter.swift */,
|
||||
0E4FD7F020D58618002221FF /* Macros.swift */,
|
||||
0E3419AC2350815E00419E18 /* Product.swift */,
|
||||
0E24273F225951B00064A1A3 /* ProductManager.swift */,
|
||||
0ECC60DD2256B6890020BEAC /* SwiftGen+Assets.swift */,
|
||||
0EDE8DE320C89028004C739C /* SwiftGen+Scenes.swift */,
|
||||
|
@ -984,7 +984,7 @@
|
|||
0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */,
|
||||
0E05C5D620D1645F006EE732 /* SwiftGen+Scenes.swift in Sources */,
|
||||
0E773BF8224BF37600CDDC8E /* ShortcutsViewController.swift in Sources */,
|
||||
0E3419AD2350815E00419E18 /* Donation.swift in Sources */,
|
||||
0E3419AD2350815E00419E18 /* Product.swift in Sources */,
|
||||
0E9CDB6723604AD5006733B4 /* ServerNetworkViewController.swift in Sources */,
|
||||
0E3262D9235EE8DA00B5E470 /* HostImporter.swift in Sources */,
|
||||
0EFD9440215BED8E00529B64 /* LabelViewController.swift in Sources */,
|
||||
|
|
Loading…
Reference in New Issue