package com.pixelized.biblib.ui.screen.authentication.composable

import androidx.compose.material.LocalTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.withStyle
import com.pixelized.biblib.R
import com.pixelized.biblib.ui.theme.color.GoogleColorPalette

@Composable
fun googleStringResource(): AnnotatedString {
    val default = LocalTextStyle.current.toSpanStyle()
    val google = stringResource(id = R.string.action_google_sign_in)
    return remember {
        buildAnnotatedString {
            withStyle(
                style = default
            ) {
                append(google)
                append(" ")
            }
            withStyle(
                style = default.copy(
                    color = GoogleColorPalette.blue,
                    fontWeight = FontWeight.ExtraBold
                ),
            ) {
                append("G")
            }
            withStyle(
                style = default.copy(
                    color = GoogleColorPalette.red,
                    fontWeight = FontWeight.ExtraBold
                ),
            ) {
                append("o")
            }
            withStyle(
                style = default.copy(
                    color = GoogleColorPalette.yellow,
                    fontWeight = FontWeight.ExtraBold
                ),
            ) {
                append("o")
            }
            withStyle(
                style = default.copy(
                    color = GoogleColorPalette.blue,
                    fontWeight = FontWeight.ExtraBold
                ),
            ) {
                append("g")
            }
            withStyle(
                style = default.copy(
                    color = GoogleColorPalette.green,
                    fontWeight = FontWeight.ExtraBold
                ),
            ) {
                append("l")
            }
            withStyle(
                style = default.copy(
                    color = GoogleColorPalette.red,
                    fontWeight = FontWeight.ExtraBold
                ),
            ) {
                append("e")
            }
        }
    }
}