Merge branch 'in-app-donations'

This commit is contained in:
Davide De Rosa 2019-04-07 15:29:44 +02:00
commit e791a0daff
12 changed files with 493 additions and 8 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- In-app donations.
### Changed
- Automatic protocol defaults to UDP endpoints. [#61](https://github.com/passepartoutvpn/passepartout-ios/pull/61)

View File

@ -54,6 +54,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
// splitViewController.preferredDisplayMode = .primaryOverlay
}
InAppHelper.shared.requestProducts(completionHandler: nil)
return true
}

View File

@ -246,13 +246,80 @@
</objects>
<point key="canvasLocation" x="-1727" y="-357"/>
</scene>
<!--Donation View Controller-->
<scene sceneID="NrW-UF-gN3">
<objects>
<tableViewController id="SoF-ZH-NT1" customClass="DonationViewController" customModule="Passepartout" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="2Io-7F-8Ed">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="52Q-2q-7xf" detailTextLabel="5ba-c6-s1I" style="IBUITableViewCellStyleValue1" id="Ukv-2T-HRq" customClass="SettingTableViewCell" customModule="Passepartout" customModuleProvider="target">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Ukv-2T-HRq" id="9sw-RZ-ki7">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="52Q-2q-7xf">
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="5ba-c6-s1I">
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="SoF-ZH-NT1" id="Zei-ZZ-9w7"/>
<outlet property="delegate" destination="SoF-ZH-NT1" id="CIL-Vb-tKS"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="B6p-Ga-iiI">
<barButtonItem key="leftBarButtonItem" systemItem="stop" id="CuS-kE-f9X">
<connections>
<action selector="close" destination="SoF-ZH-NT1" id="3lz-X4-dEb"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="UbZ-6W-wgU" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1646" y="-2076"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="B4n-eO-M22">
<objects>
<navigationController id="5ku-HX-5yk" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Z4x-kj-jBr">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="SoF-ZH-NT1" kind="relationship" relationship="rootViewController" id="2ax-VJ-siI"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="XWm-9m-gcV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2478" y="-2075"/>
</scene>
<!--About-->
<scene sceneID="xOy-mR-afs">
<objects>
<viewControllerPlaceholder storyboardName="About" id="POR-9u-PsE" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="mZu-dH-Wex" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2991" y="-1301"/>
<point key="canvasLocation" x="-3060" y="-1565"/>
</scene>
<!--Organizer View Controller-->
<scene sceneID="H6i-Tl-Gnq">
@ -300,8 +367,9 @@
<connections>
<segue destination="NVA-bQ-iIE" kind="presentation" identifier="AddProviderSegueIdentifier" modalPresentationStyle="formSheet" id="Win-5U-mIc"/>
<segue destination="z6E-m6-Op0" kind="presentation" identifier="ShowImportedHostsSegueIdentifier" modalPresentationStyle="formSheet" id="TZv-OK-8vU"/>
<segue destination="BIO-UT-cpg" kind="presentation" identifier="SiriShortcutsSegueIdentifier" id="I9b-aK-jPT"/>
<segue destination="POR-9u-PsE" kind="presentation" identifier="AboutSegueIdentifier" id="78g-ra-Yhp"/>
<segue destination="BIO-UT-cpg" kind="presentation" identifier="SiriShortcutsSegueIdentifier" modalPresentationStyle="formSheet" id="I9b-aK-jPT"/>
<segue destination="POR-9u-PsE" kind="presentation" identifier="AboutSegueIdentifier" modalPresentationStyle="formSheet" id="78g-ra-Yhp"/>
<segue destination="5ku-HX-5yk" kind="presentation" identifier="DonateSegueIdentifier" modalPresentationStyle="formSheet" id="H4q-BS-PmK"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="bGp-H5-24W" userLabel="First Responder" sceneMemberID="firstResponder"/>

View File

