Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e0d0892
Update AS Canary version & added download link
JetpackDuba Dec 4, 2020
d15fe93
[Jetnews] Update to snapshot 7024175
JolandaVerhoef Dec 10, 2020
119df1d
Updates Crane to 7001724 snapshot
Dec 11, 2020
cf7173a
Removes unused import
Dec 11, 2020
14f883f
[Crane] Updates to 7024175 snapshot
Dec 11, 2020
b6abae4
[Jetnews] Update to snapshot 7030654
JolandaVerhoef Dec 14, 2020
741b5ad
[Jetnews] Apply spotless fixes
JolandaVerhoef Dec 14, 2020
3d0b3bc
[Jetcaster] Upgrade to alpha09 snapshot
yrezgui Dec 14, 2020
17c6687
[Jetnews] Fix swipe to refresh using nested scrolling
JolandaVerhoef Dec 15, 2020
882e0b4
[Crane] Update to snapshot 7033025
JolandaVerhoef Dec 15, 2020
9325b2b
[Jetnews] Upgrade to snapshot 7033025
JolandaVerhoef Dec 15, 2020
77c7e37
[Crane] Spotless fixes
JolandaVerhoef Dec 15, 2020
8faa6b7
[Jetnews] Explain workaround for swipe to refresh
JolandaVerhoef Dec 15, 2020
fd80518
[Jetcaster] Update to 7033025 snapshot
yrezgui Dec 15, 2020
485b9a3
[Jetsnack] Update to snapshot 7033025.
nickbutcher Dec 15, 2020
064ce45
[Jetcaster] Apply Spotless
yrezgui Dec 15, 2020
2c91ab2
[Jetchat] Updates to 7033025
JoseAlcerreca Dec 14, 2020
357372c
[Crane] Update dependencies
JolandaVerhoef Dec 15, 2020
244576b
[Jetchat] Adds nav bar padding to FAB
JoseAlcerreca Dec 15, 2020
57931f9
Merge pull request #323 from android/nb/js_alpha09
nickbutcher Dec 15, 2020
1795edb
[Owl] Update to snapshot 7033025.
nickbutcher Dec 15, 2020
4963947
Removed AS Version from README.md
JetpackDuba Dec 15, 2020
eedf36a
Merge branch 'dev_alpha09' into patch-1
nickbutcher Dec 15, 2020
eb26568
Merge pull request #312 from aeab13/patch-1
nickbutcher Dec 15, 2020
e9086d7
Merge branch 'dev_alpha09' into jetcaster_alpha09
yrezgui Dec 15, 2020
6fbc02a
[Jetcaster] Use trailing lambda
yrezgui Dec 15, 2020
3278466
[Crane] Fix tests
JolandaVerhoef Dec 16, 2020
3d1065c
Merge branch 'dev_alpha09' into jv/js_alpha09
JolandaVerhoef Dec 16, 2020
c619d03
[Jetchat] Test cleanup
JoseAlcerreca Dec 16, 2020
52c1990
Merge branch 'dev_alpha09' into mv/crane_alpha09
JolandaVerhoef Dec 16, 2020
67229f1
[Jetsurvey] Updating to 7033025 snapshot
florina-muntenescu Dec 16, 2020
0b9d1a2
Merge pull request #322 from yrezgui/jetcaster_alpha09
yrezgui Dec 16, 2020
70c88fd
Merge branch 'dev_alpha09' into jetchat_alpha09
JoseAlcerreca Dec 16, 2020
ba5c2fa
Merge branch 'dev_alpha09' into jv/js_alpha09
JolandaVerhoef Dec 16, 2020
c57d56f
Merge branch 'dev_alpha09' into mv/crane_alpha09
JolandaVerhoef Dec 16, 2020
f91fb37
Merge pull request #324 from JoseAlcerreca/jetchat_alpha09
JoseAlcerreca Dec 16, 2020
0ef7f45
[Jetchat] Enables --android flag in ktlint
JoseAlcerreca Dec 16, 2020
c798188
Merge branch 'dev_alpha09' into mv/crane_alpha09
JolandaVerhoef Dec 16, 2020
2e800d7
Merge pull request #316 from android/mv/crane_alpha09
JolandaVerhoef Dec 16, 2020
73d3f51
Merge branch 'dev_alpha09' into jv/js_alpha09
JolandaVerhoef Dec 16, 2020
6c66083
Merge pull request #319 from android/jv/js_alpha09
JolandaVerhoef Dec 16, 2020
8574ab5
Merge branch 'dev_alpha09' into nb/owl_alpha09
JolandaVerhoef Dec 16, 2020
4becf15
Merge pull request #329 from JoseAlcerreca/jetchat_ktlint
JoseAlcerreca Dec 16, 2020
99034f5
Merge pull request #331 from JoseAlcerreca/rally_alpha09
JoseAlcerreca Dec 16, 2020
1991337
Merge pull request #328 from android/fm/jetsurvey_alpha09
florina-muntenescu Dec 16, 2020
a525bfc
Merge branch 'dev_alpha09' into nb/owl_alpha09
JolandaVerhoef Dec 16, 2020
a0b19f4
Merge pull request #327 from android/nb/owl_alpha09
JolandaVerhoef Dec 16, 2020
342a0b1
[All] Update to alpha09
JolandaVerhoef Dec 17, 2020
96c0c6f
[All] Remove maven reference
JolandaVerhoef Dec 17, 2020
f240e6e
Merge pull request #332 from android/jv/alpha09
JolandaVerhoef Dec 17, 2020
a5f658f
Merge branch 'main' into dev_alpha09
chrisbanes Dec 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.example.jetsnack.ui.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -26,13 +27,14 @@ import androidx.compose.foundation.layout.defaultMinSizeConstraints
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ButtonConstants
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ProvideTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import com.example.jetsnack.ui.theme.JetsnackTheme
Expand All @@ -48,7 +50,7 @@ fun JetsnackButton(
disabledBackgroundGradient: List<Color> = JetsnackTheme.colors.interactiveSecondary,
contentColor: Color = JetsnackTheme.colors.textInteractive,
disabledContentColor: Color = JetsnackTheme.colors.textHelp,
contentPadding: PaddingValues = ButtonConstants.DefaultContentPadding,
contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
content: @Composable RowScope.() -> Unit
) {
JetsnackSurface(
Expand All @@ -58,8 +60,10 @@ fun JetsnackButton(
border = border,
modifier = modifier
.clip(shape)
.horizontalGradientBackground(
colors = if (enabled) backgroundGradient else disabledBackgroundGradient
.background(
Brush.horizontalGradient(
colors = if (enabled) backgroundGradient else disabledBackgroundGradient
)
)
.clickable(
onClick = onClick,
Expand All @@ -72,8 +76,8 @@ fun JetsnackButton(
Row(
Modifier
.defaultMinSizeConstraints(
minWidth = ButtonConstants.DefaultMinWidth,
minHeight = ButtonConstants.DefaultMinHeight
minWidth = ButtonDefaults.MinWidth,
minHeight = ButtonDefaults.MinHeight
)
.fillMaxWidth()
.padding(contentPadding),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,76 +19,34 @@ package com.example.jetsnack.ui.components
import androidx.compose.animation.animate
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.HorizontalGradient
import androidx.compose.ui.graphics.LinearGradient
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp

fun Modifier.horizontalGradientBackground(
colors: List<Color>
) = drawWithCache {
// Use drawWithCache modifier to create and cache the gradient once size is known or changes.
val gradient = HorizontalGradient(
startX = 0.0f,
endX = size.width,
colors = colors
)
onDrawBehind {
drawRect(brush = gradient)
}
}

fun Modifier.diagonalGradientTint(
colors: List<Color>,
blendMode: BlendMode
) = gradientTint(colors, blendMode) { gradientColors, size ->
LinearGradient(
colors = gradientColors,
startX = 0f,
startY = 0f,
endX = size.width,
endY = size.height
) = drawWithContent {
drawContent()
drawRect(
brush = Brush.linearGradient(colors),
blendMode = blendMode
)
}

fun Modifier.gradientTint(
colors: List<Color>,
blendMode: BlendMode,
brushProvider: (List<Color>, Size) -> LinearGradient
) = composed {
var size by remember { mutableStateOf(Size.Zero) }
val gradient = remember(colors, size) { brushProvider(colors, size) }
drawWithContent {
drawContent()
size = this.size
drawRect(
brush = gradient,
blendMode = blendMode
)
}
}

fun Modifier.offsetGradientBackground(
colors: List<Color>,
width: Float,
offset: Float = 0f
) = background(
HorizontalGradient(
Brush.horizontalGradient(
colors,
startX = -offset,
endX = width - offset,
Expand All @@ -100,19 +58,11 @@ fun Modifier.diagonalGradientBorder(
colors: List<Color>,
borderSize: Dp = 2.dp,
shape: Shape
) = gradientBorder(
colors = colors,
borderSize = borderSize,
) = border(
width = borderSize,
brush = Brush.linearGradient(colors),
shape = shape
) { gradientColors, size ->
LinearGradient(
colors = gradientColors,
startX = 0f,
startY = 0f,
endX = size.width.toFloat(),
endY = size.height.toFloat()
)
}
)

fun Modifier.fadeInDiagonalGradientBorder(
showBorder: Boolean,
Expand All @@ -129,19 +79,3 @@ fun Modifier.fadeInDiagonalGradientBorder(
shape = shape
)
}

fun Modifier.gradientBorder(
colors: List<Color>,
borderSize: Dp = 2.dp,
shape: Shape,
brushProvider: (List<Color>, IntSize) -> LinearGradient
) = composed {
var size by remember { mutableStateOf(IntSize.Zero) }
val gradient = remember(colors, size) { brushProvider(colors, size) }
val sizeProvider = onSizeChanged { size = it }
sizeProvider then border(
width = borderSize,
brush = gradient,
shape = shape
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.example.jetsnack.ui.components

import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material.DrawerConstants
import androidx.compose.material.DrawerDefaults
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FabPosition
import androidx.compose.material.MaterialTheme
Expand Down Expand Up @@ -51,7 +51,7 @@ fun JetsnackScaffold(
isFloatingActionButtonDocked: Boolean = false,
drawerContent: @Composable (ColumnScope.() -> Unit)? = null,
drawerShape: Shape = MaterialTheme.shapes.large,
drawerElevation: Dp = DrawerConstants.DefaultElevation,
drawerElevation: Dp = DrawerDefaults.Elevation,
drawerBackgroundColor: Color = JetsnackTheme.colors.uiBackground,
drawerContentColor: Color = JetsnackTheme.colors.textSecondary,
drawerScrimColor: Color = JetsnackTheme.colors.uiBorder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import androidx.compose.foundation.layout.preferredHeightIn
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyRowFor
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Icon
Expand Down Expand Up @@ -61,8 +61,8 @@ private val HighlightCardWidth = 170.dp
private val HighlightCardPadding = 16.dp

// The Cards show a gradient which spans 3 cards and scrolls with parallax.
@Composable
private val gradientWidth
@Composable
get() = with(AmbientDensity.current) {
(3 * (HighlightCardWidth + HighlightCardPadding).toPx())
}
Expand Down Expand Up @@ -144,12 +144,13 @@ private fun Snacks(
onSnackClick: (Long) -> Unit,
modifier: Modifier = Modifier
) {
LazyRowFor(
items = snacks,
LazyRow(
modifier = modifier,
contentPadding = PaddingValues(start = 12.dp, end = 12.dp)
) { snack ->
SnackItem(snack, onSnackClick)
) {
items(snacks) { snack ->
SnackItem(snack, onSnackClick)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.jetsnack.ui.home.search

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -25,14 +26,15 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredHeightIn
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumnForIndexed
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -42,16 +44,17 @@ import com.example.jetsnack.model.SearchCategory
import com.example.jetsnack.model.SearchCategoryCollection
import com.example.jetsnack.ui.components.SnackImage
import com.example.jetsnack.ui.components.VerticalGrid
import com.example.jetsnack.ui.components.horizontalGradientBackground
import com.example.jetsnack.ui.theme.JetsnackTheme
import kotlin.math.max

@Composable
fun SearchCategories(
categories: List<SearchCategoryCollection>
) {
LazyColumnForIndexed(categories) { index, collection ->
SearchCategoryCollection(collection, index)
LazyColumn {
itemsIndexed(categories) { index, collection ->
SearchCategoryCollection(collection, index)
}
}
Spacer(Modifier.preferredHeight(8.dp))
}
Expand Down Expand Up @@ -104,7 +107,7 @@ private fun SearchCategory(
.aspectRatio(1.45f)
.shadow(elevation = 3.dp, shape = CategoryShape)
.clip(CategoryShape)
.horizontalGradientBackground(gradient)
.background(Brush.horizontalGradient(gradient))
.clickable { /* todo */ },
content = {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumnForIndexed
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
Expand Down Expand Up @@ -70,8 +70,10 @@ fun SearchResults(
color = JetsnackTheme.colors.textPrimary,
modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp)
)
LazyColumnForIndexed(searchResults) { index, snack ->
SearchResult(snack, onSnackClick, index != 0)
LazyColumn {
itemsIndexed(searchResults) { index, snack ->
SearchResult(snack, onSnackClick, index != 0)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.example.jetsnack.ui.home.search

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -47,9 +46,8 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.ExperimentalFocus
import androidx.compose.ui.focus.isFocused
import androidx.compose.ui.focusObserver
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -160,7 +158,6 @@ class SearchState(
}
}

@OptIn(ExperimentalFoundationApi::class, ExperimentalFocus::class)
@Composable
private fun SearchBar(
query: TextFieldValue,
Expand Down Expand Up @@ -203,7 +200,7 @@ private fun SearchBar(
onValueChange = onQueryChange,
modifier = Modifier
.weight(1f)
.focusObserver {
.onFocusChanged {
onSearchFocusChange(it.isFocused)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.AmbientDensity
Expand All @@ -65,7 +66,6 @@ import com.example.jetsnack.ui.components.JetsnackSurface
import com.example.jetsnack.ui.components.QuantitySelector
import com.example.jetsnack.ui.components.SnackCollection
import com.example.jetsnack.ui.components.SnackImage
import com.example.jetsnack.ui.components.horizontalGradientBackground
import com.example.jetsnack.ui.theme.JetsnackTheme
import com.example.jetsnack.ui.theme.Neutral8
import com.example.jetsnack.ui.utils.formatPrice
Expand Down Expand Up @@ -110,7 +110,7 @@ private fun Header() {
modifier = Modifier
.preferredHeight(280.dp)
.fillMaxWidth()
.horizontalGradientBackground(JetsnackTheme.colors.interactivePrimary)
.background(Brush.horizontalGradient(JetsnackTheme.colors.interactivePrimary))
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ fun JetsnackTheme(
}

object JetsnackTheme {
@Composable
val colors: JetsnackColors
@Composable
get() = AmbientJetsnackColors.current
}

Expand Down
2 changes: 1 addition & 1 deletion Jetsnack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ buildscript {
}

plugins {
id 'com.diffplug.spotless' version '5.7.0'
id 'com.diffplug.spotless' version '5.8.2'
}

subprojects {
Expand Down
Loading