Skip to content

Commit

Permalink
[Quick View] Merging compose-latest to main (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
JolandaVerhoef authored Oct 24, 2022
2 parents e0c2383 + 7659a1d commit 355a4a6
Show file tree
Hide file tree
Showing 38 changed files with 457 additions and 449 deletions.
4 changes: 4 additions & 0 deletions Crane/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ android {
}

dependencies {
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.android)

Expand Down
3 changes: 3 additions & 0 deletions Crane/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ android {
}

dependencies {
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)

implementation(libs.androidx.test.ext.junit)
implementation(libs.androidx.test.espresso.core)
implementation(libs.androidx.test.uiautomator)
Expand Down
71 changes: 34 additions & 37 deletions Crane/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
# Do not add a dependency to an individual sample, edit the global version instead.
#####
[versions]
accompanist = "0.25.1"
androidGradlePlugin = "7.3.0"
androidx-activity-compose = "1.5.1"
androidx-appcompat = "1.5.0"
accompanist = "0.26.5-rc"
androidGradlePlugin = "7.3.1"
androidx-activity-compose = "1.6.0"
androidx-appcompat = "1.5.1"
androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-compose-bom = "2022.10.00"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-corektx = "1.9.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-lifecycle-runtime-compose = "2.6.0-alpha03"
androidx-navigation = "2.5.2"
androidx-palette = "1.0.0"
androidx-test = "1.3.0"
androidx-test-espresso = "3.3.0"
androidx-test = "1.4.0"
androidx-test-espresso = "3.5.0-alpha06" # Alpha for Compose bugfix and to match upstream, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:gradle/libs.versions.toml;l=30
androidx-test-ext-junit = "1.1.3"
androidx-test-ext-truth = "1.4.0"
androidx-window = "1.1.0-alpha03"
Expand All @@ -25,12 +26,7 @@ androix-test-uiautomator = "2.2.0"
coil = "2.2.0"
# @keep
compileSdk = "33"
compose = "1.2.1"
compose-compiler = "1.3.0"
# @pin to be updated manually - check JetChat tests
compose-material3 = "1.0.0-alpha15"
# @pin to be updated manually - check JetChat tests
compose-materialWindow = "1.0.0-alpha15"
compose-compiler = "1.3.2"
compose-snapshot = "-"
coroutines = "1.6.4"
google-maps = "18.1.0"
Expand All @@ -39,14 +35,14 @@ hiltExt = "1.0.0"
# @pin When updating to AGP 7.3.0-beta03 and up we can update this https://developer.android.com/studio/write/java8-support#library-desugaring-versions
jdkDesugar = "1.1.5"
junit = "4.13.2"
kotlin = "1.7.10"
kotlin = "1.7.20"
maps-compose = "2.5.3"
material = "1.7.0-beta01"
material = "1.8.0-alpha01"
# @keep
minSdk = "21"
okhttp = "4.10.0"
# @pin Bump to latest after Espresso 3.5.0 goes stable (due to https://github.com/robolectric/robolectric/issues/6593)
roboelectric = "4.5.1"
robolectric = "4.5.1"
rome = "1.18.0"
room = "2.5.0-alpha02"
secrets = "2.0.1"
Expand All @@ -65,24 +61,25 @@ androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-benchmark-macrobenchmark = { module = "androidx.benchmark:benchmark-macro", version.ref = "androidx-benchmark" }
androidx-benchmark-macrobenchmark-junit4 = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark-junit4" }
androidx-compose-animation = { module = "androidx.compose.animation:animation", version.ref = "compose" }
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout", version.ref = "compose" }
androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" }
androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "compose-materialWindow" }
androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" }
androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" }
androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "compose" }
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version.ref = "compose" }
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" }
androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding", version.ref = "compose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" }
androidx-compose-animation = { module = "androidx.compose.animation:animation" }
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" }
androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" }
androidx-compose-material = { module = "androidx.compose.material:material" }
androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" }
androidx-compose-material3 = { module = "androidx.compose.material3:material3" }
androidx-compose-materialWindow = { module = "androidx.compose.material3:material3-window-size-class" }
androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" }
androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
androidx-compose-ui-googlefonts = { module = "androidx.compose.ui:ui-text-google-fonts" }
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" }
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" }
androidx-compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" }
androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version.ref = "androidx-constraintlayout" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-corektx" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" }
Expand Down Expand Up @@ -124,7 +121,7 @@ kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutine
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "roboelectric" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
rometools-modules = { module = "com.rometools:rome-modules", version.ref = "rome" }
rometools-rome = { module = "com.rometools:rome", version.ref = "rome" }
secrets-gradlePlugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets" }
46 changes: 18 additions & 28 deletions JetNews/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,25 @@ android {
}

dependencies {
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.android)

