the manager lands in manager/, next to ios/ and web/. it is a fork of this repo's own app, not of feather, so scripts/apply-rebrand.sh excludes it the same way it excludes web/ — the generic feather-to- ftstore rule would rewrite its app.ftstore.manager identity and mangle the lineage notes in its docs. zsign and idevicekitten were vendored copies in the old repo. they are registered as submodules here instead, pinned to the same commits ios/ uses and verified byte-identical to what was vendored. that keeps 71 MB of duplicated source out of the tree and leaves the xcode project's relative paths intact, so project.pbxproj needed no edits. the server moves to ftstore.app in both apps: managerrepoclient, the seeded default source and managerconfig's fallback. downloadmanager keeps the old admin host in its user-agent allowlist — that check is permissive, not identifying, and dropping it would stop sending the header to installs whose stored override still names the old host. the rest of the admin rename lands too: the client id, the base-url environment variable, the info.plist key, and user-facing errors. the userdefaults override key is renamed with a one-time migration read, so an existing install keeps the address its owner configured instead of falling back to the default. tags gain a third namespace: manager-v* for releases, manager-dev for the rolling prerelease. both repos published to a tag called `dev` before; sharing it here would make each build overwrite the other's release assets.
56 lines
1.2 KiB
Swift
56 lines
1.2 KiB
Swift
//
|
|
// Date+timeLeft.swift
|
|
// Feather
|
|
//
|
|
// Created by samara on 16.04.2025.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
extension Date {
|
|
public struct ExpirationInfo {
|
|
public let formatted: String
|
|
public let color: Color
|
|
public let icon: String
|
|
}
|
|
|
|
/// Gathers data for `ExpirationInfo`
|
|
/// - Parameter now: Date
|
|
/// - Returns: `ExpirationInfo`
|
|
public func expirationInfo(from now: Date = .now) -> ExpirationInfo {
|
|
let timeLeft = self.timeIntervalSince(now)
|
|
|
|
guard timeLeft > 0 else {
|
|
return ExpirationInfo(
|
|
formatted: .localized("Expired"),
|
|
color: .gray,
|
|
icon: "xmark.octagon"
|
|
)
|
|
}
|
|
|
|
let daysLeft = Int(timeLeft / 86400)
|
|
let color = Color.expiration(days: daysLeft)
|
|
|
|
let formatter = Date._expirationFormatter(for: timeLeft)
|
|
let timeString = formatter.string(from: timeLeft) ?? .localized("%lld days", arguments: daysLeft)
|
|
|
|
return ExpirationInfo(
|
|
formatted: timeString,
|
|
color: color,
|
|
icon: "clock"
|
|
)
|
|
}
|
|
|
|
private static func _expirationFormatter(for interval: TimeInterval) -> DateComponentsFormatter {
|
|
let formatter = DateComponentsFormatter()
|
|
formatter.allowedUnits = interval < 3600
|
|
? [.minute]
|
|
: interval < 86400
|
|
? [.hour]
|
|
: [.day]
|
|
formatter.unitsStyle = .full
|
|
return formatter
|
|
}
|
|
}
|