@ -0,0 +1,156 @@
//
// InApp.swift
// Passepartout-iOS
//
// Created by Davide De Rosa on 4/6/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 StoreKit
struct InApp {
enum Donation: String {
static let all: [Donation] = [
.tiny,
.small,
.medium,
.big,
.huge,
.maxi
]
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 func allIdentifiers() -> Set<String> {
return Set<String>(Donation.all.map { $0.rawValue })
}
}
class InAppHelper: NSObject {
enum PurchaseResult {
case success
case failure
case cancelled
}
typealias ProductObserver = ([SKProduct]) -> Void
typealias TransactionObserver = (PurchaseResult, Error?) -> Void
static let shared = InAppHelper()
private(set) var products: [SKProduct]
private var productObservers: [ProductObserver]
private var transactionObservers: [String: TransactionObserver]
private override init() {
products = []
productObservers = []
transactionObservers = [:]
super.init()
SKPaymentQueue.default().add(self)
}
deinit {
SKPaymentQueue.default().remove(self)
}
func requestProducts(completionHandler: ProductObserver?) {
let req = SKProductsRequest(productIdentifiers: InApp.allIdentifiers())
req.delegate = self
if let observer = completionHandler {
productObservers.append(observer)
}
req.start()
}
private func receiveProducts(_ products: [SKProduct]) {
self.products = products
productObservers.forEach { $0(products) }
productObservers.removeAll()
}
func purchase(product: SKProduct, completionHandler: @escaping TransactionObserver) {
let queue = SKPaymentQueue.default()
let payment = SKPayment(product: product)
transactionObservers[product.productIdentifier] = completionHandler
queue.add(payment)
}
}
extension InAppHelper: SKProductsRequestDelegate {
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
DispatchQueue.main.async {
self.receiveProducts(response.products)
}
}
func request(_ request: SKRequest, didFailWithError error: Error) {
transactionObservers.removeAll()
}
}
extension InAppHelper: SKPaymentTransactionObserver {
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for tx in transactions {
let observer = transactionObservers[tx.payment.productIdentifier]
switch tx.transactionState {
case .purchased, .restored:
queue.finishTransaction(tx)
DispatchQueue.main.async {
observer?(.success, nil)
}
case .failed:
queue.finishTransaction(tx)
if let skError = tx.error as? SKError, skError.code == .paymentCancelled {
DispatchQueue.main.async {
observer?(.cancelled, nil)
}
} else {
DispatchQueue.main.async {
observer?(.failure, tx.error)
}
}
default:
break
}
}
}
}

View File

