From 7e92e17429f53463b1b57377389691403bae6b50 Mon Sep 17 00:00:00 2001 From: junepark678 <40409848+junepark678@users.noreply.github.com> Date: Fri, 24 Nov 2023 12:36:54 +0900 Subject: [PATCH] feat(App IDs): make expiration dates more specific --- AltStore/App IDs/AppIDsViewController.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/AltStore/App IDs/AppIDsViewController.swift b/AltStore/App IDs/AppIDsViewController.swift index 1cd764b4..f5007fd4 100644 --- a/AltStore/App IDs/AppIDsViewController.swift +++ b/AltStore/App IDs/AppIDsViewController.swift @@ -91,13 +91,18 @@ private extension AppIDsViewController cell.bannerView.buttonLabel.isHidden = false - let currentDate = Date() + let formatter = DateComponentsFormatter() + formatter.unitsStyle = .full + formatter.includesApproximationPhrase = false + formatter.includesTimeRemainingPhrase = false + formatter.allowedUnits = [.minute, .hour, .day] - let numberOfDays = expirationDate.numberOfCalendarDays(since: currentDate) - let numberOfDaysText = (numberOfDays == 1) ? NSLocalizedString("1 day", comment: "") : String(format: NSLocalizedString("%@ days", comment: ""), NSNumber(value: numberOfDays)) - cell.bannerView.button.setTitle(numberOfDaysText.uppercased(), for: .normal) - attributedAccessibilityLabel.mutableString.append(String(format: NSLocalizedString("Expires in %@.", comment: ""), numberOfDaysText) + " ") + cell.bannerView.button.setTitle(formatter.string(from: expirationDate, to: Date())?.uppercased(), for: .normal) + + formatter.includesTimeRemainingPhrase = true + + attributedAccessibilityLabel.mutableString.append((formatter.string(from: expirationDate, to: Date()) ?? "Unknown amount of time") + " ") } else { @@ -206,7 +211,7 @@ extension AppIDsViewController: UICollectionViewDelegateFlowLayout **App IDs can't be deleted**, but they do expire after one week. SideStore will automatically renew App IDs for all active apps once they've expired. """, comment: "") - let attributedText = NSAttributedString(markdownRepresentation: text, attributes: [.font: headerView.textLabel.font as Any]) + let attributedText = NSAttributedString(markdownRepresentation: text) headerView.textLabel.attributedText = attributedText } else