package com.github.nullptroma.wallenc.ui.resources

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource

@Composable
fun UserNotification.resolveText(): String = when (this) {
    is UserNotification.TextRes -> {
        if (formatArgs.isEmpty()) {
            stringResource(id)
        } else {
            stringResource(id, *formatArgs.toTypedArray())
        }
    }
    is UserNotification.Plain -> message
}

fun UserNotification.resolve(resolver: UiStringResolver): String = when (this) {
    is UserNotification.TextRes -> {
        if (formatArgs.isEmpty()) {
            resolver(id)
        } else {
            resolver(id, *formatArgs.toTypedArray())
        }
    }
    is UserNotification.Plain -> message
}
