-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3224bd
commit cf43d35
Showing
32 changed files
with
481 additions
and
66 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...gation/src/commonMain/kotlin/org/michaelbel/movies/navigation/ktx/NavHostControllerKtx.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@file:OptIn(ExperimentalKotlinGradlePluginApi::class, ExperimentalWasmDsl::class) | ||
|
||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl | ||
|
||
plugins { | ||
alias(libs.plugins.kotlin.multiplatform) | ||
alias(libs.plugins.kotlin.compose) | ||
alias(libs.plugins.compose) | ||
} | ||
|
||
kotlin { | ||
js { | ||
browser {} | ||
} | ||
wasmJs() | ||
|
||
sourceSets { | ||
commonMain.dependencies { | ||
api(project(":core:ui-web")) | ||
api(project(":core:platform-services:interactor")) | ||
} | ||
} | ||
|
||
compilerOptions { | ||
jvmToolchain(libs.versions.jdk.get().toInt()) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
feature/feed-impl-web/src/commonMain/kotlin/org/michaelbel/movies/feed/di/FeedKoinModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.michaelbel.movies.feed.di | ||
|
||
import org.koin.core.module.Module | ||
|
||
expect val feedKoinModule: Module |
14 changes: 14 additions & 0 deletions
14
feature/feed-impl-web/src/commonMain/kotlin/org/michaelbel/movies/feed/ktx/MovieListKtx.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.michaelbel.movies.feed.ktx | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.jetbrains.compose.resources.stringResource | ||
import org.michaelbel.movies.common.list.MovieList | ||
import org.michaelbel.movies.ui.strings.MoviesStrings | ||
|
||
internal val MovieList.titleText: String | ||
@Composable get() = when (this) { | ||
is MovieList.NowPlaying -> stringResource(MoviesStrings.feed_title_now_playing) | ||
is MovieList.Popular -> stringResource(MoviesStrings.feed_title_popular) | ||
is MovieList.TopRated -> stringResource(MoviesStrings.feed_title_top_rated) | ||
is MovieList.Upcoming -> stringResource(MoviesStrings.feed_title_upcoming) | ||
} |
60 changes: 60 additions & 0 deletions
60
feature/feed-impl-web/src/commonMain/kotlin/org/michaelbel/movies/feed/ui/FeedEmpty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.michaelbel.movies.feed.ui | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.compose.resources.stringResource | ||
import org.jetbrains.compose.ui.tooling.preview.Preview | ||
import org.michaelbel.movies.ui.accessibility.MoviesContentDescriptionCommon | ||
import org.michaelbel.movies.ui.icons.MoviesIcons | ||
import org.michaelbel.movies.ui.strings.MoviesStrings | ||
import org.michaelbel.movies.ui.theme.MoviesTheme | ||
|
||
@Composable | ||
internal fun FeedEmpty( | ||
modifier: Modifier = Modifier | ||
) { | ||
Column( | ||
modifier = modifier.fillMaxWidth(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Icon( | ||
imageVector = MoviesIcons.LocalMovies, | ||
contentDescription = MoviesContentDescriptionCommon.None, | ||
modifier = Modifier.size(36.dp), | ||
tint = MaterialTheme.colorScheme.error | ||
) | ||
|
||
Text( | ||
text = stringResource(MoviesStrings.feed_error_empty), | ||
modifier = Modifier.padding(start = 16.dp, top = 8.dp, end = 16.dp), | ||
textAlign = TextAlign.Center, | ||
style = MaterialTheme.typography.bodyMedium.copy(MaterialTheme.colorScheme.onPrimaryContainer) | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun FeedEmptyPreview() { | ||
MoviesTheme { | ||
FeedEmpty( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(MaterialTheme.colorScheme.primaryContainer) | ||
) | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
feature/feed-impl-web/src/commonMain/kotlin/org/michaelbel/movies/feed/ui/FeedToolbar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
@file:OptIn(ExperimentalMaterial3Api::class) | ||
|
||
package org.michaelbel.movies.feed.ui | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.statusBarsPadding | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.TopAppBarScrollBehavior | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
import org.jetbrains.compose.ui.tooling.preview.Preview | ||
import org.michaelbel.movies.ui.compose.ApiKeyBox | ||
import org.michaelbel.movies.ui.compose.iconbutton.SearchIcon | ||
import org.michaelbel.movies.ui.compose.iconbutton.SettingsIcon | ||
import org.michaelbel.movies.ui.ktx.modifierDisplayCutoutWindowInsets | ||
import org.michaelbel.movies.ui.theme.MoviesTheme | ||
|
||
@Composable | ||
internal fun FeedToolbar( | ||
title: String, | ||
isTmdbApiKeyEmpty: Boolean, | ||
isSearchIconVisible: Boolean, | ||
onSearchIconClick: () -> Unit, | ||
isAuthIconVisible: Boolean, | ||
onAuthIconClick: () -> Unit, | ||
onAccountIconClick: () -> Unit, | ||
onSettingsIconClick: () -> Unit, | ||
topAppBarScrollBehavior: TopAppBarScrollBehavior, | ||
modifier: Modifier = Modifier | ||
) { | ||
Column( | ||
modifier = Modifier.background(MaterialTheme.colorScheme.primaryContainer), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
TopAppBar( | ||
title = { | ||
Text( | ||
text = title, | ||
overflow = TextOverflow.Ellipsis, | ||
style = MaterialTheme.typography.titleLarge.copy(MaterialTheme.colorScheme.onPrimaryContainer) | ||
) | ||
}, | ||
modifier = modifier, | ||
navigationIcon = if (isSearchIconVisible) { | ||
{ | ||
SearchIcon( | ||
onClick = onSearchIconClick, | ||
modifier = Modifier.then(modifierDisplayCutoutWindowInsets) | ||
) | ||
} | ||
} else { | ||
{} | ||
}, | ||
actions = { | ||
Row( | ||
modifier = Modifier.then(modifierDisplayCutoutWindowInsets) | ||
) { | ||
SettingsIcon( | ||
onClick = onSettingsIconClick | ||
) | ||
} | ||
}, | ||
colors = TopAppBarDefaults.topAppBarColors( | ||
containerColor = MaterialTheme.colorScheme.primaryContainer, | ||
scrolledContainerColor = MaterialTheme.colorScheme.inversePrimary | ||
), | ||
scrollBehavior = topAppBarScrollBehavior | ||
) | ||
|
||
if (isTmdbApiKeyEmpty) { | ||
ApiKeyBox( | ||
modifier = Modifier.fillMaxWidth().padding(vertical = 16.dp) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun FeedToolbarPreview() { | ||
MoviesTheme { | ||
FeedToolbar( | ||
title = "Not Playing", | ||
isTmdbApiKeyEmpty = true, | ||
isSearchIconVisible = true, | ||
onSearchIconClick = {}, | ||
onAccountIconClick = {}, | ||
isAuthIconVisible = true, | ||
onAuthIconClick = {}, | ||
onSettingsIconClick = {}, | ||
topAppBarScrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(), | ||
modifier = Modifier.statusBarsPadding() | ||
) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
feature/feed-impl-web/src/jsMain/kotlin/org/michaelbel/movies/feed/FeedViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@file:OptIn(ExperimentalCoroutinesApi::class) | ||
|
||
package org.michaelbel.movies.feed | ||
|
||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.flow.SharingStarted | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.flowOf | ||
import kotlinx.coroutines.flow.stateIn | ||
import org.michaelbel.movies.common.appearance.FeedView | ||
import org.michaelbel.movies.common.list.MovieList | ||
import org.michaelbel.movies.common.viewmodel.BaseViewModel | ||
|
||
class FeedViewModel: BaseViewModel() { | ||
|
||
val currentFeedView: StateFlow<FeedView> = flowOf(FeedView.FeedList) | ||
.stateIn( | ||
scope = viewModelScope, | ||
started = SharingStarted.Lazily, | ||
initialValue = FeedView.FeedList | ||
) | ||
|
||
val currentMovieList: StateFlow<MovieList> = flowOf(MovieList.NowPlaying()) | ||
.stateIn( | ||
scope = viewModelScope, | ||
started = SharingStarted.Lazily, | ||
initialValue = MovieList.NowPlaying() | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
feature/feed-impl-web/src/jsMain/kotlin/org/michaelbel/movies/feed/di/FeedKoinModule.js.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.michaelbel.movies.feed.di | ||
|
||
import org.koin.dsl.module | ||
import org.michaelbel.movies.feed.FeedViewModel | ||
|
||
actual val feedKoinModule = module { | ||
single { FeedViewModel() } | ||
} |
Oops, something went wrong.