package com.fastest.pass.browse.presentation.ui.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.fastest.pass.R
import com.fastest.pass.login.presentation.ui.components.ClickType

@Composable
fun BrowsePasswordScreen(
    isItemsAdded: Boolean = false
) {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .padding(horizontal = 30.dp)
            .padding(bottom = 20.dp)
            .background(Color.Transparent),
        contentAlignment = Alignment.Center
    ) {
        if (isItemsAdded) {
            BrowsePasswordListScreen()
        } else {
            BrowsePasswordEmptyListScreen()
        }
    }
}

@Composable
fun BrowsePasswordEmptyListScreen() {
    Box(
        modifier = Modifier
            .fillMaxSize(),
        contentAlignment = Alignment.Center
    ) {
        Column(
            modifier = Modifier,
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            Box(
                modifier = Modifier
                    .border(
                        border = BorderStroke(
                            1.dp,
                            colorResource(id = R.color.home_background_color)
                        ), shape = RoundedCornerShape(25.dp)
                    )
                    .clip(RoundedCornerShape(25.dp))
                    .background(Color.Transparent)
                    .clickable {
                    }
            ) {
                Image(
                    painter = painterResource(id = R.drawable.password_lock),
                    contentDescription = "Password",
                    modifier = Modifier
                        .padding(28.dp)
                        .size(48.dp)
                )
            }
            Spacer(modifier = Modifier.height(20.dp))
            Text(
                text = "Store password information",
                color = colorResource(id = R.color.gray_splash),
                style = MaterialTheme.typography.bodyMedium.copy(
                    fontSize = 24.sp
                ),
            )
            Spacer(modifier = Modifier.height(10.dp))
            Text(
                text = "Securely store your sensitive password \n information for your private use only.",
                color = colorResource(id = R.color.gray_splash),
                style = MaterialTheme.typography.labelLarge.copy(
                    fontSize = 16.sp
                ),
            )
            Spacer(modifier = Modifier.height(15.dp))
            StoreInfoButton(buttonText = "Store password info")

        }
    }
}

@Composable
fun BrowsePasswordListScreen() {}

@Composable
fun ColumnScope.StoreInfoButton(buttonText: String) {
    Button(
        modifier = Modifier
            .padding(start = 0.dp, end = 0.dp)
            .background(colorResource(id = R.color.transparent))
            .fillMaxWidth()
            .height(60.dp)
            .clickable() { },
        onClick = {},
        shape = RoundedCornerShape(15.dp),
//            border = BorderStroke(25.dp, colorResource(id = R.color.black)),
        colors = ButtonDefaults.buttonColors(
            contentColor = colorResource(id = R.color.white),
            containerColor = colorResource(id = R.color.red_login_button),
        ),
    )
    {
        Text(
            text = buttonText,
            style = MaterialTheme.typography.bodyMedium.copy(
                fontSize = 20.sp,
                color = colorResource(id = R.color.white)
            ),
            textAlign = TextAlign.Center
        )
    }
}