Skip to content

Commit

Permalink
[Owl] Update to snapshot 7123292.
Browse files Browse the repository at this point in the history
Change-Id: Icbc31d7b3f3b19e0b77f1b2514aa76e99ea4b531
  • Loading branch information
nickbutcher committed Feb 10, 2021
1 parent f0f9e67 commit 840d92b
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 71 deletions.
1 change: 1 addition & 0 deletions Owl/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ dependencies {

implementation Libs.AndroidX.coreKtx
implementation Libs.AndroidX.navigation
implementation Libs.AndroidX.Activity.activityCompose

implementation Libs.AndroidX.Compose.runtime
implementation Libs.AndroidX.Compose.foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import androidx.compose.ui.test.performClick
import com.example.owl.R
import com.example.owl.model.courses
import com.example.owl.ui.fakes.ProvideTestImageLoader
import com.example.owl.ui.utils.AmbientBackDispatcher
import com.example.owl.ui.utils.LocalBackDispatcher
import dev.chrisbanes.accompanist.insets.ProvideWindowInsets
import org.junit.Rule
import org.junit.Test
Expand All @@ -48,7 +48,7 @@ class NavigationTest {
private fun startActivity(startDestination: String? = null) {
composeTestRule.setContent {
val backDispatcher = composeTestRule.activity.onBackPressedDispatcher
Providers(AmbientBackDispatcher provides backDispatcher) {
Providers(LocalBackDispatcher provides backDispatcher) {
ProvideWindowInsets {
ProvideTestImageLoader {
if (startDestination == null) {
Expand Down
2 changes: 1 addition & 1 deletion Owl/app/src/main/java/com/example/owl/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.example.owl.ui

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.compose.ui.platform.setContent
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat

class MainActivity : ComponentActivity() {
Expand Down
4 changes: 2 additions & 2 deletions Owl/app/src/main/java/com/example/owl/ui/OwlApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package com.example.owl.ui
import androidx.activity.OnBackPressedDispatcher
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
import com.example.owl.ui.utils.AmbientBackDispatcher
import com.example.owl.ui.utils.LocalBackDispatcher
import com.example.owl.ui.utils.ProvideImageLoader
import dev.chrisbanes.accompanist.insets.ProvideWindowInsets

@Composable
fun OwlApp(backDispatcher: OnBackPressedDispatcher) {

Providers(AmbientBackDispatcher provides backDispatcher) {
Providers(LocalBackDispatcher provides backDispatcher) {
ProvideWindowInsets {
ProvideImageLoader {
NavGraph()
Expand Down
28 changes: 14 additions & 14 deletions Owl/app/src/main/java/com/example/owl/ui/course/CourseDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.AmbientContentAlpha
import androidx.compose.material.ContentAlpha
import androidx.compose.material.Divider
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FractionalThreshold
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
Expand All @@ -67,9 +67,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -89,7 +89,7 @@ import com.example.owl.ui.utils.NetworkImage
import com.example.owl.ui.utils.backHandler
import com.example.owl.ui.utils.lerp
import com.example.owl.ui.utils.scrim
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.LocalWindowInsets
import dev.chrisbanes.accompanist.insets.navigationBarsPadding
import dev.chrisbanes.accompanist.insets.statusBarsPadding
import dev.chrisbanes.accompanist.insets.toPaddingValues
Expand Down Expand Up @@ -119,7 +119,7 @@ fun CourseDetails(
PinkTheme {
BoxWithConstraints {
val sheetState = rememberSwipeableState(SheetState.Closed)
val fabSize = with(AmbientDensity.current) { FabSize.toPx() }
val fabSize = with(LocalDensity.current) { FabSize.toPx() }
val dragRange = constraints.maxHeight - fabSize

backHandler(
Expand Down Expand Up @@ -201,7 +201,7 @@ private fun CourseDescriptionHeader(
)
}
Image(
imageVector = vectorResource(id = R.drawable.ic_logo),
painter = painterResource(id = R.drawable.ic_logo),
contentDescription = null,
modifier = Modifier
.padding(bottom = 4.dp)
Expand Down Expand Up @@ -245,7 +245,7 @@ private fun CourseDescriptionBody(course: Course) {
.padding(horizontal = 16.dp)
)
Spacer(modifier = Modifier.preferredHeight(16.dp))
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Providers(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.course_desc),
style = MaterialTheme.typography.body1,
Expand All @@ -264,7 +264,7 @@ private fun CourseDescriptionBody(course: Course) {
.fillMaxWidth()
.padding(16.dp)
)
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Providers(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.needs),
style = MaterialTheme.typography.body1,
Expand Down Expand Up @@ -337,8 +337,8 @@ private fun LessonsSheet(
updateSheet: (SheetState) -> Unit
) {
// Use the fraction that the sheet is open to drive the transformation from FAB -> Sheet
val fabSize = with(AmbientDensity.current) { FabSize.toPx() }
val fabSheetHeight = fabSize + AmbientWindowInsets.current.systemBars.bottom
val fabSize = with(LocalDensity.current) { FabSize.toPx() }
val fabSheetHeight = fabSize + LocalWindowInsets.current.systemBars.bottom
val offsetX = lerp(width - fabSize, 0f, 0f, 0.15f, openFraction)
val offsetY = lerp(height - fabSheetHeight, 0f, openFraction)
val tlCorner = lerp(fabSize, 0f, 0f, 0.15f, openFraction)
Expand All @@ -351,8 +351,8 @@ private fun LessonsSheet(
)
Surface(
color = surfaceColor,
contentColor = contentColorFor(color = MaterialTheme.colors.primarySurface),
shape = RoundedCornerShape(topLeft = tlCorner),
contentColor = contentColorFor(backgroundColor = MaterialTheme.colors.primarySurface),
shape = RoundedCornerShape(topStart = tlCorner),
modifier = Modifier.graphicsLayer {
translationX = offsetX
translationY = offsetY
Expand Down Expand Up @@ -409,7 +409,7 @@ private fun Lessons(
}
LazyColumn(
state = scroll,
contentPadding = AmbientWindowInsets.current.systemBars.toPaddingValues(
contentPadding = LocalWindowInsets.current.systemBars.toPaddingValues(
top = false
)
) {
Expand Down Expand Up @@ -465,7 +465,7 @@ private fun Lesson(lesson: Lesson) {
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Providers(LocalContentAlpha provides ContentAlpha.medium) {
Row(
modifier = Modifier.padding(top = 4.dp),
verticalAlignment = Alignment.CenterVertically
Expand Down
10 changes: 5 additions & 5 deletions Owl/app/src/main/java/com/example/owl/ui/courses/Courses.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import androidx.annotation.StringRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.material.AmbientContentColor
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
Expand All @@ -38,8 +38,8 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import com.example.owl.R
import com.example.owl.model.courses
Expand All @@ -61,13 +61,13 @@ fun Courses(selectCourse: (Long) -> Unit) {
) {
tabs.forEach { tab ->
BottomNavigationItem(
icon = { Icon(vectorResource(tab.icon), contentDescription = null) },
icon = { Icon(painterResource(tab.icon), contentDescription = null) },
label = { Text(stringResource(tab.title).toUpperCase()) },
selected = tab == selectedTab,
onClick = { setSelectedTab(tab) },
alwaysShowLabels = false,
selectedContentColor = MaterialTheme.colors.secondary,
unselectedContentColor = AmbientContentColor.current,
unselectedContentColor = LocalContentColor.current,
modifier = Modifier.navigationBarsPadding()
)
}
Expand All @@ -94,7 +94,7 @@ fun CoursesAppBar() {
modifier = Modifier
.padding(16.dp)
.align(Alignment.CenterVertically),
imageVector = vectorResource(id = R.drawable.ic_lockup_white),
painter = painterResource(id = R.drawable.ic_lockup_white),
contentDescription = null
)
IconButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION") // FIXME move to new ConstraintLayout dep once released

package com.example.owl.ui.courses

import androidx.compose.foundation.clickable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fun MyCourse(
CourseListItem(
course = course,
onClick = { selectCourse(course.id) },
shape = RoundedCornerShape(topLeft = 24.dp),
shape = RoundedCornerShape(topStart = 24.dp),
modifier = Modifier.preferredHeight(96.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material.AmbientContentColor
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.LocalContentColor
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
Expand All @@ -38,8 +38,8 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -99,7 +99,7 @@ private fun AppBar(
) {
TopAppBar(elevation = 0.dp) {
Image(
imageVector = vectorResource(id = R.drawable.ic_search),
painter = painterResource(id = R.drawable.ic_search),
contentDescription = null,
modifier = Modifier
.padding(16.dp)
Expand All @@ -110,10 +110,10 @@ private fun AppBar(
value = searchTerm,
onValueChange = updateSearchTerm,
textStyle = MaterialTheme.typography.subtitle1.copy(
color = AmbientContentColor.current
color = LocalContentColor.current
),
maxLines = 1,
cursorColor = AmbientContentColor.current,
cursorColor = LocalContentColor.current,
modifier = Modifier
.weight(1f)
.align(Alignment.CenterVertically)
Expand Down
17 changes: 10 additions & 7 deletions Owl/app/src/main/java/com/example/owl/ui/onboarding/Onboarding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.material.AmbientContentAlpha
import androidx.compose.material.ContentAlpha
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
Expand All @@ -58,8 +59,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -129,7 +130,7 @@ private fun AppBar() {
.statusBarsPadding()
) {
Image(
imageVector = vectorResource(id = OwlTheme.images.lockupLogo),
painter = painterResource(id = OwlTheme.images.lockupLogo),
contentDescription = null,
modifier = Modifier.padding(16.dp)
)
Expand Down Expand Up @@ -187,7 +188,7 @@ private fun TopicChip(topic: Topic) {
Surface(
modifier = Modifier.padding(4.dp),
elevation = OwlTheme.elevations.card,
shape = MaterialTheme.shapes.medium.copy(topLeft = CornerSize(corerRadius))
shape = MaterialTheme.shapes.medium.copy(topStart = CornerSize(corerRadius))
) {
Row(modifier = Modifier.toggleable(value = selected, onValueChange = onSelected)) {
Box {
Expand All @@ -207,7 +208,9 @@ private fun TopicChip(topic: Topic) {
imageVector = Icons.Filled.Done,
contentDescription = null,
tint = MaterialTheme.colors.onPrimary.copy(alpha = selectedAlpha),
modifier = Modifier.scale(checkScale)
modifier = Modifier
.wrapContentSize()
.scale(checkScale)
)
}
}
Expand All @@ -224,9 +227,9 @@ private fun TopicChip(topic: Topic) {
)
)
Row(verticalAlignment = Alignment.CenterVertically) {
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
Providers(LocalContentAlpha provides ContentAlpha.medium) {
Icon(
imageVector = vectorResource(R.drawable.ic_grain),
painter = painterResource(R.drawable.ic_grain),
contentDescription = null,
modifier = Modifier
.padding(start = 16.dp)
Expand Down
4 changes: 2 additions & 2 deletions Owl/app/src/main/java/com/example/owl/ui/theme/Elevations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.example.owl.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticAmbientOf
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

Expand All @@ -27,4 +27,4 @@ import androidx.compose.ui.unit.dp
@Immutable
data class Elevations(val card: Dp = 0.dp)

internal val AmbientElevations = staticAmbientOf { Elevations() }
internal val LocalElevations = staticCompositionLocalOf { Elevations() }
4 changes: 2 additions & 2 deletions Owl/app/src/main/java/com/example/owl/ui/theme/Images.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ package com.example.owl.ui.theme

import androidx.annotation.DrawableRes
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticAmbientOf
import androidx.compose.runtime.staticCompositionLocalOf

/**
* Images that can vary by theme.
*/
@Immutable
data class Images(@DrawableRes val lockupLogo: Int)

internal val AmbientImages = staticAmbientOf<Images>()
internal val AmbientImages = staticCompositionLocalOf<Images>(null)
8 changes: 4 additions & 4 deletions Owl/app/src/main/java/com/example/owl/ui/theme/Shape.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ val shapes = Shapes(
small = RoundedCornerShape(percent = 50),
medium = RoundedCornerShape(size = 0f),
large = RoundedCornerShape(
topLeft = 16.dp,
topRight = 0.dp,
bottomRight = 0.dp,
bottomLeft = 16.dp
topStart = 16.dp,
topEnd = 0.dp,
bottomEnd = 0.dp,
bottomStart = 16.dp
)
)
Loading

0 comments on commit 840d92b

Please sign in to comment.