Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe committed Nov 29, 2024
1 parent 21c7854 commit d6ba045
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.grakovne.lissen.ui.screens.player

import android.content.Context
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
Expand Down Expand Up @@ -42,7 +41,6 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import coil.ImageLoader
import org.grakovne.lissen.R
import org.grakovne.lissen.channel.common.LibraryType
import org.grakovne.lissen.domain.DetailedItem
import org.grakovne.lissen.ui.icons.Search
import org.grakovne.lissen.ui.navigation.AppNavigationService
Expand Down Expand Up @@ -194,6 +192,7 @@ fun PlayerScreen(
TrackDetailsComposable(
viewModel = playerViewModel,
imageLoader = imageLoader,
libraryViewModel = libraryViewModel,
)
}

Expand Down Expand Up @@ -230,4 +229,4 @@ private fun playingItemChanged(
private fun cachePolicyChanged(
contentCachingModelView: ContentCachingModelView,
playingBook: DetailedItem?,
) = contentCachingModelView.localCacheUsing() != playingBook?.localProvided
) = contentCachingModelView.localCacheUsing() != playingBook?.localProvided
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Velocity
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import kotlinx.coroutines.android.awaitFrame
import kotlinx.coroutines.launch
import org.grakovne.lissen.R
import org.grakovne.lissen.viewmodel.LibraryViewModel
import org.grakovne.lissen.viewmodel.PlayerViewModel

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.grakovne.lissen.ui.screens.player.composable

import android.content.Context
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
Expand All @@ -22,19 +23,22 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil.ImageLoader
import coil.request.ImageRequest
import org.grakovne.lissen.R
import org.grakovne.lissen.channel.common.LibraryType
import org.grakovne.lissen.domain.DetailedItem
import org.grakovne.lissen.ui.components.AsyncShimmeringImage
import org.grakovne.lissen.viewmodel.LibraryViewModel
import org.grakovne.lissen.viewmodel.PlayerViewModel

@Composable
fun TrackDetailsComposable(
libraryViewModel: LibraryViewModel,
viewModel: PlayerViewModel,
modifier: Modifier = Modifier,
imageLoader: ImageLoader,
Expand Down Expand Up @@ -89,10 +93,11 @@ fun TrackDetailsComposable(
Spacer(modifier = Modifier.height(4.dp))

Text(
text = stringResource(
R.string.player_screen_now_playing_title_chapter_of,
currentTrackIndex + 1,
book?.chapters?.size ?: "?",
text = provideChapterNumberTitle(
currentTrackIndex = currentTrackIndex + 1,
book = book,
libraryType = libraryViewModel.fetchPreferredLibraryType(),
context = context,
),
style = typography.bodySmall,
color = colorScheme.onBackground.copy(alpha = 0.6f),
Expand All @@ -101,3 +106,28 @@ fun TrackDetailsComposable(
)
}
}

private fun provideChapterNumberTitle(
currentTrackIndex: Int,
book: DetailedItem?,
libraryType: LibraryType,
context: Context,
): String = when (libraryType) {
LibraryType.LIBRARY -> context.getString(
R.string.player_screen_now_playing_title_chapter_of,
currentTrackIndex + 1,
book?.chapters?.size ?: "?",
)

LibraryType.PODCAST -> context.getString(
R.string.player_screen_now_playing_title_podcast_of,
currentTrackIndex + 1,
book?.chapters?.size ?: "?",
)

LibraryType.UNKNOWN -> context.getString(
R.string.player_screen_now_playing_title_item_of,
currentTrackIndex + 1,
book?.chapters?.size ?: "?",
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.grakovne.lissen.channel.common.LibraryType

fun provideNowPlayingTitle(
libraryType: LibraryType,
context: Context
context: Context,
) = when (libraryType) {
LibraryType.LIBRARY -> context.getString(R.string.player_screen_library_playing_title)
LibraryType.PODCAST -> context.getString(R.string.player_screen_podcast_playing_title)
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<string name="player_screen_chapter_list_navigation">Эпизоды</string>
<string name="player_screen_preferences_navigation">Настройки</string>
<string name="player_screen_library_playing_title">"Список глав"</string>
<string name="player_screen_now_playing_title_chapter_of">Эпизод %1$s из %2$s</string>
<string name="player_screen_now_playing_title_chapter_of">Глава %1$d из %2$s</string>
<string name="settings_screen_title">Настройки</string>
<string name="settings_screen_preferred_library_title">Выбранная библиотека</string>
<string name="settings_screen_connected_as_title">Подключен как</string>
Expand Down Expand Up @@ -80,4 +80,6 @@
<string name="downloads_menu_download_option_clear_items">Удалить загруженные элементы</string>
<string name="player_screen_podcast_playing_title">Список выпусков</string>
<string name="player_screen_items_playing_title">Список элементов</string>
<string name="player_screen_now_playing_title_podcast_of">Выпуск %1$d из %2$s</string>
<string name="player_screen_now_playing_title_item_of">Элемент %1$d из %2$s</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<string name="player_screen_library_playing_title">Playing chapters</string>
<string name="player_screen_podcast_playing_title">Playing episodes</string>
<string name="player_screen_items_playing_title">Playing items</string>
<string name="player_screen_now_playing_title_chapter_of">Chapter %1$s of %2$s</string>
<string name="player_screen_now_playing_title_chapter_of">Chapter %1$d of %2$s</string>
<string name="player_screen_now_playing_title_podcast_of">Episode %1$d of %2$s</string>
<string name="player_screen_now_playing_title_item_of">Item %1$d of %2$s</string>
<string name="settings_screen_title">Preferences</string>
<string name="settings_screen_preferred_library_title">Preferred library</string>
<string name="settings_screen_connected_as_title">Connected as</string>
Expand Down

0 comments on commit d6ba045

Please sign in to comment.