Skip to content

Commit

Permalink
完善 PGC 内容
Browse files Browse the repository at this point in the history
  • Loading branch information
aaa1115910 committed Oct 22, 2024
1 parent 87b6edb commit 4a0f60f
Show file tree
Hide file tree
Showing 29 changed files with 1,140 additions and 641 deletions.
16 changes: 14 additions & 2 deletions app/src/main/kotlin/dev/aaa1115910/bv/BVApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import dev.aaa1115910.biliapi.repositories.FavoriteRepository
import dev.aaa1115910.biliapi.repositories.HistoryRepository
import dev.aaa1115910.biliapi.repositories.IndexRepository
import dev.aaa1115910.biliapi.repositories.LoginRepository
import dev.aaa1115910.biliapi.repositories.PgcRepository
import dev.aaa1115910.biliapi.repositories.RecommendVideoRepository
import dev.aaa1115910.biliapi.repositories.SearchRepository
import dev.aaa1115910.biliapi.repositories.SeasonRepository
Expand All @@ -34,13 +35,18 @@ import dev.aaa1115910.bv.viewmodel.PlayerViewModel
import dev.aaa1115910.bv.viewmodel.TagViewModel
import dev.aaa1115910.bv.viewmodel.UserViewModel
import dev.aaa1115910.bv.viewmodel.VideoPlayerV3ViewModel
import dev.aaa1115910.bv.viewmodel.home.AnimeViewModel
import dev.aaa1115910.bv.viewmodel.home.DynamicViewModel
import dev.aaa1115910.bv.viewmodel.home.PopularViewModel
import dev.aaa1115910.bv.viewmodel.home.RecommendViewModel
import dev.aaa1115910.bv.viewmodel.index.AnimeIndexViewModel
import dev.aaa1115910.bv.viewmodel.login.AppQrLoginViewModel
import dev.aaa1115910.bv.viewmodel.login.SmsLoginViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcAnimeViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcDocumentaryViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcGuoChuangViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcMovieViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcTvViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcVarietyViewModel
import dev.aaa1115910.bv.viewmodel.search.SearchInputViewModel
import dev.aaa1115910.bv.viewmodel.search.SearchResultViewModel
import dev.aaa1115910.bv.viewmodel.user.FavoriteViewModel
Expand Down Expand Up @@ -157,6 +163,7 @@ val appModule = module {
single { SeasonRepository(get()) }
single { dev.aaa1115910.biliapi.repositories.UserRepository(get(), get()) }
single { IndexRepository() }
single { PgcRepository() }
viewModel { DynamicViewModel(get(), get()) }
viewModel { RecommendViewModel(get()) }
viewModel { PopularViewModel(get()) }
Expand All @@ -170,13 +177,18 @@ val appModule = module {
viewModel { FollowViewModel(get()) }
viewModel { SearchInputViewModel(get()) }
viewModel { SearchResultViewModel(get()) }
viewModel { AnimeViewModel() }
viewModel { FollowingSeasonViewModel(get()) }
viewModel { TagViewModel() }
viewModel { VideoPlayerV3ViewModel(get(), get()) }
viewModel { VideoDetailViewModel(get()) }
viewModel { UserSwitchViewModel(get()) }
viewModel { AnimeIndexViewModel(get()) }
viewModel { PgcAnimeViewModel(get()) }
viewModel { PgcGuoChuangViewModel(get()) }
viewModel { PgcDocumentaryViewModel(get()) }
viewModel { PgcMovieViewModel(get()) }
viewModel { PgcTvViewModel(get()) }
viewModel { PgcVarietyViewModel(get()) }
}

val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "Settings")
77 changes: 77 additions & 0 deletions app/src/main/kotlin/dev/aaa1115910/bv/component/pgc/Carousel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package dev.aaa1115910.bv.component.pgc

import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Carousel
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
import coil.compose.AsyncImage
import dev.aaa1115910.biliapi.entity.pgc.PgcCarouselData
import dev.aaa1115910.bv.activities.video.SeasonInfoActivity
import dev.aaa1115910.bv.entity.proxy.ProxyArea
import dev.aaa1115910.bv.util.focusedBorder


@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
fun PgcCarousel(
modifier: Modifier = Modifier,
data: List<PgcCarouselData.CarouselItem>
) {
val context = LocalContext.current

Carousel(
itemCount = data.size,
modifier = modifier
//.fillMaxWidth()
.height(240.dp)
.clip(MaterialTheme.shapes.large)
.focusedBorder(),
contentTransformEndToStart =
fadeIn(tween(1000)).togetherWith(fadeOut(tween(1000))),
contentTransformStartToEnd =
fadeIn(tween(1000)).togetherWith(fadeOut(tween(1000)))
) { itemIndex ->
PgcCarouselCard(
data = data[itemIndex],
onClick = {
SeasonInfoActivity.actionStart(
context = context,
epId = data[itemIndex].episodeId,
seasonId = data[itemIndex].seasonId,
proxyArea = ProxyArea.checkProxyArea(data[itemIndex].title)
)
}
)
}
}