@ -26,6 +26,7 @@ internal enum StoryboardSegue {
internal enum Organizer: String, SegueType {
case aboutSegueIdentifier = "AboutSegueIdentifier"
case addProviderSegueIdentifier = "AddProviderSegueIdentifier"
case donateSegueIdentifier = "DonateSegueIdentifier"
case importHostSegueIdentifier = "ImportHostSegueIdentifier"
case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier"
case showImportedHostsSegueIdentifier = "ShowImportedHostsSegueIdentifier"

View File

@ -25,6 +25,7 @@
import UIKit
import MessageUI
import StoreKit
import Passepartout_Core
extension UIColor {
@ -165,3 +166,12 @@ extension Pool {
return ImageAsset(name: country.lowercased()).image
}
}
extension SKProduct {
var localizedPrice: String? {
let fmt = NumberFormatter()
fmt.numberStyle = .currency
fmt.locale = priceLocale
return fmt.string(from: price)
}
}

View File

@ -0,0 +1,156 @@
//
// DonationViewController.swift
// Passepartout-iOS
//
// Created by Davide De Rosa on 4/6/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 UIKit
import StoreKit
import Passepartout_Core
class DonationViewController: UITableViewController, TableModelHost {
private var productsByIdentifier: [String: SKProduct] = [:]
private func setProducts(_ products: [SKProduct]) {
for p in products {
productsByIdentifier[p.productIdentifier] = p
}
reloadModel()
tableView.reloadData()
}
// MARK: TableModel
var model: TableModel<SectionType, InApp.Donation> = TableModel()
func reloadModel() {
model.clear()
let completeList: [InApp.Donation] = [.tiny, .small, .medium, .big, .huge, .maxi]
var list: [InApp.Donation] = []
for row in completeList {
guard let _ = productsByIdentifier[row.rawValue] else {
continue
}
list.append(row)
}
model.add(.oneTime)
// model.add(.recurring)
model.setHeader(L10n.Donation.Sections.OneTime.header, for: .oneTime)
model.setFooter(L10n.Donation.Sections.OneTime.footer, for: .oneTime)
// model.setHeader(L10n.Donation.Sections.Recurring.header, for: .recurring)
model.set(list, in: .oneTime)
}
// MARK: UIViewController
override func viewDidLoad() {
super.viewDidLoad()
title = L10n.Donation.title
let inApp = InAppHelper.shared
if inApp.products.isEmpty {
let hud = HUD()
hud.show()
inApp.requestProducts {
hud.hide()
self.setProducts($0)
}
} else {
setProducts(inApp.products)
}
}
@IBAction private func close() {
dismiss(animated: true, completion: nil)
}
// MARK: UITableViewController
override func numberOfSections(in tableView: UITableView) -> Int {
return model.count
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return model.header(for: section)
}
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return model.footer(for: section)
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return model.count(for: section)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let productId = productIdentifier(at: indexPath)
guard let product = productsByIdentifier[productId] else {
fatalError("Row with no associated product")
}
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = product.localizedTitle
cell.rightText = product.localizedPrice
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let productId = productIdentifier(at: indexPath)
guard let product = productsByIdentifier[productId] else {
fatalError("Row with no associated product")
}
InAppHelper.shared.purchase(product: product) {
self.handlePurchase(result: $0, error: $1)
}
}
private func handlePurchase(result: InAppHelper.PurchaseResult, error: Error?) {
let alert: UIAlertController
switch result {
case .cancelled:
return
case .success:
alert = Macros.alert(title, L10n.Donation.Alerts.Purchase.success)
case .failure:
alert = Macros.alert(title, L10n.Donation.Alerts.Purchase.failure(error?.localizedDescription ?? ""))
}
alert.addCancelAction(L10n.Global.ok)
present(alert, animated: true, completion: nil)
}
}
extension DonationViewController {
enum SectionType {
case oneTime
case recurring
}
private func productIdentifier(at indexPath: IndexPath) -> String {
return model.row(at: indexPath).rawValue
}
}

View File

@ -48,6 +48,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
if #available(iOS 12, *) {
model.add(.siri)
}
model.add(.support)
model.add(.about)
model.add(.destruction)
model.setHeader(L10n.Organizer.Sections.Providers.header, for: .providers)
@ -59,6 +60,8 @@ class OrganizerViewController: UITableViewController, TableModelHost {
model.setFooter(L10n.Organizer.Sections.Siri.footer, for: .siri)
model.set([.siriShortcuts], in: .siri)
}
model.setHeader(L10n.Organizer.Sections.Support.header, for: .support)
model.set([.donate, .patreon], in: .support)
model.set([.openAbout], in: .about)
model.set([.uninstall], in: .destruction)
if AppConstants.Flags.isBeta {
@ -155,10 +158,6 @@ class OrganizerViewController: UITableViewController, TableModelHost {
// MARK: Actions
@IBAction private func about() {
perform(segue: StoryboardSegue.Organizer.aboutSegueIdentifier, sender: nil)
}
private func addNewProvider() {
var names = Set(InfrastructureFactory.shared.allNames)
var createdNames: [Infrastructure.Name] = []
@ -192,6 +191,18 @@ class OrganizerViewController: UITableViewController, TableModelHost {
perform(segue: StoryboardSegue.Organizer.siriShortcutsSegueIdentifier)
}
private func donateToDeveloper() {
perform(segue: StoryboardSegue.Organizer.donateSegueIdentifier, sender: nil)
}
private func visitPatreon() {
UIApplication.shared.open(AppConstants.URLs.patreon, options: [:], completionHandler: nil)
}
private func about() {
perform(segue: StoryboardSegue.Organizer.aboutSegueIdentifier, sender: nil)
}
private func removeProfile(at indexPath: IndexPath) {
let sectionObject = model.section(for: indexPath.section)
let rowProfile = profileKey(at: indexPath)
@ -283,6 +294,8 @@ extension OrganizerViewController {
case siri
case support
case about
case destruction
@ -299,6 +312,10 @@ extension OrganizerViewController {
case siriShortcuts
case donate
case patreon
case openAbout
case uninstall
@ -374,12 +391,22 @@ extension OrganizerViewController {
cell.leftText = L10n.Organizer.Cells.SiriShortcuts.caption
return cell
case .donate:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.Donate.caption
return cell
case .patreon:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.Patreon.caption
return cell
case .openAbout:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.About.caption(GroupConstants.App.name)
cell.rightText = Utils.versionString()
return cell
case .uninstall:
let cell = Cells.destructive.dequeue(from: tableView, for: indexPath)
cell.caption = L10n.Organizer.Cells.Uninstall.caption
@ -412,6 +439,12 @@ extension OrganizerViewController {
case .siriShortcuts:
addShortcuts()
case .donate:
donateToDeveloper()
case .patreon:
visitPatreon()
case .openAbout:
about()

View File

@ -17,6 +17,8 @@
0E1D72B2213BFFCF00BA1586 /* ProviderPresetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1D72B1213BFFCF00BA1586 /* ProviderPresetViewController.swift */; };
0E1D72B4213C118500BA1586 /* ConfigurationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1D72B3213C118500BA1586 /* ConfigurationViewController.swift */; };
0E24273A225950450064A1A3 /* About.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0E24273C225950450064A1A3 /* About.storyboard */; };
0E242740225951B00064A1A3 /* InApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E24273F225951B00064A1A3 /* InApp.swift */; };
0E242742225956AC0064A1A3 /* DonationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E242741225956AC0064A1A3 /* DonationViewController.swift */; };
0E2B494020FCFF990094784C /* Theme+Titles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E2B493F20FCFF990094784C /* Theme+Titles.swift */; };
0E3152A4223F9EF500F61841 /* Passepartout_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E31529B223F9EF400F61841 /* Passepartout_Core.framework */; };
0E3152AD223F9EF500F61841 /* Passepartout_Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E31529D223F9EF500F61841 /* Passepartout_Core.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -177,6 +179,8 @@
0E1D72B3213C118500BA1586 /* ConfigurationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationViewController.swift; sourceTree = "<group>"; };
0E242735225944060064A1A3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Intents.strings; sourceTree = "<group>"; };
0E24273B225950450064A1A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/About.storyboard; sourceTree = "<group>"; };
0E24273F225951B00064A1A3 /* InApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InApp.swift; sourceTree = "<group>"; };
0E242741225956AC0064A1A3 /* DonationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DonationViewController.swift; sourceTree = "<group>"; };
0E2B493F20FCFF990094784C /* Theme+Titles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+Titles.swift"; sourceTree = "<group>"; };
0E2B494120FD16540094784C /* TransientStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransientStore.swift; sourceTree = "<group>"; };
0E2D11B9217DBEDE0096822C /* ConnectionService+Configurations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConnectionService+Configurations.swift"; sourceTree = "<group>"; };
@ -454,6 +458,7 @@
0E89DFCC213EEDE700741BA1 /* Organizer */ = {
isa = PBXGroup;
children = (
0E242741225956AC0064A1A3 /* DonationViewController.swift */,
0EB67D6A2184581E00BA6200 /* ImportedHostsViewController.swift */,
0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */,
0ED38AD8213F33150004D387 /* WizardHostViewController.swift */,
@ -540,6 +545,7 @@
isa = PBXGroup;
children = (
0EF5CF242141CE58004FF1BD /* HUD.swift */,
0E24273F225951B00064A1A3 /* InApp.swift */,
0EFD943D215BE10800529B64 /* IssueReporter.swift */,
0E4FD7F020D58618002221FF /* Macros.swift */,
0ED38AE9214054A50004D387 /* OptionViewController.swift */,
@ -1052,8 +1058,10 @@
0E36D25C224034AD006AF062 /* ShortcutsConnectToViewController.swift in Sources */,
0E05C61D20D27C82006EE732 /* Theme.swift in Sources */,
0ECC60DE2256B68A0020BEAC /* SwiftGen+Assets.swift in Sources */,
0E242742225956AC0064A1A3 /* DonationViewController.swift in Sources */,
0ED38AEC2141260D0004D387 /* ConfigurationModificationDelegate.swift in Sources */,
0ECEE45020E1182E00A6BB43 /* Theme+Cells.swift in Sources */,
0E242740225951B00064A1A3 /* InApp.swift in Sources */,
0E1066C920E0F84A004F98B7 /* Cells.swift in Sources */,
0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */,
0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */,

View File

@ -42,11 +42,14 @@
"organizer.sections.hosts.footer" = "Import hosts from raw .ovpn configuration files.";
"organizer.sections.siri.header" = "Siri";
"organizer.sections.siri.footer" = "Get help from Siri to speed up your most common interactions with the app.";
"organizer.sections.support.header" = "Support";
"organizer.cells.profile.value.current" = "In use";
"organizer.cells.add_provider.caption" = "Add new provider";
"organizer.cells.add_host.caption" = "Add new host";
"organizer.cells.siri_shortcuts.caption" = "Manage shortcuts";
"organizer.cells.about.caption" = "About %@";
"organizer.cells.donate.caption" = "Make a donation";
"organizer.cells.patreon.caption" = "Support me on Patreon";
"organizer.cells.uninstall.caption" = "Remove VPN configuration";
"organizer.alerts.exhausted_providers.message" = "You have created profiles for any available provider.";
"organizer.alerts.add_host.message" = "Open an URL to an .ovpn configuration file from Safari, Mail or another app to set up a host profile.\n\nYou can also import an .ovpn with iTunes File Sharing.";
@ -244,6 +247,13 @@
"about.cells.join_community.caption" = "Join community";
"about.cells.write_review.caption" = "Write a review";
"donation.title" = "Donate";
"donation.sections.one_time.header" = "One time";
"donation.sections.one_time.footer" = "If you want to display gratitude for my free work, here are a couple amounts you can donate instantly.\n\nYou will only be charged once per donation, and you can donate multiple times.";
//"donation.sections.recurring.header" = "Recurring";
"donation.alerts.purchase.success" = "THANK YOU!\n\nThis means a lot to me and I really hope you keep using and promoting this app.";
"donation.alerts.purchase.failure" = "Unable to perform the donation. %@";
"share.message" = "Passepartout is an user-friendly, open source OpenVPN client for iOS and macOS";
"version.title" = "Version";

View File

@ -144,6 +144,8 @@ public class AppConstants {
public static let subreddit = URL(string: "https://www.reddit.com/r/passepartout")!
public static let patreon = URL(string: "https://www.patreon.com/keeshux")!
private static let twitterHashtags = ["OpenVPN", "iOS", "macOS"]
public static var twitterIntent: URL {

View File

@ -295,6 +295,29 @@ public enum L10n {
}
}
public enum Donation {
/// Donate
public static let title = L10n.tr("Localizable", "donation.title")
public enum Alerts {
public enum Purchase {
/// Unable to perform the donation. %@
public static func failure(_ p1: String) -> String {
return L10n.tr("Localizable", "donation.alerts.purchase.failure", p1)
}
/// THANK YOU!\n\nThis means a lot to me and I really hope you keep using and promoting this app.
public static let success = L10n.tr("Localizable", "donation.alerts.purchase.success")
}
}
public enum Sections {
public enum OneTime {
/// If you want to display gratitude for my free work, here are a couple amounts you can donate instantly.\n\nYou will only be charged once per donation, and you can donate multiple times.
public static let footer = L10n.tr("Localizable", "donation.sections.one_time.footer")
/// One time
public static let header = L10n.tr("Localizable", "donation.sections.one_time.header")
}
}
}
public enum Endpoint {
public enum Cells {
public enum AnyAddress {
@ -408,6 +431,14 @@ public enum L10n {
/// Add new provider
public static let caption = L10n.tr("Localizable", "organizer.cells.add_provider.caption")
}
public enum Donate {
/// Make a donation
public static let caption = L10n.tr("Localizable", "organizer.cells.donate.caption")
}
public enum Patreon {
/// Support me on Patreon
public static let caption = L10n.tr("Localizable", "organizer.cells.patreon.caption")
}
public enum Profile {
public enum Value {
/// In use
@ -442,6 +473,10 @@ public enum L10n {
/// Siri
public static let header = L10n.tr("Localizable", "organizer.sections.siri.header")
}
public enum Support {
/// Support
public static let header = L10n.tr("Localizable", "organizer.sections.support.header")
}
}
}