Files
vnidrop/apple/VniDrop/Platform/AppDependencies+iOS.swift
cdricms 08e61c57af feat(l10n): replace legacy %@ format keys with semantic template keys
The Apple catalog carried four stringly-named passthrough keys ("%@",
"%@ · %@", "%@ %@ · %@", "%@%%") left over from the KMP port. They were
never referenced as keys — the composite strings were built inline with
hardcoded separators, so the middot/percent formatting wasn't localizable.

Renames them to proper semantic keys in strings.json:
  - format_separated_pair(first:second:)     "{first} · {second}"
  - format_separated_triple(first:second:third:)
  - battery_level_value(level:)              "{level}%"
and drops the pure-identity "%@". Wires the inline compositions (size ·
status, count files · size, receivers pending · completed, battery level)
to the generated typed accessors. Catalog now validates with zero warnings.
2026-07-23 17:50:57 +02:00

51 lines
1.7 KiB
Swift

#if os(iOS)
import Foundation
import UIKit
/// Builds the iOS dependency graph, ported from `rememberIosAppDependencies`.
@MainActor
func makeAppDependencies(externalInvitations: ExternalInvitationController) -> AppDependencies {
let device = UIDevice.current
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.1.0"
let env = PlatformEnvironment(
name: "\(device.systemName) \(device.systemVersion)",
appVersion: version,
defaultCoreDataDir: applicationDataDirectory(),
defaultUsername: device.name.isEmpty ? "Receiver" : device.name
)
return AppDependencies(
environment: env,
deviceInfoProvider: IosDeviceInfoProvider(),
fileSystemService: IosFileSystemService(),
notificationService: LocalNotificationService(),
externalInvitations: externalInvitations
)
}
private func applicationDataDirectory() -> String {
let base = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
return base.appendingPathComponent("VniDrop").path
}
private struct IosDeviceInfoProvider: DeviceInfoProvider {
@MainActor
func load() async -> DeviceInfo {
let device = UIDevice.current
let battery: String? = {
let wasMonitoring = device.isBatteryMonitoringEnabled
device.isBatteryMonitoringEnabled = true
defer { device.isBatteryMonitoringEnabled = wasMonitoring }
let level = device.batteryLevel
return level >= 0 ? L10n.Battery.levelValue(level: "\(Int(level * 100))") : nil
}()
return DeviceInfo(
deviceName: device.name,
deviceModel: device.model,
operatingSystem: "\(device.systemName) \(device.systemVersion)",
network: nil,
batteryLevel: battery
)
}
}
#endif