@Composable
fun PgcCarouselCard(
modifier: Modifier = Modifier,
data: PgcCarouselData.CarouselItem,
onClick: () -> Unit = {}
) {
AsyncImage(
modifier = modifier
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.clickable { onClick() },
model = data.cover,
contentDescription = null,
contentScale = ContentScale.Crop,
alignment = Alignment.TopCenter
)
}
47 changes: 28 additions & 19 deletions app/src/main/kotlin/dev/aaa1115910/bv/screen/main/PgcContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.unit.dp
import dev.aaa1115910.bv.component.DevelopingTipContent
import dev.aaa1115910.bv.component.HomeTopNavItem
import dev.aaa1115910.bv.component.PgcTopNavItem
import dev.aaa1115910.bv.component.TopNav
import dev.aaa1115910.bv.screen.main.pgc.AnimeContent
import dev.aaa1115910.bv.screen.main.pgc.DocumentaryContent
import dev.aaa1115910.bv.screen.main.pgc.GuoChuangContent
import dev.aaa1115910.bv.screen.main.pgc.MovieContent
import dev.aaa1115910.bv.screen.main.pgc.TvContent
import dev.aaa1115910.bv.screen.main.pgc.VarietyContent
import dev.aaa1115910.bv.util.fInfo
import dev.aaa1115910.bv.util.requestFocus
import dev.aaa1115910.bv.viewmodel.home.AnimeViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcAnimeViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcDocumentaryViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcGuoChuangViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcMovieViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcTvViewModel
import dev.aaa1115910.bv.viewmodel.pgc.PgcVarietyViewModel
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -41,7 +49,12 @@ import org.koin.androidx.compose.koinViewModel
fun PgcContent(
modifier: Modifier = Modifier,
navFocusRequester: FocusRequester,
animeViewModel: AnimeViewModel = koinViewModel()
pgcAnimeViewModel: PgcAnimeViewModel = koinViewModel(),
pgcGuoChuangViewModel: PgcGuoChuangViewModel = koinViewModel(),
pgcMovieViewModel: PgcMovieViewModel = koinViewModel(),
pgcDocumentaryViewModel: PgcDocumentaryViewModel = koinViewModel(),
pgcTvViewModel: PgcTvViewModel = koinViewModel(),
pgcVarietyViewModel: PgcVarietyViewModel = koinViewModel()
) {
val scope = rememberCoroutineScope()
val logger = KotlinLogging.logger("PgcContent")
Expand Down Expand Up @@ -107,16 +120,12 @@ fun PgcContent(
},
onClick = { nav ->
when (nav) {
PgcTopNavItem.Anime -> {
logger.fInfo { "reload anime data" }
animeViewModel.reloadAll()
}

PgcTopNavItem.GuoChuang -> {}
PgcTopNavItem.Movie -> {}
PgcTopNavItem.Documentary -> {}
PgcTopNavItem.Tv -> {}
PgcTopNavItem.Variety -> {}
PgcTopNavItem.Anime -> pgcAnimeViewModel.reloadAll()
PgcTopNavItem.GuoChuang -> pgcGuoChuangViewModel.reloadAll()
PgcTopNavItem.Movie -> pgcMovieViewModel.reloadAll()
PgcTopNavItem.Documentary -> pgcDocumentaryViewModel.reloadAll()
PgcTopNavItem.Tv -> pgcTvViewModel.reloadAll()
PgcTopNavItem.Variety -> pgcVarietyViewModel.reloadAll()
}
}
)
Expand All @@ -143,11 +152,11 @@ fun PgcContent(
) { screen ->
when (screen) {
PgcTopNavItem.Anime -> AnimeContent(lazyListState = animeState)
PgcTopNavItem.GuoChuang -> DevelopingTipContent()
PgcTopNavItem.Movie -> DevelopingTipContent()
PgcTopNavItem.Documentary -> DevelopingTipContent()
PgcTopNavItem.Tv -> DevelopingTipContent()
PgcTopNavItem.Variety -> DevelopingTipContent()
PgcTopNavItem.GuoChuang -> GuoChuangContent(lazyListState = guoChuangState)
PgcTopNavItem.Movie -> MovieContent(lazyListState = movieState)
PgcTopNavItem.Documentary -> DocumentaryContent(lazyListState = documentaryState)
PgcTopNavItem.Tv -> TvContent(lazyListState = tvState)
PgcTopNavItem.Variety -> VarietyContent(lazyListState = varietyState)
}
}
}
Expand Down
Loading

0 comments on commit 4a0f60f

Please sign in to comment.