Skip to content

Commit

Permalink
Merge pull request #86 from VictorKabata/temp
Browse files Browse the repository at this point in the history
Temp -> Develop
  • Loading branch information
VictorKabata committed Jul 6, 2023
2 parents 02f21d5 + f605856 commit edd4fd0
Show file tree
Hide file tree
Showing 159 changed files with 2,454 additions and 760 deletions.
Binary file removed app-android/notflix.jks
Binary file not shown.
12 changes: 12 additions & 0 deletions app-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ dependencies {
implementation(project(":shared"))

implementation(compose.desktop.currentOs)

implementation(libs.voyager.core)
implementation(libs.voyager.navigator)
implementation(libs.voyager.tabNavigator)

implementation(libs.kamel)

testImplementation(kotlin("test"))
testImplementation(libs.turbine)
testImplementation(libs.ktor.mock)
testImplementation(libs.mockk)
testImplementation(libs.kotlinX.coroutines.test)
}

compose.desktop {
Expand Down
3 changes: 2 additions & 1 deletion app-desktop/src/main/kotlin/NotflixDesktop.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import androidx.compose.ui.window.application
import com.vickikbt.shared.di.initKoin
import di.desktopModule
import org.koin.core.Koin
import ui.screens.main.MainScreen

lateinit var koin: Koin

fun main() {
koin = initKoin(enableNetworkLogs = true).koin
koin = initKoin(enableNetworkLogs = true) { modules(desktopModule) }.koin

return application {
MainScreen(applicationScope = this)
Expand Down
16 changes: 16 additions & 0 deletions app-desktop/src/main/kotlin/di/DesktopModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package di

import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
import ui.screens.details.DetailsScreenModel
import ui.screens.favourites.FavouritesScreenModel
import ui.screens.home.HomeScreenModel
import ui.screens.settings.SettingsScreenModel

val desktopModule = module {

singleOf(::HomeScreenModel)
singleOf(::DetailsScreenModel)
singleOf(::FavouritesScreenModel)
singleOf(::SettingsScreenModel)
}
45 changes: 30 additions & 15 deletions app-desktop/src/main/kotlin/ui/components/ItemMovieCast.kt
Original file line number Diff line number Diff line change
@@ -1,41 +1,56 @@
package ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vickikbt.shared.domain.models.Actor
import io.kamel.image.KamelImage
import io.kamel.image.lazyPainterResource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import ui.theme.TextSecondary
import utils.AsyncImage
import utils.loadImage
import utils.loadImageBitmap

@Composable
fun ItemMovieCast(modifier: Modifier = Modifier, actor: Actor) {
val imageUrl = actor.profilePath?.loadImage()

Column(horizontalAlignment = Alignment.CenterHorizontally) {
AsyncImage(
modifier = Modifier.fillMaxSize(),
load = { loadImageBitmap(imageUrl) },
painterFor = { remember { BitmapPainter(it) } },
contentDescription = "Cast",
contentScale = ContentScale.Crop
)
val painterResource = lazyPainterResource(imageUrl ?: "") {
coroutineContext = Job() + Dispatchers.IO
}

Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Card(
modifier = Modifier.size(90.dp),
shape = CircleShape
) {
KamelImage(
modifier = Modifier.fillMaxSize(),
resource = painterResource,
contentDescription = "Cast",
contentScale = ContentScale.Crop
)
}

Text(
modifier = Modifier.width(78.dp),
modifier = Modifier.widthIn(max = 90.dp),
text = actor.name ?: "Unknown actor",
style = MaterialTheme.typography.h6,
fontSize = 14.sp,
Expand All @@ -46,7 +61,7 @@ fun ItemMovieCast(modifier: Modifier = Modifier, actor: Actor) {
)

Text(
modifier = Modifier.width(77.dp),
modifier = Modifier.widthIn(max = 90.dp),
text = actor.character ?: "Unknown character",
style = MaterialTheme.typography.h4,
fontSize = 12.sp,
Expand Down
34 changes: 16 additions & 18 deletions app-desktop/src/main/kotlin/ui/components/ItemNowPlaying.kt
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
package ui.components

import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.onPointerEvent
import androidx.compose.ui.layout.ContentScale
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 androidx.compose.ui.unit.sp
import com.vickikbt.shared.domain.models.Movie
import utils.AsyncImage
import io.kamel.image.KamelImage
import io.kamel.image.lazyPainterResource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import utils.loadImage
import utils.loadImageBitmap

@OptIn(ExperimentalComposeUiApi::class)
@Composable
Expand All @@ -41,24 +35,28 @@ fun ItemNowPlayingMovies(

val boxWidth by animateDpAsState(targetValue = if (isHovered) 400.dp else 200.dp)

val imageUrl = (if (isHovered) movie.backdropPath else movie.posterPath)?.loadImage()
val imageUrl = movie.posterPath?.loadImage()

val painterResource = lazyPainterResource(imageUrl ?: "") {
coroutineContext = Job() + Dispatchers.IO
}

Box(
modifier = modifier.width(boxWidth)
.clickable { onItemClick(movie) }
.onPointerEvent(PointerEventType.Enter) { isHovered = true }
.onPointerEvent(PointerEventType.Exit) { isHovered = false },
) {
AsyncImage(
KamelImage(
modifier = Modifier.fillMaxSize(),
load = { loadImageBitmap(imageUrl) },
painterFor = { remember { BitmapPainter(it) } },
resource = painterResource,
contentDescription = "Movie Backdrop Poster",
contentScale = ContentScale.Crop
contentScale = ContentScale.Crop,
animationSpec = tween()
)

//region Movie Title
if (isHovered) {
/*if (isHovered) {
Text(
modifier = Modifier.padding(horizontal = 8.dp, vertical = 16.dp)
.align(Alignment.BottomStart),
Expand All @@ -70,7 +68,7 @@ fun ItemNowPlayingMovies(
textAlign = TextAlign.Start,
color = MaterialTheme.colors.onSurface
)
}
}*/
//endregion
}
}
27 changes: 13 additions & 14 deletions app-desktop/src/main/kotlin/ui/components/ItemPopularMovies.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ui.components

import androidx.compose.animation.core.tween
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -17,17 +18,18 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
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 androidx.compose.ui.unit.sp
import com.vickikbt.shared.domain.models.Movie
import utils.AsyncImage
import io.kamel.image.KamelImage
import io.kamel.image.lazyPainterResource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import utils.loadImage
import utils.loadImageBitmap

@Composable
fun ItemPopularMovies(
Expand All @@ -43,29 +45,26 @@ fun ItemPopularMovies(

val imageUrl = movie.backdropPath?.loadImage()

// var cardAspectRatio by remember { mutableStateOf(1F) }
val painterResource = lazyPainterResource(imageUrl ?: "") {
coroutineContext = Job() + Dispatchers.IO
}

Card(
modifier = modifier
.width(480.dp)
.height(320.dp)
.clickable { onClickItem(movie) }
/*.onPointerEvent(PointerEventType.Enter) {
cardAspectRatio = 1.5f
}.onPointerEvent(PointerEventType.Exit) {
cardAspectRatio = 1f
}*/,
.clickable { onClickItem(movie) },
elevation = 8.dp,
shape = RoundedCornerShape(4.dp)
) {
Box(modifier = Modifier.fillMaxSize()) {
//region Movie Cover
AsyncImage(
KamelImage(
modifier = Modifier.fillMaxSize(),
load = { loadImageBitmap(imageUrl) },
painterFor = { remember { BitmapPainter(it) } },
resource = painterResource,
contentDescription = "Movie backdrop poster",
contentScale = ContentScale.Crop
contentScale = ContentScale.Crop,
animationSpec = tween()
)
//endregion

Expand Down
17 changes: 10 additions & 7 deletions app-desktop/src/main/kotlin/ui/components/ItemSimilarMovies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,37 @@ import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vickikbt.shared.domain.models.Movie
import utils.AsyncImage
import io.kamel.image.KamelImage
import io.kamel.image.lazyPainterResource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import utils.loadImage
import utils.loadImageBitmap

@Composable
fun ItemSimilarMovies(movie: Movie) {
val imageUrl = movie.posterPath?.loadImage()

val painterResource = lazyPainterResource(imageUrl ?: "") {
coroutineContext = Job() + Dispatchers.IO
}

Column {
Card(
modifier = Modifier
.width(150.dp)
.height(220.dp),
shape = RoundedCornerShape(4.dp)
) {
AsyncImage(
KamelImage(
modifier = Modifier.fillMaxSize(),
load = { loadImageBitmap(imageUrl) },
painterFor = { remember { BitmapPainter(it) } },
resource = painterResource,
contentDescription = "Movie poster",
contentScale = ContentScale.Crop
)
Expand Down
21 changes: 13 additions & 8 deletions app-desktop/src/main/kotlin/ui/components/ItemTrendingMovies.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ui.components

import androidx.compose.animation.core.tween
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -12,19 +13,19 @@ import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
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 androidx.compose.ui.unit.sp
import com.vickikbt.shared.domain.models.Movie
import utils.AsyncImage
import io.kamel.image.KamelImage
import io.kamel.image.lazyPainterResource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import utils.loadImage
import utils.loadImageBitmap

@Composable
fun ItemTrendingMovies(
Expand All @@ -34,6 +35,10 @@ fun ItemTrendingMovies(
) {
val imageUrl = movie.posterPath?.loadImage()

val painterResource = lazyPainterResource(imageUrl ?: "") {
coroutineContext = Job() + Dispatchers.IO
}

Column {
Card(
modifier = modifier
Expand All @@ -43,12 +48,12 @@ fun ItemTrendingMovies(
elevation = 8.dp,
shape = RoundedCornerShape(4.dp)
) {
AsyncImage(
KamelImage(
modifier = Modifier.fillMaxSize(),
load = { loadImageBitmap(imageUrl) },
painterFor = { remember { BitmapPainter(it) } },
resource = painterResource,
contentDescription = "Movie poster",
contentScale = ContentScale.Crop
contentScale = ContentScale.Crop,
animationSpec = tween()
)
}

Expand Down
Loading

0 comments on commit edd4fd0

Please sign in to comment.