Skip to content

Commit

Permalink
Merge pull request #478 from tiwiz/clean-projects
Browse files Browse the repository at this point in the history
Update Feed-Compose to latest compose version
  • Loading branch information
tiwiz authored Sep 12, 2024
2 parents b9e3899 + 6ce1455 commit 5a9cfd8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
8 changes: 4 additions & 4 deletions CanonicalLayouts/feed-compose/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ composeCompiler {
}

dependencies {
def composeBom = platform('androidx.compose:compose-bom:2024.08.00')
def composeBom = platform('androidx.compose:compose-bom:2024.09.00')
implementation(composeBom)
androidTestImplementation(composeBom)

Expand All @@ -76,9 +76,9 @@ dependencies {
implementation 'androidx.compose.material3:material3'
implementation 'androidx.compose.material3:material3-window-size-class'
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
implementation 'androidx.activity:activity-compose:1.9.1'
implementation 'androidx.navigation:navigation-compose:2.7.7'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.5'
implementation 'androidx.activity:activity-compose:1.9.2'
implementation 'androidx.navigation:navigation-compose:2.8.0'
implementation 'io.coil-kt:coil-compose:2.2.1'

testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ package com.example.feedcompose.ui.components
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.example.feedcompose.R


@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun TopAppBar(onBackPressed: () -> Unit = {}) {
SmallTopAppBar(
title = { Text(text = stringResource(id = R.string.app_name)) },
navigationIcon = { BackButton(onBackPressed) }
)
internal fun SweetTopAppBar(onBackPressed: () -> Unit) {
TopAppBar(title = { Text(text = stringResource(id = R.string.app_name)) },
navigationIcon = {
BackButton(onBackPressed = onBackPressed)
})
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.example.feedcompose.R
import com.example.feedcompose.data.Sweets
import com.example.feedcompose.ui.components.TopAppBar
import com.example.feedcompose.ui.components.SweetTopAppBar

@Composable
fun SweetsDetails(
Expand All @@ -53,18 +53,21 @@ fun SweetsDetails(
scrollState = scrollState,
onBackPressed = onBackPressed
)

WindowWidthSizeClass.Compact -> SweetsDetailsVertical(
sweets = sweets,
scrollState = scrollState,
onBackPressed = onBackPressed
)

else -> {
when (windowSizeClass.heightSizeClass) {
WindowHeightSizeClass.Expanded -> SweetsDetailsVertical(
sweets = sweets,
scrollState = scrollState,
onBackPressed = onBackPressed
)

else -> SweetsDetailsHorizontal(
sweets = sweets,
scrollState = scrollState,
Expand All @@ -82,7 +85,7 @@ private fun SweetsDetailsVertical(
onBackPressed: () -> Unit
) {
Column(modifier = Modifier.verticalScroll(scrollState)) {
TopAppBar(onBackPressed = onBackPressed)
SweetTopAppBar(onBackPressed = onBackPressed)
AsyncImage(
model = sweets.imageUrl,
contentDescription = stringResource(id = R.string.thumbnail_content_description),
Expand All @@ -105,7 +108,7 @@ private fun SweetsDetailsHorizontal(
onBackPressed: () -> Unit
) {
Column {
TopAppBar(onBackPressed = onBackPressed)
SweetTopAppBar(onBackPressed = onBackPressed)
Row {
AsyncImage(
model = sweets.imageUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 The Android Open Source Project
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,13 +20,11 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import com.example.supportingpanecompose.ui.SupportingPaneSample
import com.example.supportingpanecompose.ui.theme.SupportingPaneCompose

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Expand Down

0 comments on commit 5a9cfd8

Please sign in to comment.