Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit ff5310a

Browse files
authored
Merge pull request #41 from ricknout/develop
Update Compose to 1.0.0-alpha11
2 parents 65a4826 + 217b168 commit ff5310a

File tree

5 files changed

+95
-94
lines changed

5 files changed

+95
-94
lines changed

buildSrc/src/main/java/com/google/android/material/composethemeadapter/dependencies.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ object Versions {
2121
}
2222

2323
object Libs {
24-
const val androidGradlePlugin = "com.android.tools.build:gradle:7.0.0-alpha04"
24+
const val androidGradlePlugin = "com.android.tools.build:gradle:7.0.0-alpha05"
2525

2626
const val gradleMavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.12.0"
2727

2828
const val mdc = "com.google.android.material:material:1.1.0"
2929

3030
object Kotlin {
31-
const val version = "1.4.21"
31+
const val version = "1.4.21-2"
3232
const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib:$version"
3333
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version"
3434

@@ -52,7 +52,7 @@ object Libs {
5252
else -> throw IllegalArgumentException("Snapshot version not set")
5353
}
5454

55-
private const val version = "1.0.0-alpha10"
55+
private const val version = "1.0.0-alpha11"
5656

5757
const val runtime = "androidx.compose.runtime:runtime:$version"
5858
const val foundation = "androidx.compose.foundation:foundation:${version}"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
distributionBase=GRADLE_USER_HOME
18-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-rc-1-bin.zip
18+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
1919
distributionPath=wrapper/dists
2020
zipStorePath=wrapper/dists
2121
zipStoreBase=GRADLE_USER_HOME

lib/src/androidTest/java/com/google/android/material/composethemeadapter/MdcThemeTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import androidx.compose.ui.platform.AmbientContext
2626
import androidx.compose.ui.platform.AmbientDensity
2727
import androidx.compose.ui.res.colorResource
2828
import androidx.compose.ui.test.junit4.createAndroidComposeRule
29+
import androidx.compose.ui.text.font.Font
2930
import androidx.compose.ui.text.font.FontFamily
3031
import androidx.compose.ui.text.font.FontWeight
31-
import androidx.compose.ui.text.font.asFontFamily
32-
import androidx.compose.ui.text.font.font
32+
import androidx.compose.ui.text.font.toFontFamily
3333
import androidx.compose.ui.unit.Density
3434
import androidx.compose.ui.unit.Dp
3535
import androidx.compose.ui.unit.TextUnit
@@ -127,9 +127,9 @@ class MdcThemeTest<T : AppCompatActivity>(activityClass: Class<T>) {
127127
val typography = MaterialTheme.typography
128128
val density = AmbientDensity.current
129129

130-
val rubik300 = font(R.font.rubik_300).asFontFamily()
131-
val rubik400 = font(R.font.rubik_400).asFontFamily()
132-
val rubik500 = font(R.font.rubik_500).asFontFamily()
130+
val rubik300 = Font(R.font.rubik_300).toFontFamily()
131+
val rubik400 = Font(R.font.rubik_400).toFontFamily()
132+
val rubik500 = Font(R.font.rubik_500).toFontFamily()
133133
val sansSerif = FontFamilyWithWeight(FontFamily.SansSerif)
134134
val sansSerifLight = FontFamilyWithWeight(FontFamily.SansSerif, FontWeight.Light)
135135
val sansSerifBlack = FontFamilyWithWeight(FontFamily.SansSerif, FontWeight.Black)

lib/src/main/java/com/google/android/material/composethemeadapter/TypedArrayUtils.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ import androidx.compose.ui.geometry.Offset
3333
import androidx.compose.ui.graphics.Color
3434
import androidx.compose.ui.graphics.Shadow
3535
import androidx.compose.ui.text.TextStyle
36+
import androidx.compose.ui.text.font.Font
3637
import androidx.compose.ui.text.font.FontFamily
37-
import androidx.compose.ui.text.font.FontListFontFamily
3838
import androidx.compose.ui.text.font.FontStyle
3939
import androidx.compose.ui.text.font.FontWeight
40-
import androidx.compose.ui.text.font.asFontFamily
41-
import androidx.compose.ui.text.font.font
42-
import androidx.compose.ui.text.font.fontFamily
40+
import androidx.compose.ui.text.font.toFontFamily
4341
import androidx.compose.ui.unit.Density
4442
import androidx.compose.ui.unit.TextUnit
4543
import androidx.compose.ui.unit.dp
@@ -214,7 +212,7 @@ internal fun TypedArray.getFontFamilyOrNull(index: Int): FontFamilyWithWeight? {
214212
resources.parseXmlFontFamily(tv.resourceId)?.let(::FontFamilyWithWeight)
215213
} else {
216214
// Otherwise we just load it as a single font
217-
FontFamilyWithWeight(font(tv.resourceId).asFontFamily())
215+
FontFamilyWithWeight(Font(tv.resourceId).toFontFamily())
218216
}
219217
} else null
220218
}
@@ -225,7 +223,7 @@ internal fun TypedArray.getFontFamilyOrNull(index: Int): FontFamilyWithWeight? {
225223

226224
@SuppressLint("RestrictedApi") // FontResourcesParserCompat.*
227225
@RequiresApi(23) // XML font families with >1 fonts are only supported on API 23+
228-
private fun Resources.parseXmlFontFamily(resourceId: Int): FontListFontFamily? {
226+
private fun Resources.parseXmlFontFamily(resourceId: Int): FontFamily? {
229227
val parser = getXml(resourceId)
230228

231229
// Can't use {} since XmlResourceParser is AutoCloseable, not Closeable
@@ -234,13 +232,13 @@ private fun Resources.parseXmlFontFamily(resourceId: Int): FontListFontFamily? {
234232
val result = FontResourcesParserCompat.parse(parser, this)
235233
if (result is FontResourcesParserCompat.FontFamilyFilesResourceEntry) {
236234
val fonts = result.entries.map { font ->
237-
font(
235+
Font(
238236
resId = font.resourceId,
239237
weight = fontWeightOf(font.weight),
240238
style = if (font.isItalic) FontStyle.Italic else FontStyle.Normal
241239
)
242240
}
243-
return fontFamily(fonts)
241+
return FontFamily(fonts)
244242
}
245243
} finally {
246244
parser.close()

sample/src/main/java/com/google/android/material/composethemeadapter/sample/BasicIntegration.kt

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ package com.google.android.material.composethemeadapter.sample
1818

1919
import android.os.Bundle
2020
import androidx.appcompat.app.AppCompatActivity
21-
import androidx.compose.foundation.ScrollableColumn
2221
import androidx.compose.foundation.layout.Column
2322
import androidx.compose.foundation.layout.Spacer
2423
import androidx.compose.foundation.layout.padding
2524
import androidx.compose.foundation.layout.preferredHeight
25+
import androidx.compose.foundation.rememberScrollState
26+
import androidx.compose.foundation.verticalScroll
2627
import androidx.compose.material.Button
2728
import androidx.compose.material.CircularProgressIndicator
2829
import androidx.compose.material.ExtendedFloatingActionButton
@@ -67,88 +68,90 @@ fun ComponentsSample() {
6768
)
6869
}
6970
) {
70-
ScrollableColumn {
71-
Column(Modifier.padding(16.dp)) {
72-
CircularProgressIndicator()
73-
VerticalSpacer()
71+
Column(
72+
modifier = Modifier
73+
.verticalScroll(rememberScrollState())
74+
.padding(16.dp)
75+
) {
76+
CircularProgressIndicator()
77+
VerticalSpacer()
7478

75-
Button(onClick = {}) {
76-
Text(text = "Button")
77-
}
78-
VerticalSpacer()
79+
Button(onClick = {}) {
80+
Text(text = "Button")
81+
}
82+
VerticalSpacer()
7983

80-
OutlinedButton(onClick = {}) {
81-
Text(text = "Outlined Button")
82-
}
83-
VerticalSpacer()
84+
OutlinedButton(onClick = {}) {
85+
Text(text = "Outlined Button")
86+
}
87+
VerticalSpacer()
8488

85-
TextButton(onClick = {}) {
86-
Text(text = "Text Button")
87-
}
88-
VerticalSpacer()
89+
TextButton(onClick = {}) {
90+
Text(text = "Text Button")
91+
}
92+
VerticalSpacer()
8993

90-
FloatingActionButton(
91-
onClick = {},
92-
content = { Icon(Icons.Default.Favorite) }
93-
)
94-
VerticalSpacer()
94+
FloatingActionButton(
95+
onClick = {},
96+
content = { Icon(Icons.Default.Favorite, null) }
97+
)
98+
VerticalSpacer()
9599

96-
ExtendedFloatingActionButton(
97-
onClick = {},
98-
text = { Text(text = "Extended FAB") },
99-
icon = { Icon(Icons.Default.Favorite) }
100-
)
101-
VerticalSpacer()
100+
ExtendedFloatingActionButton(
101+
onClick = {},
102+
text = { Text(text = "Extended FAB") },
103+
icon = { Icon(Icons.Default.Favorite, null) }
104+
)
105+
VerticalSpacer()
102106

103-
Text(
104-
text = "H1",
105-
style = MaterialTheme.typography.h1
106-
)
107-
Text(
108-
text = "Headline 2",
109-
style = MaterialTheme.typography.h2
110-
)
111-
Text(
112-
text = "Headline 3",
113-
style = MaterialTheme.typography.h3
114-
)
115-
Text(
116-
text = "Headline 4",
117-
style = MaterialTheme.typography.h4
118-
)
119-
Text(
120-
text = "Headline 5",
121-
style = MaterialTheme.typography.h5
122-
)
123-
Text(
124-
text = "Headline 6",
125-
style = MaterialTheme.typography.h6
126-
)
127-
Text(
128-
text = "Subtitle 1",
129-
style = MaterialTheme.typography.subtitle1
130-
)
131-
Text(
132-
text = "Subtitle 2",
133-
style = MaterialTheme.typography.subtitle2
134-
)
135-
Text(
136-
text = "Body 1",
137-
style = MaterialTheme.typography.body1
138-
)
139-
Text(
140-
text = "Body 2",
141-
style = MaterialTheme.typography.body2
142-
)
143-
Text(
144-
text = "Caption",
145-
style = MaterialTheme.typography.caption
146-
)
147-
Text(
148-
text = "Overline",
149-
style = MaterialTheme.typography.overline
150-
)
151-
}
107+
Text(
108+
text = "H1",
109+
style = MaterialTheme.typography.h1
110+
)
111+
Text(
112+
text = "Headline 2",
113+
style = MaterialTheme.typography.h2
114+
)
115+
Text(
116+
text = "Headline 3",
117+
style = MaterialTheme.typography.h3
118+
)
119+
Text(
120+
text = "Headline 4",
121+
style = MaterialTheme.typography.h4
122+
)
123+
Text(
124+
text = "Headline 5",
125+
style = MaterialTheme.typography.h5
126+
)
127+
Text(
128+
text = "Headline 6",
129+
style = MaterialTheme.typography.h6
130+
)
131+
Text(
132+
text = "Subtitle 1",
133+
style = MaterialTheme.typography.subtitle1
134+
)
135+
Text(
136+
text = "Subtitle 2",
137+
style = MaterialTheme.typography.subtitle2
138+
)
139+
Text(
140+
text = "Body 1",
141+
style = MaterialTheme.typography.body1
142+
)
143+
Text(
144+
text = "Body 2",
145+
style = MaterialTheme.typography.body2
146+
)
147+
Text(
148+
text = "Caption",
149+
style = MaterialTheme.typography.caption
150+
)
151+
Text(
152+
text = "Overline",
153+
style = MaterialTheme.typography.overline
154+
)
152155
}
153156
}
154157
}

0 commit comments

Comments
 (0)