Rename files

This commit is contained in:
vfsfitvnm
2022-09-25 13:30:11 +02:00
parent f463f82f72
commit 9efe4f9579
24 changed files with 77 additions and 150 deletions

View File

@@ -3,24 +3,34 @@ package it.vfsfitvnm.vimusic.ui.screens.album
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import it.vfsfitvnm.route.RouteHandler
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.ui.components.themed.SimpleScaffold
import it.vfsfitvnm.vimusic.ui.components.themed.Scaffold
import it.vfsfitvnm.vimusic.ui.screens.globalRoutes
@OptIn(ExperimentalFoundationApi::class)
@ExperimentalAnimationApi
@Composable
fun AlbumScreen(browseId: String) {
val saveableStateHolder = rememberSaveableStateHolder()
RouteHandler(listenToGlobalEmitter = true) {
globalRoutes()
host {
SimpleScaffold(
Scaffold(
topIconButtonId = R.drawable.chevron_back,
onTopIconButtonClick = pop,
) {
AlbumSongList(browseId = browseId)
tabIndex = 0,
onTabChanged = {},
tabColumnContent = { Item ->
Item(0, "Overview", R.drawable.sparkles)
}
) { currentTabIndex ->
saveableStateHolder.SaveableStateProvider(key = currentTabIndex) {
AlbumSongList(browseId = browseId)
}
}
}
}

View File

@@ -54,11 +54,13 @@ import it.vfsfitvnm.vimusic.ui.styling.shimmer
import it.vfsfitvnm.vimusic.ui.views.SongItem
import it.vfsfitvnm.vimusic.utils.asMediaItem
import it.vfsfitvnm.vimusic.utils.center
import it.vfsfitvnm.vimusic.utils.color
import it.vfsfitvnm.vimusic.utils.enqueue
import it.vfsfitvnm.vimusic.utils.forcePlayAtIndex
import it.vfsfitvnm.vimusic.utils.forcePlayFromBeginning
import it.vfsfitvnm.vimusic.utils.medium
import it.vfsfitvnm.vimusic.utils.secondary
import it.vfsfitvnm.vimusic.utils.semiBold
import it.vfsfitvnm.vimusic.utils.thumbnail
@ExperimentalAnimationApi
@@ -66,12 +68,12 @@ import it.vfsfitvnm.vimusic.utils.thumbnail
@Composable
fun AlbumSongList(
browseId: String,
viewModel: AlbumViewModel = viewModel(
viewModel: AlbumSongListViewModel = viewModel(
key = browseId,
factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return AlbumViewModel(browseId) as T
return AlbumSongListViewModel(browseId) as T
}
}
)
@@ -175,7 +177,7 @@ fun AlbumSongList(
startContent = {
BasicText(
text = "${index + 1}",
style = typography.m.secondary.secondary.center,
style = typography.s.semiBold.center.color(colorPalette.textDisabled),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier
@@ -215,7 +217,7 @@ fun AlbumSongList(
.size(20.dp)
)
}
} ?: viewModel.result?.exceptionOrNull()?.let { _ ->
} ?: viewModel.result?.exceptionOrNull()?.let {
Box(
modifier = Modifier
.pointerInput(Unit) {

View File

@@ -15,7 +15,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
class AlbumViewModel(browseId: String) : ViewModel() {
class AlbumSongListViewModel(browseId: String) : ViewModel() {
var result by mutableStateOf<Result<AlbumWithSongs?>?>(null)
private set

View File

@@ -54,8 +54,8 @@ import it.vfsfitvnm.vimusic.utils.medium
@ExperimentalFoundationApi
@Composable
fun PlaylistsTab(
viewModel: PlaylistsTabViewModel = viewModel(),
fun HomePlaylistList(
viewModel: HomePlaylistListViewModel = viewModel(),
onBuiltInPlaylistClicked: (BuiltInPlaylist) -> Unit,
onPlaylistClicked: (Playlist) -> Unit,
) {

View File

@@ -23,7 +23,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.launch
class PlaylistsTabViewModel(application: Application) : AndroidViewModel(application) {
class HomePlaylistListViewModel(application: Application) : AndroidViewModel(application) {
var items by mutableStateOf(emptyList<PlaylistPreview>())
private set

View File

@@ -102,8 +102,8 @@ fun HomeScreen() {
) { currentTabIndex ->
saveableStateHolder.SaveableStateProvider(key = currentTabIndex) {
when (currentTabIndex) {
0 -> SongsTab()
1 -> PlaylistsTab(
0 -> HomeSongList()
1 -> HomePlaylistList(
onBuiltInPlaylistClicked = { builtInPlaylistRoute(it) },
onPlaylistClicked = { localPlaylistRoute(it.id) }
)

View File

@@ -55,8 +55,8 @@ import it.vfsfitvnm.vimusic.utils.semiBold
@ExperimentalFoundationApi
@ExperimentalAnimationApi
@Composable
fun SongsTab(
viewModel: SongsTabViewModel = viewModel()
fun HomeSongList(
viewModel: HomeSongListViewModel = viewModel()
) {
val (colorPalette, typography) = LocalAppearance.current
val binder = LocalPlayerServiceBinder.current

View File

@@ -23,7 +23,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.launch
class SongsTabViewModel(application: Application) : AndroidViewModel(application) {
class HomeSongListViewModel(application: Application) : AndroidViewModel(application) {
var items by mutableStateOf(emptyList<DetailedSong>())
private set

View File

@@ -47,15 +47,15 @@ import it.vfsfitvnm.youtubemusic.models.NavigationEndpoint
@ExperimentalFoundationApi
@ExperimentalAnimationApi
@Composable
fun LibrarySearchTab(
fun LocalSongSearch(
textFieldValue: TextFieldValue,
onTextFieldValueChanged: (TextFieldValue) -> Unit,
viewModel: LibrarySearchTabViewModel = viewModel(
viewModel: LocalSongSearchViewModel = viewModel(
key = textFieldValue.text,
factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return LibrarySearchTabViewModel(textFieldValue.text) as T
return LocalSongSearchViewModel(textFieldValue.text) as T
}
}
)

View File

@@ -9,7 +9,7 @@ import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.models.DetailedSong
import kotlinx.coroutines.launch
class LibrarySearchTabViewModel(text: String) : ViewModel() {
class LocalSongSearchViewModel(text: String) : ViewModel() {
var items by mutableStateOf(emptyList<DetailedSong>())
private set

View File

@@ -56,18 +56,18 @@ import it.vfsfitvnm.vimusic.utils.secondary
import kotlinx.coroutines.delay
@Composable
fun OnlineSearchTab(
fun OnlineSearch(
textFieldValue: TextFieldValue,
onTextFieldValueChanged: (TextFieldValue) -> Unit,
isOpenableUrl: Boolean,
onSearch: (String) -> Unit,
onUri: () -> Unit,
viewModel: OnlineSearchTabViewModel = viewModel(
viewModel: OnlineSearchViewModel = viewModel(
key = textFieldValue.text,
factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return OnlineSearchTabViewModel(textFieldValue.text) as T
return OnlineSearchViewModel(textFieldValue.text) as T
}
}
)

View File

@@ -11,7 +11,7 @@ import it.vfsfitvnm.youtubemusic.YouTube
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.launch
class OnlineSearchTabViewModel(text: String) : ViewModel() {
class OnlineSearchViewModel(text: String) : ViewModel() {
var history by mutableStateOf(emptyList<SearchQuery>())
private set

View File

@@ -66,7 +66,7 @@ fun SearchScreen(initialTextInput: String, onSearch: (String) -> Unit, onUri: (U
) { currentTabIndex ->
saveableStateHolder.SaveableStateProvider(currentTabIndex) {
when (currentTabIndex) {
0 -> OnlineSearchTab(
0 -> OnlineSearch(
textFieldValue = textFieldValue,
onTextFieldValueChanged = onTextFieldValueChanged,
isOpenableUrl = isOpenableUrl,
@@ -77,7 +77,7 @@ fun SearchScreen(initialTextInput: String, onSearch: (String) -> Unit, onUri: (U
}
}
)
1 -> LibrarySearchTab(
1 -> LocalSongSearch(
textFieldValue = textFieldValue,
onTextFieldValueChanged = onTextFieldValueChanged
)

View File

@@ -27,12 +27,12 @@ inline fun <I : YouTube.Item> ItemSearchResult(
query: String,
filter: String,
crossinline onSearchAgain: () -> Unit,
viewModel: ItemSearchResultViewModel<I> = viewModel(
viewModel: SearchResultViewModel<I> = viewModel(
key = query + filter,
factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return ItemSearchResultViewModel<I>(query, filter) as T
return SearchResultViewModel<I>(query, filter) as T
}
}
),

View File

@@ -11,7 +11,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class ItemSearchResultViewModel<T : YouTube.Item>(
class SearchResultViewModel<T : YouTube.Item>(
private val query: String,
private val filter: String
) : ViewModel() {

View File

@@ -19,7 +19,7 @@ import it.vfsfitvnm.vimusic.utils.secondary
@ExperimentalAnimationApi
@Composable
fun AboutTab() {
fun About() {
val (colorPalette, typography) = LocalAppearance.current
val uriHandler = LocalUriHandler.current

View File

@@ -25,7 +25,7 @@ import it.vfsfitvnm.vimusic.utils.thumbnailRoundnessKey
@ExperimentalAnimationApi
@Composable
fun AppearanceSettingsTab() {
fun AppearanceSettings() {
val (colorPalette) = LocalAppearance.current
var colorPaletteName by rememberPreference(colorPaletteNameKey, ColorPaletteName.Dynamic)

View File

@@ -30,7 +30,7 @@ import it.vfsfitvnm.vimusic.utils.rememberPreference
@OptIn(ExperimentalCoilApi::class)
@ExperimentalAnimationApi
@Composable
fun CacheSettingsTab() {
fun CacheSettings() {
val context = LocalContext.current
val (colorPalette) = LocalAppearance.current
val binder = LocalPlayerServiceBinder.current

View File

@@ -47,7 +47,7 @@ import kotlinx.coroutines.Dispatchers
@ExperimentalAnimationApi
@Composable
fun OtherSettingsTab() {
fun OtherSettings() {
val context = LocalContext.current
val (colorPalette) = LocalAppearance.current

View File

@@ -28,7 +28,7 @@ import it.vfsfitvnm.vimusic.utils.volumeNormalizationKey
@ExperimentalAnimationApi
@Composable
fun PlayerSettingsTab() {
fun PlayerSettings() {
val context = LocalContext.current
val (colorPalette) = LocalAppearance.current
val binder = LocalPlayerServiceBinder.current

View File

@@ -52,11 +52,11 @@ fun SettingsScreen() {
) { currentTabIndex ->
saveableStateHolder.SaveableStateProvider(currentTabIndex) {
when (currentTabIndex) {
0 -> AppearanceSettingsTab()
1 -> PlayerSettingsTab()
2 -> CacheSettingsTab()
3 -> OtherSettingsTab()
4 -> AboutTab()
0 -> AppearanceSettings()
1 -> PlayerSettings()
2 -> CacheSettings()
3 -> OtherSettings()
4 -> About()
}
}
}