// TODO: Replace when all samples use the same Material3 & Compose version
implementation("androidx.compose.animation:animation:1.3.0-beta03")
implementation("androidx.compose.foundation:foundation-layout:1.3.0-beta03")
implementation("androidx.compose.material:material-icons-extended:1.3.0-beta03")
implementation("androidx.compose.material3:material3:1.0.0-beta03")
implementation("androidx.compose.material3:material3-window-size-class:1.0.0-beta03")
implementation("androidx.compose.runtime:runtime-livedata:1.3.0-beta03")
implementation("androidx.compose.ui:ui-tooling-preview:1.3.0-beta03")
debugImplementation("androidx.compose.ui:ui-test-manifest:1.3.0-beta03")
debugImplementation("androidx.compose.ui:ui-tooling:1.3.0-beta03")
// implementation(libs.androidx.compose.animation)
// implementation(libs.androidx.compose.foundation.layout)
// implementation(libs.androidx.compose.material.iconsExtended)
// implementation(libs.androidx.compose.material3)
// implementation(libs.androidx.compose.materialWindow)
// implementation(libs.androidx.compose.runtime.livedata)
// implementation(libs.androidx.compose.ui.tooling.preview)
// debugImplementation(libs.androidx.compose.ui.test.manifest)
// debugImplementation(libs.androidx.compose.ui.tooling)

implementation("com.google.accompanist:accompanist-swiperefresh:0.26.4-beta")
implementation("com.google.accompanist:accompanist-systemuicontroller:0.26.4-beta")
// implementation(libs.accompanist.swiperefresh)
// implementation(libs.accompanist.systemuicontroller)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.materialWindow)
implementation(libs.androidx.compose.runtime.livedata)
implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.test.manifest)
debugImplementation(libs.androidx.compose.ui.tooling)

implementation(libs.accompanist.swiperefresh)
implementation(libs.accompanist.systemuicontroller)

implementation(libs.androidx.appcompat)
implementation(libs.androidx.activity.ktx)
Expand All @@ -131,7 +123,7 @@ dependencies {
implementation(libs.androidx.lifecycle.viewmodel.savedstate)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewModelCompose)

implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.window)

Expand All @@ -147,9 +139,7 @@ dependencies {
androidTestImplementation(libs.androidx.compose.ui.test)
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
// Robolectric dependencies
// TODO: Replace when all samples use the same Material3 & Compose version
implementation("androidx.compose.ui:ui-test-junit4:1.3.0-beta03")
// testImplementation(libs.androidx.compose.ui.test.junit4)
testImplementation(libs.androidx.compose.ui.test.junit4)
testImplementation(libs.robolectric)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.jetnews.ui.article.ArticleScreen
import com.example.jetnews.ui.home.HomeScreenType.ArticleDetails
import com.example.jetnews.ui.home.HomeScreenType.Feed
Expand All @@ -40,6 +41,7 @@ import com.example.jetnews.ui.home.HomeScreenType.FeedWithArticleDetails
* @param openDrawer (event) request opening the app drawer
* @param snackbarHostState (state) state for the [Scaffold] component on this screen
*/
@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun HomeRoute(
homeViewModel: HomeViewModel,
Expand All @@ -48,7 +50,7 @@ fun HomeRoute(
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }
) {
// UiState of the HomeScreen
val uiState by homeViewModel.uiState.collectAsState()
val uiState by homeViewModel.uiState.collectAsStateWithLifecycle()

HomeRoute(
uiState = uiState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
Expand All @@ -69,6 +68,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.constrainHeight
import androidx.compose.ui.unit.constrainWidth
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.jetnews.R
import com.example.jetnews.data.Result
import com.example.jetnews.data.interests.InterestSection
Expand Down Expand Up @@ -166,15 +167,16 @@ fun InterestsScreen(
* Remembers the content for each tab on the Interests screen
* gathering application data from [InterestsViewModel]
*/
@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun rememberTabContent(interestsViewModel: InterestsViewModel): List<TabContent> {
// UiState of the InterestsScreen
val uiState by interestsViewModel.uiState.collectAsState()
val uiState by interestsViewModel.uiState.collectAsStateWithLifecycle()

// Describe the screen sections here since each section needs 2 states and 1 event.
// Pass them to the stateless InterestsScreen using a tabContent.
val topicsSection = TabContent(Sections.Topics) {
val selectedTopics by interestsViewModel.selectedTopics.collectAsState()
val selectedTopics by interestsViewModel.selectedTopics.collectAsStateWithLifecycle()
TabWithSections(
sections = uiState.topics,
selectedTopics = selectedTopics,
Expand All @@ -183,7 +185,7 @@ fun rememberTabContent(interestsViewModel: InterestsViewModel): List<TabContent>
}

val peopleSection = TabContent(Sections.People) {
val selectedPeople by interestsViewModel.selectedPeople.collectAsState()
val selectedPeople by interestsViewModel.selectedPeople.collectAsStateWithLifecycle()
TabWithTopics(
topics = uiState.people,
selectedTopics = selectedPeople,
Expand All @@ -192,7 +194,8 @@ fun rememberTabContent(interestsViewModel: InterestsViewModel): List<TabContent>
}

val publicationSection = TabContent(Sections.Publications) {
val selectedPublications by interestsViewModel.selectedPublications.collectAsState()
val selectedPublications by interestsViewModel.selectedPublications
.collectAsStateWithLifecycle()
TabWithTopics(
topics = uiState.publications,
selectedTopics = selectedPublications,
Expand Down
Loading

0 comments on commit 355a4a6

Please sign in to comment.