SystemIntegration.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/services/system/SystemIntegration.kt
1package eu.friedcutlet.yokan.services.system23import kotlinx.coroutines.flow.MutableStateFlow4import kotlinx.coroutines.flow.StateFlow56/** A one-off check; [NetworkMonitor] follows network changes. */7expect fun isOnUnmeteredNetwork(): Boolean89/** Whether the device's current network is unmetered, updated as it changes networks. */10interface NetworkMonitor {11 /** False on a metered or Low Data Mode network, and without a network. */12 val unmetered: StateFlow<Boolean>13}1415/** Registers a monitor with the platform for the process lifetime; create one per process. */16expect fun createNetworkMonitor(): NetworkMonitor1718/** Platforms that don't expose metering (desktop, browser) are always unmetered. */19internal object UnmeteredNetwork : NetworkMonitor {20 override val unmetered: StateFlow<Boolean> = MutableStateFlow(true)21}2223expect fun openSystemBrowser(url: String): Boolean2425/**26 * Apply the user-chosen UI language to the underlying platform so Compose27 * Multiplatform Resources picks up the matching translation on the next28 * recomposition. Pass `null` (or blank) to restore the system default.29 *30 * - JVM (Android + Desktop): updates `java.util.Locale.getDefault()`.31 * - iOS: sets `NSUserDefaults.AppleLanguages` — change takes effect on32 * next app launch (iOS caches the bundle locale).33 */34expect fun applyAppLanguage(languageCode: String?)35