Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store implementation cleanup #106

Merged
merged 42 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0587943
Merge pull request #102 from c0de-wizard/github-actions-cleanup
thomaskioko Nov 17, 2023
4a334c9
Update all dependencies.
thomaskioko Nov 18, 2023
adb34f8
Remove store5 dependency from domain api module.
thomaskioko Nov 18, 2023
d94fbe5
cleanup domain implementation module and map result to Either impleme…
thomaskioko Nov 18, 2023
2503196
update presentation implementation result mapping.
thomaskioko Nov 18, 2023
3ce9d86
add store dependencies.
thomaskioko Nov 18, 2023
91aba88
minor cleanup.
thomaskioko Nov 18, 2023
7a93434
update ui states.
thomaskioko Nov 18, 2023
eb1087a
update result mapping.
thomaskioko Nov 18, 2023
f9adf25
add helper classes and server error class
thomaskioko Nov 18, 2023
64d998c
add jvm test job
thomaskioko Nov 18, 2023
2ca4cf6
implement type-safe IDs
thomaskioko Nov 19, 2023
374c4d4
Delete unused classes
thomaskioko Nov 19, 2023
050ac0d
Cleanup: Update function signatures, mapping implementation after tab…
thomaskioko Nov 19, 2023
d2adadb
Merge pull request #103 from c0de-wizard/database-cleanup
thomaskioko Nov 19, 2023
1dc2dbb
Delete networkUtil module
thomaskioko Nov 19, 2023
76bbee5
Delete networkComponent class.
thomaskioko Nov 19, 2023
4ea9840
Remove networkUtil dependency
thomaskioko Nov 19, 2023
1231b79
ADd util dependency
thomaskioko Nov 19, 2023
5f48f59
Move classes to util module.
thomaskioko Nov 19, 2023
84a9274
Update imports.
thomaskioko Nov 19, 2023
ca4d5fb
Change log level to info
thomaskioko Nov 19, 2023
2a164c9
Cleanup TMDB DI component.
thomaskioko Nov 19, 2023
c44aa2f
Create transaction runner object.
thomaskioko Nov 19, 2023
bb16c5f
Add delete functions and update dao implementation.
thomaskioko Nov 19, 2023
829b490
Add season detail error state.
thomaskioko Nov 19, 2023
c0d5e39
Update dependencies.
thomaskioko Nov 19, 2023
3f6967b
Migrate season details and episodeImage to use Store5
thomaskioko Nov 19, 2023
200ad30
Move image call to combine block
thomaskioko Nov 19, 2023
b45595c
Male spotless happy
thomaskioko Nov 19, 2023
df06854
Merge pull request #104 from c0de-wizard/feature/complete-store-imple…
thomaskioko Nov 19, 2023
5d15fa0
Update logger to info.
thomaskioko Nov 21, 2023
1cb61cc
Wrap write function in db transaction.
thomaskioko Nov 21, 2023
8a97d45
Fix images not loading on the first call.
thomaskioko Nov 21, 2023
07ecfa2
Add material shapes
thomaskioko Nov 22, 2023
6026d7b
Minor cleanup: Implement material shapes and animate content
thomaskioko Nov 22, 2023
2b03b58
Cleanup platform component implementation.
thomaskioko Nov 22, 2023
1496a09
Replace List with PersistenceList
thomaskioko Nov 22, 2023
329630d
Minor update on Episode List UI.
thomaskioko Nov 22, 2023
ca23344
Make spotless happy
thomaskioko Nov 22, 2023
97f6c5f
Bump up dependency versions.
thomaskioko Nov 22, 2023
ba8bec9
Merge pull request #105 from c0de-wizard/fix-loading-images
thomaskioko Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ jobs:
- name: unitTest
run: ./gradlew testDemoDebug

- name: Jvm Test
run: ./gradlew jvmTest

