Skip to content

Commit

Permalink
chore: Remove VerticalConnectionStatusView
Browse files Browse the repository at this point in the history
  • Loading branch information
wba2hi committed Feb 16, 2024
1 parent 084dd8f commit 5777ca2
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 492 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,43 @@ package org.eclipse.kuksa.companion.feature.connection.view
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
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.material3.CircularProgressIndicator
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.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.constraintlayout.compose.ConstraintLayout
import org.eclipse.kuksa.companion.R
import org.eclipse.kuksa.companion.extension.isVisible
import org.eclipse.kuksa.companion.feature.connection.viewModel.ConnectionStatusViewModel
import org.eclipse.kuksa.companion.feature.connection.viewModel.ConnectionStatusViewModel.ConnectionState

val StatusBarHeight = 50.dp
private val iconSize = 30.dp
private val paddingEnd = 5.dp

@Composable
fun HorizontalConnectionStatusView(
viewModel: ConnectionStatusViewModel,
modifier: Modifier = Modifier,
) {
val connectionState = viewModel.connectionState
val connectionStateLabel = connectionState.toString()
val backgroundColor = viewModel.backgroundColor
val backgroundColor = MaterialTheme.colorScheme.errorContainer

Row(
Box(
contentAlignment = Alignment.Center,
modifier = modifier
.fillMaxWidth()
.height(StatusBarHeight)
Expand All @@ -61,42 +67,41 @@ fun HorizontalConnectionStatusView(
viewModel.onClickReconnect()
},
) {
val isAnimating = connectionState == ConnectionState.CONNECTING
var text = connectionStateLabel
text = animateLoadingText(isAnimating, text)
Row {
when (connectionState) {
ConnectionState.DISCONNECTED -> {
Image(
painter = painterResource(id = R.drawable.baseline_refresh_24),
contentDescription = "Reconnect",
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
alignment = Alignment.CenterEnd,
modifier = Modifier
.size(iconSize)
.padding(end = paddingEnd),
)
}

ConnectionState.CONNECTING -> {
CircularProgressIndicator(
color = MaterialTheme.colorScheme.error,
modifier = Modifier
.size(iconSize)
.padding(end = paddingEnd),
)
}

else -> {
// unused
}
}

ConstraintLayout(modifier = Modifier.height(StatusBarHeight)) {
val (textRef, imageRef) = createRefs()
Text(
text,
color = Color.White,
connectionStateLabel,
color = MaterialTheme.colorScheme.error,
textAlign = TextAlign.Center,
fontWeight = FontWeight.Bold,
modifier = Modifier
.fillMaxWidth()
.constrainAs(textRef) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)

start.linkTo(parent.start)
end.linkTo(imageRef.start)
},
)

Image(
painter = painterResource(id = R.drawable.baseline_refresh_24),
contentDescription = "Reconnect",
colorFilter = ColorFilter.tint(Color.White),
alignment = Alignment.CenterEnd,
modifier = Modifier
.constrainAs(imageRef) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)

end.linkTo(parent.end)
}
.padding(10.dp)
.isVisible(connectionState == ConnectionState.DISCONNECTED),
.align(Alignment.CenterVertically),
)
}
}
Expand Down
Loading

0 comments on commit 5777ca2

Please sign in to comment.