package com.pixelized.desktop.lwa.utils.extention

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalLayoutDirection

@Stable
@Composable
operator fun PaddingValues.plus(other: PaddingValues): PaddingValues {
    val direction = LocalLayoutDirection.current
    return remember(this, other, direction) {
        PaddingValues(
            start = calculateStartPadding(direction) + other.calculateStartPadding(direction),
            top = calculateTopPadding() + other.calculateTopPadding(),
            end = calculateEndPadding(direction) + other.calculateEndPadding(direction),
            bottom = calculateBottomPadding() + other.calculateBottomPadding(),
        )
    }
}