|
|
@@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.filled.Info
|
|
|
import androidx.compose.runtime.Composable
|
|
|
-import androidx.compose.runtime.collectAsState
|
|
|
import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
@@ -34,12 +33,7 @@ import androidx.compose.ui.input.pointer.pointerInput
|
|
|
import androidx.compose.ui.layout.ContentScale
|
|
|
import androidx.navigation.navArgument
|
|
|
import org.mjdev.tvapp.R
|
|
|
-import org.mjdev.tvapp.base.ui.components.tv.Loading
|
|
|
-import org.mjdev.tvapp.state.DetailsLoadingState
|
|
|
-import org.mjdev.tvapp.viewmodel.DetailViewModel
|
|
|
import org.mjdev.tvlib.annotations.TvPreview
|
|
|
-import org.mjdev.tvlib.extensions.HiltExt.appViewModel
|
|
|
-import org.mjdev.tvlib.extensions.StringExt.asException
|
|
|
import org.mjdev.tvlib.interfaces.ItemPhoto
|
|
|
import org.mjdev.tvlib.interfaces.ItemWithBackground
|
|
|
import org.mjdev.tvlib.interfaces.ItemWithDescription
|
|
|
@@ -73,16 +67,8 @@ class DetailScreen : Screen() {
|
|
|
@Composable
|
|
|
override fun ComposeScreen() {
|
|
|
|
|
|
- val viewModel: DetailViewModel = appViewModel { context ->
|
|
|
- DetailViewModel.mockDetailViewModel(context)
|
|
|
- }
|
|
|
-
|
|
|
val data: Any? = args[data]
|
|
|
|
|
|
- val dataState = remember {
|
|
|
- viewModel.detailsLoadingState(data)
|
|
|
- }.collectAsState()
|
|
|
-
|
|
|
val photo = (data as? ItemPhoto)?.uri
|
|
|
val backgroundImage = (data as? ItemWithBackground<*>)?.background
|
|
|
val image = (data as? ItemWithImage<*>)?.image
|
|
|
@@ -91,69 +77,54 @@ class DetailScreen : Screen() {
|
|
|
val description = (data as? ItemWithDescription<*>)?.description
|
|
|
var infoVisible by remember { mutableStateOf(true) }
|
|
|
|
|
|
- fun postError(error: String) = viewModel.postError(error.asException())
|
|
|
-
|
|
|
- when (dataState.value) {
|
|
|
- is DetailsLoadingState.Ready -> {
|
|
|
- Box(
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .pointerInput(Unit) {
|
|
|
+ detectTapGestures {
|
|
|
+ infoVisible = !infoVisible
|
|
|
+ }
|
|
|
+ },
|
|
|
+ contentAlignment = Alignment.BottomStart,
|
|
|
+ ) {
|
|
|
+ ImageAny(
|
|
|
+ src = photo ?: backgroundImage ?: image,
|
|
|
+ contentDescription = null,
|
|
|
+ contentScale = ContentScale.Crop,
|
|
|
+ modifier = Modifier.fillMaxSize()
|
|
|
+ )
|
|
|
+ AnimatedVisibility(
|
|
|
+ visible = infoVisible,
|
|
|
+ enter = fadeIn(),
|
|
|
+ exit = fadeOut(),
|
|
|
+ ) {
|
|
|
+ Column(
|
|
|
modifier = Modifier
|
|
|
- .fillMaxSize()
|
|
|
- .pointerInput(Unit) {
|
|
|
- detectTapGestures {
|
|
|
- infoVisible = !infoVisible
|
|
|
- }
|
|
|
- },
|
|
|
- contentAlignment = Alignment.BottomStart,
|
|
|
+ .fillMaxWidth()
|
|
|
+ .alpha(0.8f)
|
|
|
+ .background(themeProvider.detailTextBackgroundColor)
|
|
|
+ .padding(
|
|
|
+ vertical = themeProvider.detailTextPaddingVertical,
|
|
|
+ horizontal = themeProvider.detailTextPaddingHorizontal
|
|
|
+ )
|
|
|
) {
|
|
|
- ImageAny(
|
|
|
- src = photo ?: backgroundImage ?: image,
|
|
|
- contentDescription = null,
|
|
|
- contentScale = ContentScale.Crop,
|
|
|
- modifier = Modifier.fillMaxSize()
|
|
|
+ TextAny(
|
|
|
+ text = title ?: "-",
|
|
|
+ style = themeProvider.detailsTitleTextStyle,
|
|
|
+ color = themeProvider.detailsTextColor
|
|
|
+ )
|
|
|
+ TextAny(
|
|
|
+ text = subtitle ?: "-",
|
|
|
+ style = themeProvider.detailsTextStyle,
|
|
|
+ color = themeProvider.detailsTextColor
|
|
|
+ )
|
|
|
+ TextAny(
|
|
|
+ text = description ?: "-",
|
|
|
+ style = themeProvider.detailsTextStyle,
|
|
|
+ color = themeProvider.detailsTextColor
|
|
|
)
|
|
|
- AnimatedVisibility(
|
|
|
- visible = infoVisible,
|
|
|
- enter = fadeIn(),
|
|
|
- exit = fadeOut(),
|
|
|
- ) {
|
|
|
- Column(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .alpha(0.8f)
|
|
|
- .background(themeProvider.detailTextBackgroundColor)
|
|
|
- .padding(
|
|
|
- vertical = themeProvider.detailTextPaddingVertical,
|
|
|
- horizontal = themeProvider.detailTextPaddingHorizontal
|
|
|
- )
|
|
|
- ) {
|
|
|
- TextAny(
|
|
|
- text = title ?: "-",
|
|
|
- style = themeProvider.detailsTitleTextStyle,
|
|
|
- color = themeProvider.detailsTextColor
|
|
|
- )
|
|
|
- TextAny(
|
|
|
- text = subtitle ?: "-",
|
|
|
- style = themeProvider.detailsTextStyle,
|
|
|
- color = themeProvider.detailsTextColor
|
|
|
- )
|
|
|
- TextAny(
|
|
|
- text = description ?: "-",
|
|
|
- style = themeProvider.detailsTextStyle,
|
|
|
- color = themeProvider.detailsTextColor
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- DetailsLoadingState.Loading -> {
|
|
|
- Loading()
|
|
|
- }
|
|
|
-
|
|
|
- else -> {
|
|
|
- Loading()
|
|
|
- postError("File or address $data not found.")
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
}
|