Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Nov 22, 2024
1 parent a3224bd commit cf43d35
Show file tree
Hide file tree
Showing 32 changed files with 481 additions and 66 deletions.
39 changes: 0 additions & 39 deletions core/navigation/build.gradle.kts

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions core/ui-web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ kotlin {
commonMain.dependencies {
api(project(":core:common"))
api(libs.bundles.coil.common)
api(libs.bundles.jetbrains.androidx.navigation.compose.common)
api(libs.bundles.jetbrains.androidx.core.bundle.common)
api(compose.animation)
api(compose.foundation)
api(compose.runtime)
Expand Down
3 changes: 3 additions & 0 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ kotlin {
commonMain.dependencies {
api(project(":core:persistence"))
api(libs.bundles.coil.common)
api(libs.bundles.jetbrains.androidx.navigation.compose.common)
api(libs.bundles.jetbrains.androidx.core.bundle.common)
api(compose.animation)
api(compose.foundation)
api(compose.runtime)
Expand All @@ -44,6 +46,7 @@ kotlin {
api(compose.desktop.common)
api(compose.desktop.currentOs)
api(libs.bundles.compose.desktop)
api(libs.bundles.jetbrains.androidx.lifecycle.viewmodel.compose.common)
}
}

Expand Down
1 change: 0 additions & 1 deletion feature/account-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(project(":core:navigation"))
api(project(":core:ui"))
api(project(":core:common"))
api(project(":core:interactor"))
Expand Down
1 change: 0 additions & 1 deletion feature/auth-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(project(":core:navigation"))
api(project(":core:ui"))
api(project(":core:common"))
api(project(":core:interactor"))
Expand Down
1 change: 0 additions & 1 deletion feature/debug-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ kotlin {
api(project(":core:ui"))
implementation(project(":core:platform-services:interactor"))
implementation(project(":core:interactor"))
implementation(project(":core:navigation"))
}
}

Expand Down
1 change: 0 additions & 1 deletion feature/details-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kotlin {

sourceSets {
commonMain.dependencies {
api(project(":core:navigation"))
api(project(":core:ui"))
api(project(":core:interactor"))
}
Expand Down
28 changes: 28 additions & 0 deletions feature/feed-impl-web/build.gradle.kts
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())
}
}
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
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)
}
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)
)
}
}
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()
)
}
}
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()
)
}
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() }
}
Loading

0 comments on commit cf43d35

Please sign in to comment.