Skip to content

Commit

Permalink
update: add GirdLastItemHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Nov 16, 2023
1 parent 097dbb3 commit 8bf868c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 81 deletions.
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/muedsa/agetv/ui/Size.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package com.muedsa.agetv.ui
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp

val AgePosterSize = DpSize(width = 256.dp, height = 356.dp).div(2)
val AgePosterSize = DpSize(width = 256.dp, height = 356.dp).div(2)
val GirdLastItemHeight = 250.dp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.foundation.lazy.grid.TvGridCells
Expand All @@ -41,17 +40,16 @@ import androidx.tv.material3.ButtonDefaults
import androidx.tv.material3.Card
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Icon
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.OutlinedButton
import androidx.tv.material3.OutlinedIconButton
import androidx.tv.material3.Text
import com.muedsa.agetv.model.LazyType
import com.muedsa.agetv.model.age.AgeCatalogOption
import com.muedsa.agetv.ui.AgePosterSize
import com.muedsa.agetv.ui.GirdLastItemHeight
import com.muedsa.agetv.ui.navigation.NavigationItems
import com.muedsa.agetv.viewmodel.CatalogViewModel
import com.muedsa.compose.tv.model.ContentModel
import com.muedsa.compose.tv.theme.CardContentPadding
import com.muedsa.compose.tv.theme.ImageCardRowCardPadding
import com.muedsa.compose.tv.theme.ScreenPaddingLeft
import com.muedsa.compose.tv.widget.CardType
Expand All @@ -69,15 +67,6 @@ fun CatalogScreen(
errorMsgBoxState: ErrorMessageBoxState,
onNavigate: (NavigationItems, List<String>?) -> Unit = { _, _ -> }
) {
val fontScale = LocalConfiguration.current.fontScale
val titleMediumFontSize = MaterialTheme.typography.titleMedium.fontSize.value
val bodyMediumFontSize = MaterialTheme.typography.bodyMedium.fontSize.value
val contentHeight = remember {
(titleMediumFontSize * fontScale + 0.5f).dp +
(bodyMediumFontSize * fontScale + 0.5f).dp +
CardContentPadding * 2
}

val query by viewModel.querySF.collectAsState()
val searchAnimeLP by viewModel.animeLPSF.collectAsState()

Expand Down Expand Up @@ -313,27 +302,29 @@ fun CatalogScreen(

if (searchAnimeLP.type != LazyType.LOADING && searchAnimeLP.hasNext) {
item {
Column {
Card(
modifier = Modifier
.size(AgePosterSize)
.padding(end = ImageCardRowCardPadding),
onClick = {
viewModel.catalog(searchAnimeLP)
}
Card(
modifier = Modifier
.size(AgePosterSize)
.padding(end = ImageCardRowCardPadding),
onClick = {
viewModel.catalog(searchAnimeLP)
}
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "继续加载")
}
Text(text = "继续加载")
}
Spacer(modifier = Modifier.height(contentHeight))
}
}
}

// 最后一行占位
item {
Spacer(modifier = Modifier.height(GirdLastItemHeight))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.foundation.lazy.grid.TvGridCells
Expand All @@ -31,10 +30,10 @@ import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text
import com.muedsa.agetv.model.LazyType
import com.muedsa.agetv.ui.AgePosterSize
import com.muedsa.agetv.ui.GirdLastItemHeight
import com.muedsa.agetv.ui.navigation.NavigationItems
import com.muedsa.agetv.viewmodel.LatestUpdateViewModel
import com.muedsa.compose.tv.model.ContentModel
import com.muedsa.compose.tv.theme.CardContentPadding
import com.muedsa.compose.tv.theme.ImageCardRowCardPadding
import com.muedsa.compose.tv.theme.ScreenPaddingLeft
import com.muedsa.compose.tv.widget.CardType
Expand All @@ -52,14 +51,6 @@ fun LatestUpdateScreen(
errorMsgBoxState: ErrorMessageBoxState,
onNavigate: (NavigationItems, List<String>?) -> Unit = { _, _ -> }
) {
val fontScale = LocalConfiguration.current.fontScale
val titleMediumFontSize = MaterialTheme.typography.titleMedium.fontSize.value
val bodyMediumFontSize = MaterialTheme.typography.bodyMedium.fontSize.value
val contentHeight = remember {
(titleMediumFontSize * fontScale + 0.5f).dp +
(bodyMediumFontSize * fontScale + 0.5f).dp +
CardContentPadding * 2
}

val latestUpdateLP by viewModel.latestUpdateLPSF.collectAsState()

Expand Down Expand Up @@ -137,27 +128,29 @@ fun LatestUpdateScreen(

if (latestUpdateLP.type != LazyType.LOADING && latestUpdateLP.hasNext) {
item {
Column {
Card(
modifier = Modifier
.size(AgePosterSize)
.padding(end = ImageCardRowCardPadding),
onClick = {
viewModel.latestUpdate()
}
Card(
modifier = Modifier
.size(AgePosterSize)
.padding(end = ImageCardRowCardPadding),
onClick = {
viewModel.latestUpdate()
}
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "继续加载")
}
Text(text = "继续加载")
}
Spacer(modifier = Modifier.height(contentHeight))
}
}
}

// 最后一行占位
item {
Spacer(modifier = Modifier.height(GirdLastItemHeight))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.foundation.lazy.grid.TvGridCells
Expand All @@ -44,10 +43,10 @@ import androidx.tv.material3.Text
import com.muedsa.agetv.model.LazyPagedList
import com.muedsa.agetv.model.LazyType
import com.muedsa.agetv.ui.AgePosterSize
import com.muedsa.agetv.ui.GirdLastItemHeight
import com.muedsa.agetv.ui.navigation.NavigationItems
import com.muedsa.agetv.viewmodel.SearchViewModel
import com.muedsa.compose.tv.model.ContentModel
import com.muedsa.compose.tv.theme.CardContentPadding
import com.muedsa.compose.tv.theme.CustomerColor
import com.muedsa.compose.tv.theme.ImageCardRowCardPadding
import com.muedsa.compose.tv.theme.ScreenPaddingLeft
Expand All @@ -66,14 +65,6 @@ fun SearchScreen(
errorMsgBoxState: ErrorMessageBoxState,
onNavigate: (NavigationItems, List<String>?) -> Unit = { _, _ -> }
) {
val fontScale = LocalConfiguration.current.fontScale
val titleMediumFontSize = MaterialTheme.typography.titleMedium.fontSize.value
val bodyMediumFontSize = MaterialTheme.typography.bodyMedium.fontSize.value
val contentHeight = remember {
(titleMediumFontSize * fontScale + 0.5f).dp +
(bodyMediumFontSize * fontScale + 0.5f).dp +
CardContentPadding * 2
}

val searchText by viewModel.searchTextSF.collectAsState()
val searchAnimeLP by viewModel.searchAnimeLPSF.collectAsState()
Expand Down Expand Up @@ -189,27 +180,29 @@ fun SearchScreen(

if (searchAnimeLP.type != LazyType.LOADING && searchAnimeLP.hasNext) {
item {
Column {
Card(
modifier = Modifier
.size(AgePosterSize)
.padding(end = ImageCardRowCardPadding),
onClick = {
viewModel.searchAnime(searchAnimeLP)
}
Card(
modifier = Modifier
.size(AgePosterSize)
.padding(end = ImageCardRowCardPadding),
onClick = {
viewModel.searchAnime(searchAnimeLP)
}
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = "继续加载")
}
Text(text = "继续加载")
}
Spacer(modifier = Modifier.height(contentHeight))
}
}
}

// 最后一行占位
item {
Spacer(modifier = Modifier.height(GirdLastItemHeight))
}
}
}
}
Expand Down

0 comments on commit 8bf868c

Please sign in to comment.