Compare commits
No commits in common. "develop" and "public-beta" have entirely different histories.
develop
...
public-bet
|
@ -1,20 +1,3 @@
|
|||
## 2024.2
|
||||
This release introduces push notifications as well as an enhanced multi-column interface on iPadOS!
|
||||
|
||||
Features/Improvements:
|
||||
- Push notifications
|
||||
- Add post preview to Appearance preferences
|
||||
- Show instance announcements in Notifications tab
|
||||
- Add subscription option to Tip Jar
|
||||
- iPadOS: Multi-column navigation
|
||||
- Pleroma/Akkoma: Emoji reaction notifications
|
||||
|
||||
Bugfixes:
|
||||
- Fix fetching server info on some instances
|
||||
- Fix attachment captions not displaying while loading in gallery
|
||||
- macOS: Remove in-app Safari preferences
|
||||
- Pleroma: Handle posts with missing creation date
|
||||
|
||||
## 2024.1
|
||||
This update includes a significant improvements for the attachment gallery and displaying rich text posts. See below for a full list of improvements and fixes.
|
||||
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
## 2024.3 (124)
|
||||
Features/Improvements:
|
||||
- Add subscription option to Tip Jar
|
||||
|
||||
Bugfixes:
|
||||
- Fix attachment captions not displaying while loading in gallery
|
||||
- Fix tapping follow request push notification not working
|
||||
- Pleroma: Handle posts with missing creation dates
|
||||
|
||||
## 2024.2 (122)
|
||||
Features/Improvements:
|
||||
- Show instance announcements in Notifications
|
||||
|
|
|
@ -42,8 +42,7 @@ public struct Client: Sendable {
|
|||
} else if let date = iso8601.date(from: str) {
|
||||
return date
|
||||
} else {
|
||||
// throw DecodingError.typeMismatch(Date.self, .init(codingPath: container.codingPath, debugDescription: "unexpected date format: \(str)"))
|
||||
return Date(timeIntervalSinceReferenceDate: 0)
|
||||
throw DecodingError.typeMismatch(Date.self, .init(codingPath: container.codingPath, debugDescription: "unexpected date format"))
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
D60E2F2E244248BF005F8713 /* MastodonCachePersistentStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D60E2F2D244248BF005F8713 /* MastodonCachePersistentStore.swift */; };
|
||||
D6114E0D27F7FEB30080E273 /* TrendingStatusesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6114E0C27F7FEB30080E273 /* TrendingStatusesViewController.swift */; };
|
||||
D6114E1127F899B30080E273 /* TrendingLinksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6114E1027F899B30080E273 /* TrendingLinksViewController.swift */; };
|
||||
D6187BED2BFA840B00B3A281 /* FollowRequestNotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6187BEC2BFA840B00B3A281 /* FollowRequestNotificationViewController.swift */; };
|
||||
D61A45E628DC0F2F002BE511 /* ConfirmLoadMoreCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61A45E528DC0F2F002BE511 /* ConfirmLoadMoreCollectionViewCell.swift */; };
|
||||
D61A45E828DF477D002BE511 /* LoadingCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61A45E728DF477D002BE511 /* LoadingCollectionViewCell.swift */; };
|
||||
D61A45EA28DF51EE002BE511 /* TimelineLikeCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61A45E928DF51EE002BE511 /* TimelineLikeCollectionViewController.swift */; };
|
||||
|
@ -96,7 +95,7 @@
|
|||
D630C3CA2BC59FF500208903 /* MastodonController+Push.swift in Sources */ = {isa = PBXBuildFile; fileRef = D630C3C92BC59FF500208903 /* MastodonController+Push.swift */; };
|
||||
D630C3CC2BC5FD4600208903 /* GetAuthorizationTokenService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D630C3CB2BC5FD4600208903 /* GetAuthorizationTokenService.swift */; };
|
||||
D630C3D42BC61B6100208903 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D630C3D32BC61B6100208903 /* NotificationService.swift */; };
|
||||
D630C3D82BC61B6100208903 /* NotificationExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D630C3D12BC61B6000208903 /* NotificationExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
D630C3D82BC61B6100208903 /* NotificationExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D630C3D12BC61B6000208903 /* NotificationExtension.appex */; platformFilters = (ios, maccatalyst, ); settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
D630C3DF2BC61C4900208903 /* PushNotifications in Frameworks */ = {isa = PBXBuildFile; productRef = D630C3DE2BC61C4900208903 /* PushNotifications */; };
|
||||
D630C3E12BC61C6700208903 /* UserAccounts in Frameworks */ = {isa = PBXBuildFile; productRef = D630C3E02BC61C6700208903 /* UserAccounts */; };
|
||||
D630C3E52BC6313400208903 /* Pachyderm in Frameworks */ = {isa = PBXBuildFile; productRef = D630C3E42BC6313400208903 /* Pachyderm */; };
|
||||
|
@ -468,7 +467,6 @@
|
|||
D60E2F2D244248BF005F8713 /* MastodonCachePersistentStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonCachePersistentStore.swift; sourceTree = "<group>"; };
|
||||
D6114E0C27F7FEB30080E273 /* TrendingStatusesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingStatusesViewController.swift; sourceTree = "<group>"; };
|
||||
D6114E1027F899B30080E273 /* TrendingLinksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingLinksViewController.swift; sourceTree = "<group>"; };
|
||||
D6187BEC2BFA840B00B3A281 /* FollowRequestNotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowRequestNotificationViewController.swift; sourceTree = "<group>"; };
|
||||
D61A45E528DC0F2F002BE511 /* ConfirmLoadMoreCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmLoadMoreCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D61A45E728DF477D002BE511 /* LoadingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D61A45E928DF51EE002BE511 /* TimelineLikeCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineLikeCollectionViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -1166,7 +1164,6 @@
|
|||
D646DCD92A081A2C0059ECEB /* PollFinishedNotificationCollectionViewCell.swift */,
|
||||
D646DCDB2A081CF10059ECEB /* StatusUpdatedNotificationCollectionViewCell.swift */,
|
||||
D68245112BCA1F4000AFB38B /* NotificationLoadingViewController.swift */,
|
||||
D6187BEC2BFA840B00B3A281 /* FollowRequestNotificationViewController.swift */,
|
||||
);
|
||||
path = Notifications;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2237,7 +2234,6 @@
|
|||
D65A261D2BC39399005EB5D8 /* PushInstanceSettingsView.swift in Sources */,
|
||||
D65C6BF525478A9C00A6E89C /* BackgroundableViewController.swift in Sources */,
|
||||
D61DC84D28F500D200B82C6E /* ProfileViewController.swift in Sources */,
|
||||
D6187BED2BFA840B00B3A281 /* FollowRequestNotificationViewController.swift in Sources */,
|
||||
D600891F29848DE2005B4D00 /* AddInstancePinnedTimelineView.swift in Sources */,
|
||||
D693A72F25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift in Sources */,
|
||||
D627943223A5466600D38C68 /* SelectableTableViewCell.swift in Sources */,
|
||||
|
|
|
@ -42,7 +42,7 @@ class ImageGalleryDataSource: GalleryDataSource {
|
|||
gifController: gifController
|
||||
)
|
||||
} else {
|
||||
return LoadingGalleryContentViewController(caption: nil) {
|
||||
return LoadingGalleryContentViewController {
|
||||
let (data, image) = await self.cache.get(self.url, loadOriginal: true)
|
||||
if let image {
|
||||
let gifController: GIFController? =
|
||||
|
|
|
@ -10,7 +10,6 @@ import UIKit
|
|||
import GalleryVC
|
||||
|
||||
class LoadingGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||
private let fallbackCaption: String?
|
||||
private let provider: () async -> (any GalleryContentViewController)?
|
||||
private var wrapped: (any GalleryContentViewController)!
|
||||
|
||||
|
@ -25,15 +24,14 @@ class LoadingGalleryContentViewController: UIViewController, GalleryContentViewC
|
|||
}
|
||||
|
||||
var caption: String? {
|
||||
wrapped?.caption ?? fallbackCaption
|
||||
wrapped?.caption
|
||||
}
|
||||
|
||||
var canAnimateFromSourceView: Bool {
|
||||
wrapped?.canAnimateFromSourceView ?? true
|
||||
}
|
||||
|
||||
init(caption: String?, provider: @escaping () async -> (any GalleryContentViewController)?) {
|
||||
self.fallbackCaption = caption
|
||||
init(provider: @escaping () async -> (any GalleryContentViewController)?) {
|
||||
self.provider = provider
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
|
|
@ -57,8 +57,7 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
|||
gifController: gifController
|
||||
)
|
||||
} else {
|
||||
return LoadingGalleryContentViewController(caption: attachment.description) {
|
||||
try! await Task.sleep(nanoseconds: NSEC_PER_SEC)
|
||||
return LoadingGalleryContentViewController {
|
||||
let (data, image) = await ImageCache.attachments.get(attachment.url, loadOriginal: true)
|
||||
if let image {
|
||||
let gifController: GIFController? =
|
||||
|
@ -96,7 +95,7 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
|||
// TODO: use separate content VC with audio visualization?
|
||||
return VideoGalleryContentViewController(url: attachment.url, caption: attachment.description)
|
||||
case .unknown:
|
||||
return LoadingGalleryContentViewController(caption: nil) {
|
||||
return LoadingGalleryContentViewController {
|
||||
do {
|
||||
let (data, _) = try await URLSession.shared.data(from: attachment.url)
|
||||
let url = FileManager.default.temporaryDirectory.appendingPathComponent(attachment.url.lastPathComponent)
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
//
|
||||
// FollowRequestNotificationViewController.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 5/19/24.
|
||||
// Copyright © 2024 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
|
||||
class FollowRequestNotificationViewController: UIViewController, CollectionViewController {
|
||||
|
||||
private let mastodonController: MastodonController
|
||||
private let notification: Pachyderm.Notification
|
||||
|
||||
var collectionView: UICollectionView! {
|
||||
view as? UICollectionView
|
||||
}
|
||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
|
||||
init(notification: Pachyderm.Notification, mastodonController: MastodonController) {
|
||||
precondition(notification.kind == .followRequest)
|
||||
self.mastodonController = mastodonController
|
||||
self.notification = notification
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
title = "Follow Request"
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
||||
section.readableContentInset(in: environment)
|
||||
return section
|
||||
}
|
||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.allowsFocus = true
|
||||
dataSource = createDataSource()
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let followRequestCell = UICollectionView.CellRegistration<FollowRequestNotificationCollectionViewCell, Void> { [unowned self] cell, indexPath, itemIdentifier in
|
||||
cell.delegate = self
|
||||
cell.updateUI(notification: self.notification)
|
||||
}
|
||||
return UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
return collectionView.dequeueConfiguredReusableCell(using: followRequestCell, for: indexPath, item: ())
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.notifications])
|
||||
snapshot.appendItems([.notification])
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
clearSelectionOnAppear(animated: animated)
|
||||
}
|
||||
}
|
||||
|
||||
extension FollowRequestNotificationViewController {
|
||||
enum Section {
|
||||
case notifications
|
||||
}
|
||||
enum Item {
|
||||
case notification
|
||||
}
|
||||
}
|
||||
|
||||
extension FollowRequestNotificationViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
selected(account: notification.account.id)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard let cell = collectionView.cellForItem(at: indexPath) else {
|
||||
return nil
|
||||
}
|
||||
let accountID = notification.account.id
|
||||
return UIContextMenuConfiguration {
|
||||
ProfileViewController(accountID: accountID, mastodonController: self.mastodonController)
|
||||
} actionProvider: { _ in
|
||||
let cell = cell as! FollowRequestNotificationCollectionViewCell
|
||||
let acceptRejectChildren = [
|
||||
UIAction(title: "Accept", image: UIImage(systemName: "checkmark.circle"), handler: { _ in cell.acceptButtonPressed() }),
|
||||
UIAction(title: "Reject", image: UIImage(systemName: "xmark.circle"), handler: { _ in cell.rejectButtonPressed() }),
|
||||
]
|
||||
let acceptRejectMenu: UIMenu
|
||||
if #available(iOS 16.0, *) {
|
||||
acceptRejectMenu = UIMenu(options: .displayInline, preferredElementSize: .medium, children: acceptRejectChildren)
|
||||
} else {
|
||||
acceptRejectMenu = UIMenu(options: .displayInline, children: acceptRejectChildren)
|
||||
}
|
||||
return UIMenu(children: [
|
||||
acceptRejectMenu,
|
||||
UIMenu(options: .displayInline, children: self.actionsForProfile(accountID: accountID, source: .view(cell))),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: any UIContextMenuInteractionCommitAnimating) {
|
||||
MenuPreviewHelper.willPerformPreviewAction(animator: animator, presenter: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension FollowRequestNotificationViewController: UICollectionViewDragDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: any UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
let provider = NSItemProvider(object: notification.account.url as NSURL)
|
||||
let activity = UserActivityManager.showProfileActivity(id: notification.account.id, accountID: mastodonController.accountInfo!.id)
|
||||
activity.displaysAuxiliaryScene = true
|
||||
provider.registerObject(activity, visibility: .all)
|
||||
return [UIDragItem(itemProvider: provider)]
|
||||
}
|
||||
}
|
||||
|
||||
extension FollowRequestNotificationViewController: TuskerNavigationDelegate {
|
||||
var apiController: MastodonController! { mastodonController }
|
||||
}
|
||||
|
||||
extension FollowRequestNotificationViewController: MenuActionProvider {
|
||||
}
|
||||
|
||||
extension FollowRequestNotificationViewController: StatusBarTappableViewController {
|
||||
func handleStatusBarTapped(xPosition: CGFloat) -> StatusBarTapActionResult {
|
||||
collectionView.scrollToTop()
|
||||
return .stop
|
||||
}
|
||||
}
|
|
@ -89,7 +89,8 @@ class NotificationLoadingViewController: UIViewController {
|
|||
case .follow:
|
||||
vc = ProfileViewController(accountID: notification.account.id, mastodonController: mastodonController)
|
||||
case .followRequest:
|
||||
vc = FollowRequestNotificationViewController(notification: notification, mastodonController: mastodonController)
|
||||
// todo
|
||||
return
|
||||
case .unknown:
|
||||
showLoadingError(Error.unknownType)
|
||||
return
|
||||
|
|
|
@ -17,15 +17,6 @@ struct NotificationsPrefsView: View {
|
|||
|
||||
var body: some View {
|
||||
List {
|
||||
NavigationLink {
|
||||
TipJarView()
|
||||
} label: {
|
||||
Text("Push notifications are available for free to all users, but providing them has an ongoing cost. If you like the app, please consider \(Text("supporting Tusker").foregroundColor(.accentColor)).")
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.listRowBackground(Color.accentColor.opacity(0.1))
|
||||
|
||||
Section {
|
||||
ForEach(userAccounts.accounts) { account in
|
||||
PushInstanceSettingsView(account: account)
|
||||
|
|
|
@ -11,24 +11,18 @@ import StoreKit
|
|||
import Combine
|
||||
|
||||
struct TipJarView: View {
|
||||
private static let tipProductIDs = [
|
||||
private static let productIDs = [
|
||||
"tusker.tip.small",
|
||||
"tusker.tip.medium",
|
||||
"tusker.tip.large",
|
||||
]
|
||||
private static let supporterProductIDs = [
|
||||
"tusker.supporter.regular",
|
||||
]
|
||||
|
||||
@State private var isLoaded = false
|
||||
@State private var tipProducts: [(Product, Bool)] = []
|
||||
@State private var supporterProducts: [(Product, Bool)] = []
|
||||
@State private var products: [(Product, Bool)] = []
|
||||
@State private var error: Error?
|
||||
@State private var showConfetti = false
|
||||
@State private var updatesObserver: Task<Void, Never>?
|
||||
@State private var tipButtonWidth: CGFloat?
|
||||
@State private var supporterButtonWidth: CGFloat?
|
||||
@State private var supporterStartDate: Date?
|
||||
@State private var buttonWidth: CGFloat?
|
||||
@StateObject private var observer = UbiquitousKeyValueStoreObserver()
|
||||
|
||||
var body: some View {
|
||||
|
@ -53,20 +47,9 @@ struct TipJarView: View {
|
|||
updatesObserver = Task.detached { @MainActor in
|
||||
await observeTransactionUpdates()
|
||||
}
|
||||
for await verificationResult in Transaction.currentEntitlements {
|
||||
if case .verified(let transaction) = verificationResult,
|
||||
Self.supporterProductIDs.contains(transaction.productID),
|
||||
await transaction.subscriptionStatus?.state == .subscribed {
|
||||
supporterStartDate = transaction.originalPurchaseDate
|
||||
break
|
||||
}
|
||||
}
|
||||
do {
|
||||
let allProducts = try await Product.products(for: Self.tipProductIDs + Self.supporterProductIDs).map { ($0, false) }
|
||||
tipProducts = allProducts.filter { Self.tipProductIDs.contains($0.0.id) }
|
||||
tipProducts.sort(by: { $0.0.price < $1.0.price })
|
||||
supporterProducts = allProducts.filter { Self.supporterProductIDs.contains($0.0.id) }
|
||||
supporterProducts.sort(by: { $0.0.price < $1.0.price })
|
||||
products = try await Product.products(for: Self.productIDs).map { ($0, false) }
|
||||
products.sort(by: { $0.0.price < $1.0.price })
|
||||
isLoaded = true
|
||||
} catch {
|
||||
self.error = .fetchingProducts(error)
|
||||
|
@ -84,15 +67,25 @@ struct TipJarView: View {
|
|||
private var productsView: some View {
|
||||
if isLoaded {
|
||||
VStack {
|
||||
supporterSubscriptions
|
||||
Text("If you're enjoying using Tusker and want to show your gratitude or help support its development, it is greatly appreciated!")
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal)
|
||||
|
||||
tipPurchases
|
||||
VStack(alignment: .myAlignment) {
|
||||
ForEach($products, id: \.0.id) { $productAndPurchasing in
|
||||
TipRow(product: productAndPurchasing.0, buttonWidth: buttonWidth, isPurchasing: $productAndPurchasing.1, showConfetti: $showConfetti)
|
||||
}
|
||||
}
|
||||
.onPreferenceChange(ButtonWidthKey.self) { newValue in
|
||||
if let buttonWidth {
|
||||
self.buttonWidth = max(buttonWidth, newValue)
|
||||
} else {
|
||||
self.buttonWidth = newValue
|
||||
}
|
||||
}
|
||||
|
||||
if let tipStatus {
|
||||
tipStatus
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 16)
|
||||
if let total = getTotalTips(), total > 0 {
|
||||
Text("You've tipped a total of \(Text(total, format: products[0].0.priceFormatStyle)) 😍")
|
||||
Text("Thank you!")
|
||||
}
|
||||
}
|
||||
|
@ -102,92 +95,19 @@ struct TipJarView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var supporterSubscriptions: some View {
|
||||
Text("If you want to contribute Tusker's continued development, you can become a supporter. Supporting Tusker is an auto-renewable monthly subscription.")
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal)
|
||||
|
||||
VStack(alignment: .myAlignment) {
|
||||
ForEach($supporterProducts, id: \.0.id) { $productAndPurchasing in
|
||||
TipRow(product: productAndPurchasing.0, buttonWidth: supporterButtonWidth, isPurchasing: $productAndPurchasing.1, showConfetti: $showConfetti)
|
||||
}
|
||||
}
|
||||
.onPreferenceChange(ButtonWidthKey.self) { newValue in
|
||||
if let supporterButtonWidth {
|
||||
self.supporterButtonWidth = max(supporterButtonWidth, newValue)
|
||||
} else {
|
||||
self.supporterButtonWidth = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var tipPurchases: some View {
|
||||
Text("Or, you can choose to make a one-time tip to show your gratitutde or help support the app's development. It is greatly appreciated!")
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 16)
|
||||
|
||||
VStack(alignment: .myAlignment) {
|
||||
ForEach($tipProducts, id: \.0.id) { $productAndPurchasing in
|
||||
TipRow(product: productAndPurchasing.0, buttonWidth: tipButtonWidth, isPurchasing: $productAndPurchasing.1, showConfetti: $showConfetti)
|
||||
}
|
||||
}
|
||||
.onPreferenceChange(ButtonWidthKey.self) { newValue in
|
||||
if let tipButtonWidth {
|
||||
self.tipButtonWidth = max(tipButtonWidth, newValue)
|
||||
} else {
|
||||
self.tipButtonWidth = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var tipStatus: Text? {
|
||||
var text: Text?
|
||||
if let supporterStartDate {
|
||||
var months = Calendar.current.dateComponents([.month], from: supporterStartDate, to: Date()).month!
|
||||
// the user has already paid for n months before the nth month has finished, so reflect that
|
||||
months += 1
|
||||
text = Text("You've been a supporter for ^[\(months) months](inflect: true)")
|
||||
}
|
||||
if let total = getTotalTips(),
|
||||
total > 0 {
|
||||
if let t = text {
|
||||
text = Text("\(t) and tipped \(total.formatted(tipProducts[0].0.priceFormatStyle))")
|
||||
} else {
|
||||
text = Text("You've tipped \(total.formatted(tipProducts[0].0.priceFormatStyle))")
|
||||
}
|
||||
}
|
||||
if let text {
|
||||
return Text("\(text) 😍")
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func observeTransactionUpdates() async {
|
||||
for await verificationResult in StoreKit.Transaction.updates {
|
||||
if let index = tipProducts.firstIndex(where: { $0.0.id == verificationResult.unsafePayloadValue.productID }) {
|
||||
switch verificationResult {
|
||||
case .verified(let transaction):
|
||||
await transaction.finish()
|
||||
self.tipProducts[index].1 = false
|
||||
self.showConfetti = true
|
||||
case .unverified(_, let error):
|
||||
self.error = .verifyingTransaction(error)
|
||||
}
|
||||
} else if let index = supporterProducts.firstIndex(where: { $0.0.id == verificationResult.unsafePayloadValue.productID }) {
|
||||
switch verificationResult {
|
||||
case .verified(let transaction):
|
||||
await transaction.finish()
|
||||
self.supporterProducts[index].1 = false
|
||||
self.showConfetti = true
|
||||
self.supporterStartDate = transaction.originalPurchaseDate
|
||||
case .unverified(_, let error):
|
||||
self.error = .verifyingTransaction(error)
|
||||
}
|
||||
guard let index = products.firstIndex(where: { $0.0.id == verificationResult.unsafePayloadValue.productID }) else {
|
||||
continue
|
||||
}
|
||||
switch verificationResult {
|
||||
case .verified(let transaction):
|
||||
await transaction.finish()
|
||||
self.products[index].1 = false
|
||||
self.showConfetti = true
|
||||
case .unverified(_, let error):
|
||||
self.error = .verifyingTransaction(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,11 +149,25 @@ private struct TipRow: View {
|
|||
Text(product.displayName)
|
||||
.alignmentGuide(.myAlignment, computeValue: { context in context[.trailing] })
|
||||
|
||||
if let subscription = product.subscription {
|
||||
SubscriptionButton(product: product, subscriptionInfo: subscription, isPurchasing: $isPurchasing, buttonWidth: buttonWidth, purchase: purchase)
|
||||
} else {
|
||||
tipButton
|
||||
Button {
|
||||
Task {
|
||||
await self.purchase()
|
||||
}
|
||||
} label: {
|
||||
if isPurchasing {
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
.frame(width: buttonWidth, alignment: .center)
|
||||
} else {
|
||||
Text(product.displayPrice)
|
||||
.background(GeometryReader { proxy in
|
||||
Color.clear
|
||||
.preference(key: ButtonWidthKey.self, value: proxy.size.width)
|
||||
})
|
||||
.frame(width: buttonWidth)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
.alertWithData("Error", data: $error) { _ in
|
||||
Button("OK") {}
|
||||
|
@ -242,28 +176,6 @@ private struct TipRow: View {
|
|||
}
|
||||
}
|
||||
|
||||
private var tipButton: some View {
|
||||
Button {
|
||||
Task {
|
||||
await self.purchase()
|
||||
}
|
||||
} label: {
|
||||
if isPurchasing {
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
.frame(width: buttonWidth, alignment: .center)
|
||||
} else {
|
||||
Text(product.displayPrice)
|
||||
.background(GeometryReader { proxy in
|
||||
Color.clear
|
||||
.preference(key: ButtonWidthKey.self, value: proxy.size.width)
|
||||
})
|
||||
.frame(width: buttonWidth)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func purchase() async {
|
||||
isPurchasing = true
|
||||
|
@ -309,71 +221,6 @@ private struct TipRow: View {
|
|||
}
|
||||
}
|
||||
|
||||
private struct SubscriptionButton: View {
|
||||
let product: Product
|
||||
let subscriptionInfo: Product.SubscriptionInfo
|
||||
@Binding var isPurchasing: Bool
|
||||
let buttonWidth: CGFloat?
|
||||
let purchase: () async -> Void
|
||||
@State private var hasPurchased = false
|
||||
@State private var showManageSheet = false
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
if #available(iOS 17.0, *), hasPurchased {
|
||||
showManageSheet = true
|
||||
} else {
|
||||
Task {
|
||||
await purchase()
|
||||
await updateHasPurchased()
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
if #available(iOS 17.0, *), hasPurchased {
|
||||
Text("Manage")
|
||||
} else if isPurchasing {
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
.frame(width: buttonWidth, alignment: .center)
|
||||
} else {
|
||||
let per: String = if subscriptionInfo.subscriptionPeriod.value == 1, subscriptionInfo.subscriptionPeriod.unit == .month {
|
||||
"mo"
|
||||
} else {
|
||||
subscriptionInfo.subscriptionPeriod.formatted(product.subscriptionPeriodFormatStyle)
|
||||
}
|
||||
Text("\(product.displayPrice)/\(per)")
|
||||
.background(GeometryReader { proxy in
|
||||
Color.clear
|
||||
.preference(key: ButtonWidthKey.self, value: proxy.size.width)
|
||||
})
|
||||
.frame(width: buttonWidth)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.task {
|
||||
await updateHasPurchased()
|
||||
}
|
||||
.onChange(of: showManageSheet) {
|
||||
if !$0 {
|
||||
Task {
|
||||
await updateHasPurchased()
|
||||
}
|
||||
}
|
||||
}
|
||||
.manageSubscriptionsSheetIfAvailable(isPresented: $showManageSheet, subscriptionGroupID: subscriptionInfo.subscriptionGroupID)
|
||||
}
|
||||
|
||||
private func updateHasPurchased() async {
|
||||
switch await Transaction.currentEntitlement(for: product.id) {
|
||||
case .verified(let transaction):
|
||||
let state = await transaction.subscriptionStatus?.state
|
||||
hasPurchased = state == .subscribed
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension HorizontalAlignment {
|
||||
private enum MyTrailing: AlignmentID {
|
||||
static func defaultValue(in context: ViewDimensions) -> CGFloat {
|
||||
|
@ -416,15 +263,3 @@ private class UbiquitousKeyValueStoreObserver: ObservableObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension View {
|
||||
@available(iOS, obsoleted: 17.0)
|
||||
@ViewBuilder
|
||||
func manageSubscriptionsSheetIfAvailable(isPresented: Binding<Bool>, subscriptionGroupID: String) -> some View {
|
||||
if #available(iOS 17.0, *) {
|
||||
self.manageSubscriptionsSheet(isPresented: isPresented, subscriptionGroupID: subscriptionGroupID)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,94 +53,13 @@
|
|||
"settings" : {
|
||||
"_applicationInternalID" : "1498334597",
|
||||
"_developerTeamID" : "V4WK9KR9U2",
|
||||
"_failTransactionsEnabled" : false,
|
||||
"_lastSynchronizedDate" : 737914663.21114194,
|
||||
"_storeKitErrors" : [
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Load Products"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Purchase"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Verification"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "App Store Sync"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Subscription Status"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "App Transaction"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Manage Subscriptions Sheet"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Refund Request Sheet"
|
||||
},
|
||||
{
|
||||
"current" : null,
|
||||
"enabled" : false,
|
||||
"name" : "Offer Code Redeem Sheet"
|
||||
}
|
||||
]
|
||||
"_lastSynchronizedDate" : 696310076.23998904
|
||||
},
|
||||
"subscriptionGroups" : [
|
||||
{
|
||||
"id" : "21490109",
|
||||
"localizations" : [
|
||||
|
||||
],
|
||||
"name" : "Tip Jar",
|
||||
"subscriptions" : [
|
||||
{
|
||||
"adHocOffers" : [
|
||||
|
||||
],
|
||||
"codeOffers" : [
|
||||
|
||||
],
|
||||
"displayPrice" : "1.99",
|
||||
"familyShareable" : false,
|
||||
"groupNumber" : 1,
|
||||
"internalID" : "6502909920",
|
||||
"introductoryOffer" : null,
|
||||
"localizations" : [
|
||||
{
|
||||
"description" : "Support the continued development of Tusker!",
|
||||
"displayName" : "Tusker Supporter",
|
||||
"locale" : "en_US"
|
||||
}
|
||||
],
|
||||
"productID" : "tusker.supporter.regular",
|
||||
"recurringSubscriptionPeriod" : "P1M",
|
||||
"referenceName" : "tusker.supporter.regular",
|
||||
"subscriptionGroupID" : "21490109",
|
||||
"type" : "RecurringSubscription"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"version" : {
|
||||
"major" : 3,
|
||||
"major" : 2,
|
||||
"minor" : 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// https://help.apple.com/xcode/#/dev745c5c974
|
||||
|
||||
MARKETING_VERSION = 2024.2
|
||||
CURRENT_PROJECT_VERSION = 124
|
||||
CURRENT_PROJECT_VERSION = 122
|
||||
CURRENT_PROJECT_VERSION = $(inherited)$(CURRENT_PROJECT_VERSION_BUILD_SUFFIX_$(CONFIGURATION))
|
||||
|
||||
CURRENT_PROJECT_VERSION_BUILD_SUFFIX_Debug=-dev
|
||||
|
|
Loading…
Reference in New Issue