package com.lanyun.wanglaotou.composable

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
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 com.google.accompanist.insets.statusBarsPadding
import com.lanyun.wanglaotou.R
import com.lanyun.wanglaotou.ui.theme.red
import com.lanyun.wanglaotou.viewModel.MainViewModel
import com.lanyun.wanglaotou.viewModel.VpnState


@Composable
fun MyFloatingActionButton(
    mainViewModel: MainViewModel
) {


    Box(
        modifier = Modifier
            .size(70.dp),
        contentAlignment= Alignment.Center
    )
    {

        FloatingActionButton(
            modifier = Modifier,
            onClick = {
                mainViewModel.startVpn()
            }
        ) {

            if (mainViewModel.viewStates.isRunning){
                Icon(
                    painter= painterResource(R.drawable.pause),
                    // bitmap=ImageBitmap.imageResource(id = R.drawable.pause),
                    modifier = Modifier,
                    contentDescription=""
                )
            } else {
                Icon(
                    painter= painterResource(R.drawable.play),
                    // bitmap=ImageBitmap.imageResource(id = R.drawable.pause),
                    modifier = Modifier,
                    contentDescription=""
                )
            }
        }

        when(mainViewModel.viewStates.vpnState){
            is VpnState.MainConnected -> {

            }
            is VpnState.MainConnecting -> {
                CircularProgressIndicator(
                    color = MaterialTheme.colors.primary,
                    modifier = Modifier
                        .width(60.dp)
                        .height(60.dp)
                )
            }
            is VpnState.MainStop -> {

            }
            is VpnState.MainStopping -> {

            }
            is VpnState.MainIdLe -> {

            }
            else -> {

            }
        }
    }


}