Skip to content

Commit

Permalink
Upgraded to Material3
Browse files Browse the repository at this point in the history
  • Loading branch information
handstandsam committed Jun 27, 2024
1 parent 16b76db commit 207c6d9
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 67 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dependencies {
// AndroidX Libraries
implementation(libs.androidx.appcompat.v7)
implementation(libs.androidx.material)
implementation(libs.androidx.material3)
implementation(libs.androidx.lifecycle.runtime.ktx)

// Networking)
Expand All @@ -82,11 +83,10 @@ dependencies {
implementation(libs.timber)

// Compose
// implementation( libs.androidx.compose.compiler)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.material3)
implementation(libs.androidx.compose.material.icons.extended)
implementation(libs.androidx.compose.animation)
implementation(libs.androidx.compose.ui.tooling)
Expand Down
23 changes: 6 additions & 17 deletions app/dependencies/debugRuntimeClasspath.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
androidx.activity:activity-compose:1.7.2
androidx.activity:activity-ktx:1.7.2
androidx.activity:activity:1.7.2
androidx.annotation:annotation-experimental:1.3.0
androidx.annotation:annotation-experimental:1.4.0
androidx.annotation:annotation-jvm:1.7.0
androidx.annotation:annotation:1.7.0
androidx.appcompat:appcompat-resources:1.6.1
androidx.appcompat:appcompat:1.6.1
androidx.arch.core:core-common:2.2.0
androidx.arch.core:core-runtime:2.2.0
androidx.autofill:autofill:1.0.0
androidx.cardview:cardview:1.0.0
androidx.collection:collection-jvm:1.4.0
androidx.collection:collection-ktx:1.4.0
androidx.collection:collection:1.4.0
Expand All @@ -27,6 +26,8 @@ androidx.compose.foundation:foundation-android:1.6.8
androidx.compose.foundation:foundation-layout-android:1.6.8
androidx.compose.foundation:foundation-layout:1.6.8
androidx.compose.foundation:foundation:1.6.8
androidx.compose.material3:material3-android:1.2.1
androidx.compose.material3:material3:1.2.1
androidx.compose.material:material-android:1.6.8
androidx.compose.material:material-icons-core-android:1.6.8
androidx.compose.material:material-icons-core:1.6.8
Expand Down Expand Up @@ -58,23 +59,18 @@ androidx.compose.ui:ui-util-android:1.6.8
androidx.compose.ui:ui-util:1.6.8
androidx.compose.ui:ui:1.6.8
androidx.concurrent:concurrent-futures:1.1.0
androidx.constraintlayout:constraintlayout-solver:2.0.1
androidx.constraintlayout:constraintlayout:2.0.1
androidx.coordinatorlayout:coordinatorlayout:1.1.0
androidx.core:core-ktx:1.12.0
androidx.core:core:1.12.0
androidx.cursoradapter:cursoradapter:1.0.0
androidx.customview:customview-poolingcontainer:1.0.0
androidx.customview:customview:1.1.0
androidx.documentfile:documentfile:1.0.0
androidx.drawerlayout:drawerlayout:1.1.1
androidx.dynamicanimation:dynamicanimation:1.0.0
androidx.customview:customview:1.0.0
androidx.drawerlayout:drawerlayout:1.0.0
androidx.emoji2:emoji2-views-helper:1.3.0
androidx.emoji2:emoji2:1.3.0
androidx.exifinterface:exifinterface:1.3.3
androidx.fragment:fragment:1.3.6
androidx.interpolator:interpolator:1.0.0
androidx.legacy:legacy-support-core-utils:1.0.0
androidx.lifecycle:lifecycle-common-java8:2.6.2
androidx.lifecycle:lifecycle-common:2.6.2
androidx.lifecycle:lifecycle-livedata-core:2.6.2
androidx.lifecycle:lifecycle-livedata:2.6.2
Expand All @@ -85,20 +81,15 @@ androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2
androidx.lifecycle:lifecycle-viewmodel:2.6.2
androidx.loader:loader:1.0.0
androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
androidx.print:print:1.0.0
androidx.profileinstaller:profileinstaller:1.3.0
androidx.recyclerview:recyclerview:1.1.0
androidx.resourceinspection:resourceinspection-annotation:1.0.1
androidx.savedstate:savedstate-ktx:1.2.1
androidx.savedstate:savedstate:1.2.1
androidx.startup:startup-runtime:1.1.1
androidx.tracing:tracing:1.0.0
androidx.transition:transition:1.2.0
androidx.vectordrawable:vectordrawable-animated:1.1.0
androidx.vectordrawable:vectordrawable:1.1.0
androidx.versionedparcelable:versionedparcelable:1.1.1
androidx.viewpager2:viewpager2:1.0.0
androidx.viewpager:viewpager:1.0.0
com.github.bumptech.glide:annotations:4.11.0
com.github.bumptech.glide:disklrucache:4.11.0
Expand All @@ -109,8 +100,6 @@ com.github.skydoves:landscapist:1.3.0
com.google.accompanist:accompanist-coil:0.15.0
com.google.accompanist:accompanist-drawablepainter:0.25.1
com.google.accompanist:accompanist-imageloading-core:0.15.0
com.google.android.material:material:1.9.0
com.google.errorprone:error_prone_annotations:2.15.0
com.google.guava:listenablefuture:1.0
com.jakewharton.timber:timber:4.5.1
com.squareup.okhttp3:logging-interceptor:4.11.0
Expand Down
41 changes: 20 additions & 21 deletions app/src/main/java/com/handstandsam/shoppingapp/compose/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ package com.handstandsam.shoppingapp.compose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Shapes
import androidx.compose.material.Typography
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
Expand Down Expand Up @@ -37,29 +33,32 @@ private val appFontFamily = FontFamily(

private val defaultTypography = Typography()
val appTypography = Typography(
h1 = defaultTypography.h1.copy(fontFamily = appFontFamily),
h2 = defaultTypography.h2.copy(fontFamily = appFontFamily),
h3 = defaultTypography.h3.copy(fontFamily = appFontFamily),
h4 = defaultTypography.h4.copy(fontFamily = appFontFamily),
h5 = defaultTypography.h5.copy(fontFamily = appFontFamily),
h6 = defaultTypography.h6.copy(fontFamily = appFontFamily),
subtitle1 = defaultTypography.subtitle1.copy(fontFamily = appFontFamily),
subtitle2 = defaultTypography.subtitle2.copy(fontFamily = appFontFamily),
body1 = defaultTypography.body1.copy(fontFamily = appFontFamily),
body2 = defaultTypography.body2.copy(fontFamily = appFontFamily),
button = defaultTypography.button.copy(fontFamily = appFontFamily),
caption = defaultTypography.caption.copy(fontFamily = appFontFamily),
overline = defaultTypography.overline.copy(fontFamily = appFontFamily)

displayLarge = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
displayMedium = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
displaySmall = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
headlineLarge = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
headlineMedium = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
headlineSmall = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
titleLarge = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
titleMedium = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
titleSmall = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
bodyLarge = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
bodyMedium = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
bodySmall = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
labelLarge = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
labelMedium = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
labelSmall = defaultTypography.displayLarge.copy(fontFamily = appFontFamily),
)


private val dark = darkColors(
private val dark = darkColorScheme(
// primary = purple200,
// primaryVariant = purple700,
// secondary = teal200
)

private val light = lightColors(
private val light = lightColorScheme(
// background = Color.White,
// secondary = teal200,
// background = Color.LightGray
Expand Down Expand Up @@ -88,7 +87,7 @@ fun MyApplicationTheme(
val colors = if (isSystemInDarkTheme) dark else light

MaterialTheme(
colors = colors,
colorScheme = colors,
typography = appTypography,
shapes = shapes,
content = content
Expand Down
6 changes: 3 additions & 3 deletions compose-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ kotlin {
}
val jvmMain by sourceSets.getting {
dependencies {
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.ui)
api(libs.androidx.material3)
api(libs.androidx.compose.foundation)
api(libs.androidx.compose.ui)

implementation(project(":models"))
implementation(project(":mock-data"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
//import androidx.compose.material.DropdownMenu
//import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.ShoppingCart
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand All @@ -33,6 +29,7 @@ import com.handstandsam.shoppingapp.models.totalItemCount
import kotlinx.coroutines.flow.Flow


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AppScaffold(
itemsInCart: Flow<List<ItemWithQuantity>>,
Expand All @@ -45,14 +42,14 @@ fun AppScaffold(
) {
val itemCount by itemsInCart.collectAsState(initial = listOf())

val navigationIcon: @Composable (() -> Unit)? = if (homeUpClicked != null) {
val navigationIcon: @Composable (() -> Unit) = if (homeUpClicked != null) {
{
IconButton(onClick = homeUpClicked) {
Icon(Icons.Default.ArrowBack, contentDescription = "Back")
}
}
} else {
null
{}
}
Scaffold(
topBar = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -44,7 +44,7 @@ fun HomeScreen(
.fillMaxWidth()
.padding(16.dp),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.body1
style = MaterialTheme.typography.bodySmall
)
LazyColumn(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -65,7 +65,7 @@ fun ShoppingCartScreen(
.fillMaxWidth()
.padding(16.dp),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.body1
style = MaterialTheme.typography.bodySmall
)
LazyColumn(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.handstandsam.shoppingapp.compose

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
Expand All @@ -28,7 +28,7 @@ fun TextWithShadow(
modifier = modifier
.fillMaxSize()
.padding(16.dp),
style = MaterialTheme.typography.h4.copy(
style = MaterialTheme.typography.headlineSmall.copy(
fontSize = 24.sp,
fontWeight = FontWeight.Bold,
shadow = Shadow(
Expand Down
4 changes: 4 additions & 0 deletions desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
kotlin("jvm")
alias(libs.plugins.compose.compiler)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.dependency.guard)
application
}

Expand All @@ -17,6 +18,9 @@ dependencies {
implementation(project(":shopping-cart"))
}

dependencyGuard {
configuration("runtimeClasspath")
}

//compose.desktop {
//}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.mutableStateOf
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ androidx_activity = "1.7.2"
androidx_appcompat = "1.6.1"
androidx_androidx = "1.3.0"
androidx_material = "1.9.0"
androidx_material3 = "1.2.1"
androidx_lifecycle = "2.6.2"
androidx_persistence = "2.5.2"
androidx_test_orchestrator = "1.4.2"
Expand Down Expand Up @@ -48,7 +49,6 @@ androidx_compose_runtime = { module = "androidx.compose.runtime:runtime", versio
androidx_compose_ui = { module = "androidx.compose.ui:ui", 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_icons_extended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" }
androidx_compose_animation = { module = "androidx.compose.animation:animation", version.ref = "compose" }
androidx_compose_runtime_livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose" }
Expand All @@ -58,6 +58,8 @@ androidx_espresso_contrib = { module = "androidx.test.espresso:espresso-contrib"
androidx_lifecycle_livedata_core = { module = "androidx.lifecycle:lifecycle-livedata-core", version.ref = "androidx_lifecycle" }
androidx_lifecycle_runtime_ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx_lifecycle" }
androidx_material = { module = "com.google.android.material:material", version.ref = "androidx_material" }
#androidx_compose_material = { module = "androidx.compose.material:material", version.ref = "compose" }
androidx_material3 = { module = "androidx.compose.material3:material3", version.ref = "androidx_material3" }
androidx_persistence_room_runtime = { module = "androidx.room:room-runtime", version.ref = "androidx_persistence" }
androidx_persistence_room_kapt = { module = "androidx.room:room-compiler", version.ref = "androidx_persistence" }
androidx_persistence_room_ktx = { module = "androidx.room:room-ktx", version.ref = "androidx_persistence" }
Expand Down

0 comments on commit 207c6d9

Please sign in to comment.