- uses: actions/upload-artifact@v3
with:
name: unit-test-report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -93,7 +92,7 @@ fun TvManiacOutlinedButton(
borderColor: Color,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = RoundedCornerShape(4.dp),
shape: Shape = MaterialTheme.shapes.small,
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
content: @Composable RowScope.() -> Unit,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
Expand All @@ -26,14 +26,15 @@ fun TvPosterCard(
posterImageUrl: String?,
title: String,
modifier: Modifier = Modifier,
shape: Shape = MaterialTheme.shapes.small,
imageWidth: Dp = 120.dp,
onClick: () -> Unit = {},
) {
Card(
modifier = modifier
.width(imageWidth)
.clickable { onClick() },
shape = RectangleShape,
shape = shape,
elevation = CardDefaults.cardElevation(
defaultElevation = 4.dp,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.dp
Expand All @@ -24,7 +23,7 @@ fun BasicDialog(
enableConfirmButton: Boolean = true,
enableDismissButton: Boolean = true,
dismissButtonText: String? = null,
shape: Shape = RectangleShape,
shape: Shape = MaterialTheme.shapes.small,
onDismissDialog: () -> Unit = {},
confirmButtonClicked: () -> Unit = {},
dismissButtonClicked: () -> Unit = {},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.thomaskioko.tvmaniac.compose.theme

import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp

val tvManiacShapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(8.dp),
large = RoundedCornerShape(16.dp),
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fun TvManiacTheme(
MaterialTheme(
colorScheme = colorScheme,
typography = tvManiacTypography,
shapes = tvManiacShapes,
content = content,
)
}
Expand Down
1 change: 1 addition & 0 deletions android-core/resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

<string name="title_settings">Settings</string>
<string name="title_all_seasons">All Seasons</string>
<string name="title_all_episodes">All Episodes</string>
<string name="title_watch_next">Watch Next</string>
<string name="status_connected">Back Online!</string>
<string name="status_no_connection">No Internet Connection!</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.thomaskioko.tvmaniac.discover
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import com.thomaskioko.tvmaniac.presentation.discover.DataLoaded
import com.thomaskioko.tvmaniac.presentation.discover.DiscoverState
import com.thomaskioko.tvmaniac.presentation.discover.ErrorState
import com.thomaskioko.tvmaniac.presentation.discover.model.TvShow
import kotlinx.collections.immutable.toImmutableList

Expand Down Expand Up @@ -39,7 +40,7 @@ class DiscoverPreviewParameterProvider : PreviewParameterProvider<DiscoverState>
get() {
return sequenceOf(
discoverContentSuccess,
DataLoaded(errorMessage = "Opps! Something went wrong"),
ErrorState(errorMessage = "Opps! Something went wrong"),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import androidx.compose.ui.util.lerp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.thomaskioko.tvmaniac.category.api.model.Category
import com.thomaskioko.tvmaniac.compose.components.BoxTextItems
import com.thomaskioko.tvmaniac.compose.components.EmptyUi
import com.thomaskioko.tvmaniac.compose.components.ErrorUi
import com.thomaskioko.tvmaniac.compose.components.LoadingIndicator
import com.thomaskioko.tvmaniac.compose.components.ThemePreviews
Expand All @@ -72,6 +71,7 @@ import com.thomaskioko.tvmaniac.compose.util.rememberDominantColorState
import com.thomaskioko.tvmaniac.navigation.extensions.viewModel
import com.thomaskioko.tvmaniac.presentation.discover.DataLoaded
import com.thomaskioko.tvmaniac.presentation.discover.DiscoverState
import com.thomaskioko.tvmaniac.presentation.discover.ErrorState
import com.thomaskioko.tvmaniac.presentation.discover.Loading
import com.thomaskioko.tvmaniac.presentation.discover.RetryLoading
import com.thomaskioko.tvmaniac.presentation.discover.SnackBarDismissed
Expand Down Expand Up @@ -140,49 +140,33 @@ private fun DiscoverScreen(
onMoreClicked: (showType: Long) -> Unit,
) {
when (state) {
Loading ->
LoadingIndicator(
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)

is DataLoaded ->
when {
state.isContentEmpty && state.errorMessage != null -> {
ErrorUi(
errorMessage = state.errorMessage,
onRetry = onRetry,
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)
}

state.isContentEmpty -> {
EmptyUi(
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)
}

else -> {
DiscoverScrollContent(
modifier = modifier,
pagerState = pagerState,
snackBarHostState = snackBarHostState,
onShowClicked = onShowClicked,
onMoreClicked = onMoreClicked,
onSnackBarErrorDismissed = onErrorDismissed,
trendingShows = state.trendingShows,
popularShows = state.popularShows,
anticipatedShows = state.anticipatedShows,
recommendedShows = state.recommendedShows,
errorMessage = state.errorMessage,
)
}
}
Loading -> LoadingIndicator(
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)

is DataLoaded -> DiscoverScrollContent(
modifier = modifier,
pagerState = pagerState,
snackBarHostState = snackBarHostState,
onShowClicked = onShowClicked,
onMoreClicked = onMoreClicked,
onSnackBarErrorDismissed = onErrorDismissed,
trendingShows = state.trendingShows,
popularShows = state.popularShows,
anticipatedShows = state.anticipatedShows,
recommendedShows = state.recommendedShows,
errorMessage = state.errorMessage,
)

is ErrorState -> ErrorUi(
errorMessage = state.errorMessage,
onRetry = onRetry,
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)
}
}

Expand Down Expand Up @@ -433,7 +417,7 @@ fun HorizontalPagerItem(
}
}

@OptIn(ExperimentalSnapperApi::class)
@OptIn(ExperimentalSnapperApi::class, ExperimentalFoundationApi::class)
@Composable
private fun RowContent(
category: Category,
Expand Down Expand Up @@ -465,6 +449,8 @@ private fun RowContent(
posterImageUrl = tvShow.posterImageUrl,
title = tvShow.title,
onClick = { onItemClicked(tvShow.traktId) },
modifier = Modifier
.animateItemPlacement(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -41,10 +44,14 @@ import com.thomaskioko.tvmaniac.presentation.seasondetails.Loading
import com.thomaskioko.tvmaniac.presentation.seasondetails.LoadingError
import com.thomaskioko.tvmaniac.presentation.seasondetails.SeasonDetailsLoaded
import com.thomaskioko.tvmaniac.presentation.seasondetails.SeasonDetailsState
import com.thomaskioko.tvmaniac.presentation.seasondetails.model.Episode
import com.thomaskioko.tvmaniac.presentation.seasondetails.model.SeasonDetails
import com.thomaskioko.tvmaniac.resources.R
import com.thomaskioko.tvmaniac.seasondetails.components.CollapsableContent
import com.thomaskioko.tvmaniac.seasondetails.components.WatchNextContent
import com.thomaskioko.tvmaniac.seasondetails.components.EpisodeItem
import dev.chrisbanes.snapper.ExperimentalSnapperApi
import dev.chrisbanes.snapper.rememberSnapperFlingBehavior
import kotlinx.collections.immutable.ImmutableList
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject

Expand Down Expand Up @@ -106,8 +113,7 @@ internal fun SeasonDetailScreen(
navigateUp = onBackClicked,
)
},
modifier = modifier
.statusBarsPadding(),
modifier = modifier.statusBarsPadding(),
content = { contentPadding ->
when (state) {
Loading -> LoadingIndicator(
Expand All @@ -116,14 +122,13 @@ internal fun SeasonDetailScreen(
.wrapContentSize(Alignment.Center),
)

is LoadingError ->
ErrorUi(
errorMessage = state.message,
onRetry = {},
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)
is LoadingError -> ErrorUi(
errorMessage = state.message,
onRetry = {},
modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center),
)

is SeasonDetailsLoaded -> {
SeasonContent(
Expand Down Expand Up @@ -155,7 +160,7 @@ private fun TopBar(

@Composable
private fun SeasonContent(
seasonsEpList: List<SeasonDetails>?,
seasonsEpList: ImmutableList<SeasonDetails>?,
initialSeasonName: String?,
listState: LazyListState,
contentPadding: PaddingValues,
Expand All @@ -179,15 +184,21 @@ private fun SeasonContent(
LazyColumn(
state = listState,
contentPadding = contentPadding.copy(copyTop = false),
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.padding(horizontal = 16.dp)
.fillMaxSize(),
) {
item { Spacer(modifier = Modifier.height(64.dp)) }

item { WatchNextContent(seasonsEpList.firstOrNull()?.episodes) }

item { Spacer(modifier = Modifier.height(16.dp)) }

item { AllSeasonsTitle() }
item {
LabelTitle(
label = stringResource(id = R.string.title_all_episodes),
)
}

itemsIndexed(seasonsEpList) { index, season ->
CollapsableContent(
Expand All @@ -204,20 +215,57 @@ private fun SeasonContent(
}
}

@OptIn(ExperimentalSnapperApi::class)
@Composable
fun WatchNextContent(
episodeList: ImmutableList<Episode>?,
modifier: Modifier = Modifier,
onEpisodeClicked: () -> Unit = {},
) {
episodeList?.let {
LabelTitle(
modifier = modifier
.padding(top = 16.dp, bottom = 8.dp),
label = stringResource(id = R.string.title_watch_next),
)

val lazyListState = rememberLazyListState()

LazyRow(
state = lazyListState,
flingBehavior = rememberSnapperFlingBehavior(lazyListState),
) {
itemsIndexed(episodeList) { index, episode ->
val value = if (index == 0) 0 else 8
Spacer(modifier = Modifier.width(value.dp))

EpisodeItem(
modifier = modifier.size(width = 320.dp, height = 90.dp),
imageUrl = episode.imageUrl,
title = episode.seasonEpisodeNumber,
episodeOverview = episode.overview,
onEpisodeClicked = onEpisodeClicked,
)
}

item { Spacer(modifier = Modifier.height(16.dp)) }
}
}
}

@Composable
private fun AllSeasonsTitle(
private fun LabelTitle(
label: String,
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier
.fillMaxWidth()
.padding(2.dp),
modifier = modifier.fillMaxWidth(),
contentAlignment = Alignment.Center,
) {
Spacer(modifier = Modifier.height(8.dp))

Text(
text = stringResource(id = R.string.title_all_seasons),
text = label,
style = MaterialTheme.typography.labelMedium.copy(MaterialTheme.colorScheme.secondary),
)
}
Expand All @@ -226,8 +274,7 @@ private fun AllSeasonsTitle(
@ThemePreviews
@Composable
private fun SeasonDetailScreenPreview(
@PreviewParameter(SeasonPreviewParameterProvider::class)
state: SeasonDetailsState,
@PreviewParameter(SeasonPreviewParameterProvider::class) state: SeasonDetailsState,
) {
TvManiacTheme {
Surface {
Expand Down
Loading
Loading