package llc.arma.ble.app.ui.screen.password.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
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.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import llc.arma.ble.app.ui.screen.password.ChangePasswordContract

@Composable
fun Result(
    onEvent: (ChangePasswordContract.Event) -> Unit,
    state: ChangePasswordContract.State.LoadingState
) {

    Column(
        modifier = Modifier.padding(20.dp)
    ) {

        when(state){
            ChangePasswordContract.State.LoadingState.Failure -> {

                Box(
                    modifier = Modifier
                        .padding(8.dp)
                        .fillMaxWidth()
                ) {

                    Image(
                        modifier = Modifier
                            .size(125.dp)
                            .align(Alignment.Center),
                        painter = painterResource(llc.arma.ble.R.drawable.ic_error),
                        contentDescription = null
                    )

                }

                Spacer(modifier = Modifier.height(16.dp))

                Text(
                    modifier = Modifier.align(Alignment.CenterHorizontally),
                    text = "Ошибка записи"
                )
            }
            ChangePasswordContract.State.LoadingState.Success -> {

                Box(
                    modifier = Modifier
                        .padding(8.dp)
                        .fillMaxWidth()
                ) {

                    Image(
                        modifier = Modifier
                            .size(125.dp)
                            .align(Alignment.Center),
                        painter = painterResource(llc.arma.ble.R.drawable.ic_done),
                        contentDescription = null
                    )

                }

                Spacer(modifier = Modifier.height(16.dp))

                Text(
                    modifier = Modifier.align(Alignment.CenterHorizontally),
                    text = "Успешно завершено"
                )
            }
            else -> {}
        }

        Spacer(modifier = Modifier.height(20.dp))

        Box(
            modifier = Modifier
        ) {

            Surface(
                modifier = Modifier
                    .fillMaxWidth()
                    .height(50.dp),
                shape = CircleShape,
                color = MaterialTheme.colorScheme.primary,
                onClick = {
                    onEvent(ChangePasswordContract.Event.OnNavigateUp)
                }
            ) {

                Box(modifier = Modifier.fillMaxSize()) {

                    Text(
                        modifier = Modifier.align(Alignment.Center),
                        color = MaterialTheme.colorScheme.onPrimary,
                        style = MaterialTheme.typography.labelLarge,
                        text = "Ок"
                    )

                }

            }

        }

    }

}