Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Update to Compose SNAPSHOT 6854728 #697

Merged
merged 3 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 18 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ subprojects {
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
// Create a configuration which allows us to intercept the JARs, and add them to
// Kotlin Compiler freeCompilerArgs. This is needed because we can't currently use the
// built-in `compose` feature in AGP, since it depends on the old Compose Compiler artifacts.
// TODO: Remove this once AGP uses the new Compose Compiler artifact name
def compilerPluginConfig = project.configurations.create("kotlinCompilerPlugin")

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { compile ->
kotlinOptions {
// Treat all Kotlin warnings as errors
allWarningsAsErrors = true
Expand All @@ -128,6 +134,17 @@ subprojects {
// Set JVM target to 1.8
jvmTarget = "1.8"
}

compile.dependsOn(compilerPluginConfig)
compile.doFirst {
if (!compilerPluginConfig.isEmpty()) {
// Add the compiler plugin JARs using the -Xplugin flag
compile.kotlinOptions.freeCompilerArgs +=
"-Xplugin=${compilerPluginConfig.files.first()}"
// Need to turn on the IR compiler too
compile.kotlinOptions.useIR = true
}
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Versions {
}

object Libs {
const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha10"
const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha11"

const val gradlePlayPublisher = "com.github.triplet.gradle:play-publisher:3.0.0"

Expand Down Expand Up @@ -59,7 +59,7 @@ object Libs {
}

object Accompanist {
private const val version = "0.2.2.ui-6824694-SNAPSHOT"
private const val version = "0.2.3.compose-6854728-SNAPSHOT"
const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version"
}

Expand Down Expand Up @@ -164,13 +164,15 @@ object Libs {
}

object Compose {
const val snapshot = "6824694"
const val snapshot = "6854728"
const val version = "1.0.0-SNAPSHOT"

@get:JvmStatic
val snapshotUrl: String
get() = "https://androidx.dev/snapshots/builds/$snapshot/artifacts/ui/repository/"

const val compiler = "androidx.compose.compiler:compiler:$version"

const val runtime = "androidx.compose.runtime:runtime:$version"
const val livedata = "androidx.compose.runtime:runtime-livedata:$version"

Expand Down
11 changes: 10 additions & 1 deletion common-ui-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ android {
}

buildFeatures {
compose true
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
// Compose compiler artifact has changed artifact group/name.
// Instead we add the compiler manually below in the dependencies {}. Also see
// the root build.gradle for info on how to apply the plugin.
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details

// compose true
}

composeOptions {
Expand All @@ -51,6 +57,9 @@ dependencies {
implementation Libs.AndroidX.coreKtx
implementation Libs.AndroidX.Lifecycle.livedata

// Temporary workaround (see above)
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler

implementation Libs.AndroidX.Compose.runtime
implementation Libs.AndroidX.Compose.foundation
implementation Libs.AndroidX.Compose.ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ package app.tivi.common.compose

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.Box
import androidx.compose.foundation.ContentGravity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
Expand All @@ -29,6 +28,7 @@ import androidx.compose.material.FloatingActionButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
Expand Down Expand Up @@ -56,7 +56,7 @@ fun ExpandableFloatingActionButton(
shape = shape,
modifier = modifier
) {
Row(verticalAlignment = ContentGravity.CenterVertically) {
Row(verticalAlignment = Alignment.CenterVertically) {
AnimatedVisibility(visible = expanded) {
Spacer(Modifier.preferredWidth(20.dp))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package app.tivi.common.compose

import androidx.compose.foundation.Text
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Card
import androidx.compose.material.EmphasisAmbient
Expand All @@ -30,7 +30,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import app.tivi.data.entities.TiviShow
import app.tivi.data.entities.TmdbImageEntity
import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade
import dev.chrisbanes.accompanist.coil.CoilImage

@Composable
fun PosterCard(
Expand All @@ -40,7 +40,7 @@ fun PosterCard(
modifier: Modifier = Modifier
) {
Card(modifier = modifier) {
Stack(
Box(
modifier = if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier
) {
// TODO: remove text if the image has loaded (and animated in).
Expand All @@ -53,8 +53,9 @@ fun PosterCard(
)
}
if (poster != null) {
CoilImageWithCrossfade(
CoilImage(
data = poster,
fadeIn = true,
modifier = Modifier.matchParentSize()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package app.tivi.common.compose

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Box
import androidx.compose.foundation.contentColor
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down
13 changes: 10 additions & 3 deletions ui-account/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ android {
}

buildFeatures {
compose true
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
// Compose compiler artifact has changed artifact group/name.
// Instead we add the compiler manually below in the dependencies {}. Also see
// the root build.gradle for info on how to apply the plugin.
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details

// compose true
}

composeOptions {
Expand All @@ -56,10 +62,8 @@ dependencies {
implementation project(':domain')
implementation project(':common-ui-view')
implementation project(':common-ui-compose')

implementation project(':trakt-auth')


implementation Libs.AndroidX.Lifecycle.livedata
implementation Libs.AndroidX.Lifecycle.viewmodel

Expand All @@ -68,6 +72,9 @@ dependencies {
implementation Libs.AndroidX.Fragment.fragmentKtx
implementation Libs.AndroidX.Navigation.fragment

// Temporary workaround (see above)
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler

implementation Libs.AndroidX.Compose.runtime
implementation Libs.AndroidX.Compose.foundation
implementation Libs.AndroidX.Compose.ui
Expand Down
5 changes: 3 additions & 2 deletions ui-account/src/main/java/app/tivi/account/AccountUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import androidx.ui.tooling.preview.Preview
import app.tivi.common.compose.VectorImage
import app.tivi.data.entities.TraktUser
import app.tivi.trakt.TraktAuthState
import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade
import dev.chrisbanes.accompanist.coil.CoilImage
import org.threeten.bp.OffsetDateTime
import org.threeten.bp.ZoneOffset

Expand Down Expand Up @@ -116,8 +116,9 @@ private fun UserRow(
) {
val avatarUrl = user.avatarUrl
if (avatarUrl != null) {
CoilImageWithCrossfade(
CoilImage(
data = avatarUrl,
fadeIn = true,
modifier = Modifier.preferredSize(40.dp)
.clip(RoundedCornerShape(50))
)
Expand Down
11 changes: 10 additions & 1 deletion ui-discover/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ android {
}

buildFeatures {
compose true
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
// Compose compiler artifact has changed artifact group/name.
// Instead we add the compiler manually below in the dependencies {}. Also see
// the root build.gradle for info on how to apply the plugin.
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details

// compose true
}

composeOptions {
Expand All @@ -67,6 +73,9 @@ dependencies {
implementation Libs.AndroidX.Fragment.fragmentKtx
implementation Libs.AndroidX.Navigation.fragment

// Temporary workaround (see above)
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler

implementation Libs.AndroidX.Compose.runtime
implementation Libs.AndroidX.Compose.foundation
implementation Libs.AndroidX.Compose.ui
Expand Down
11 changes: 5 additions & 6 deletions ui-discover/src/main/java/app/tivi/home/discover/Discover.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.Icon
import androidx.compose.foundation.Text
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope.align
import androidx.compose.foundation.layout.RowScope.alignWithSiblings
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -80,7 +79,7 @@ fun Discover(
actioner: (DiscoverAction) -> Unit
) {
Surface(Modifier.fillMaxSize()) {
Stack(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize()) {
var appBarHeight by rememberMutableState { 0 }

LazyColumn(Modifier.fillMaxSize()) {
Expand Down Expand Up @@ -273,7 +272,7 @@ private fun Header(
title: String,
modifier: Modifier = Modifier,
loading: Boolean = false,
action: (@Composable () -> Unit)? = null
action: @Composable RowScope.() -> Unit = {}
) {
Row(modifier) {
Spacer(Modifier.preferredWidth(16.dp))
Expand All @@ -296,7 +295,7 @@ private fun Header(
)
}

if (action != null) action()
action()

Spacer(Modifier.preferredWidth(16.dp))
}
Expand Down
11 changes: 10 additions & 1 deletion ui-episodedetails/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ android {
}

buildFeatures {
compose true
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
// Compose compiler artifact has changed artifact group/name.
// Instead we add the compiler manually below in the dependencies {}. Also see
// the root build.gradle for info on how to apply the plugin.
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details

// compose true
}

composeOptions {
Expand All @@ -73,6 +79,9 @@ dependencies {
implementation Libs.AndroidX.Fragment.fragment
implementation Libs.AndroidX.Fragment.fragmentKtx

// Temporary workaround (see above)
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler

implementation Libs.AndroidX.Compose.runtime
implementation Libs.AndroidX.Compose.foundation
implementation Libs.AndroidX.Compose.ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import androidx.compose.foundation.ScrollableColumn
import androidx.compose.foundation.Text
import androidx.compose.foundation.background
import androidx.compose.foundation.contentColor
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -100,7 +100,7 @@ import app.tivi.data.entities.EpisodeWatchEntry
import app.tivi.data.entities.PendingAction
import app.tivi.data.entities.Season
import app.tivi.ui.animations.lerp
import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade
import dev.chrisbanes.accompanist.coil.CoilImage
import kotlinx.coroutines.launch
import org.threeten.bp.OffsetDateTime
import kotlin.math.absoluteValue
Expand All @@ -112,9 +112,9 @@ fun EpisodeDetails(
viewState: EpisodeDetailsViewState,
actioner: (EpisodeDetailsAction) -> Unit
) {
Stack {
Box {
Column {
Stack {
Box {
if (viewState.episode != null && viewState.season != null) {
Backdrop(
season = viewState.season,
Expand Down Expand Up @@ -246,10 +246,11 @@ private fun Backdrop(
modifier: Modifier
) {
Surface(modifier = modifier) {
Stack(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize()) {
if (episode.tmdbBackdropPath != null) {
CoilImageWithCrossfade(
CoilImage(
data = episode,
fadeIn = true,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize()
)
Expand Down Expand Up @@ -449,7 +450,7 @@ private fun EpisodeWatchSwipeBackground(
toState = wouldCompleteOnRelease
)

Stack(
Box(
Modifier.fillMaxSize()
.background(MaterialTheme.colors.onSurface.copy(alpha = 0.2f), RectangleShape)
) {
Expand Down
11 changes: 10 additions & 1 deletion ui-showdetails/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ android {
}

buildFeatures {
compose true
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
// Compose compiler artifact has changed artifact group/name.
// Instead we add the compiler manually below in the dependencies {}. Also see
// the root build.gradle for info on how to apply the plugin.
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details

// compose true
}

composeOptions {
Expand Down Expand Up @@ -78,6 +84,9 @@ dependencies {

implementation Libs.Insetter.ktx

// Temporary workaround (see above)
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler

implementation Libs.AndroidX.Compose.runtime
implementation Libs.AndroidX.Compose.foundation
implementation Libs.AndroidX.Compose.ui
Expand Down
Loading